public function RolesTestMocked::testThatAddRolePermissionsRequestIsFormattedProperly in Auth0 Single Sign On 8.2
Test an add role permissions call.
Return value
void
Throws
\Exception Should not be thrown in this test.
File
- vendor/
auth0/ auth0-php/ tests/ API/ Management/ RolesMockedTest.php, line 380
Class
- RolesTestMocked
- Class RolesTestMocked.
Namespace
Auth0\Tests\API\ManagementCode
public function testThatAddRolePermissionsRequestIsFormattedProperly() {
$api = new MockManagementApi([
new Response(200, self::$headers),
]);
$api
->call()
->roles()
->addPermissions('__test_role_id__', [
[
'permission_name' => '__test_permission_name__',
'resource_server_identifier' => '__test_server_id__',
],
]);
$this
->assertEquals('POST', $api
->getHistoryMethod());
$this
->assertEquals('https://api.test.local/api/v2/roles/__test_role_id__/permissions', $api
->getHistoryUrl());
$headers = $api
->getHistoryHeaders();
$this
->assertEquals('Bearer __api_token__', $headers['Authorization'][0]);
$this
->assertEquals('application/json', $headers['Content-Type'][0]);
$this
->assertEquals(self::$expectedTelemetry, $headers['Auth0-Client'][0]);
$body = $api
->getHistoryBody();
$this
->assertArrayHasKey('permissions', $body);
$this
->assertCount(1, $body['permissions']);
$this
->assertArrayHasKey('permission_name', $body['permissions'][0]);
$this
->assertEquals('__test_permission_name__', $body['permissions'][0]['permission_name']);
$this
->assertArrayHasKey('resource_server_identifier', $body['permissions'][0]);
$this
->assertEquals('__test_server_id__', $body['permissions'][0]['resource_server_identifier']);
}