public function ApigeeEdgeManagementCliServiceTest::testCreateEdgeRoleAndSetPermissions in Apigee Edge 8
Test Edge API for creating role and setting permissions.
File
- tests/
src/ Kernel/ Util/ ApigeeEdgeManagementCliServiceTest.php, line 205
Class
- ApigeeEdgeManagementCliServiceTest
- ApigeeEdgeManagementCliService Edge tests.
Namespace
Drupal\Tests\apigee_edge\Kernel\UtilCode
public function testCreateEdgeRoleAndSetPermissions() {
$this->stack
->queueMockResponse([
'no_content' => [
'status_code' => 201,
],
]);
$url = $this->endpoint . '/o/' . $this->organization . '/userroles';
$response = $this->httpClient
->post($url, json_encode([
'role' => [
self::TEST_ROLE_NAME,
],
]));
$this
->assertEquals('201', $response
->getStatusCode(), 'Role should be created.');
// Add permissions to this role.
$this->stack
->queueMockResponse([
'no_content' => [
'status_code' => 201,
],
]);
$url = $this->endpoint . '/o/' . $this->organization . '/userroles/' . self::TEST_ROLE_NAME . '/permissions';
$body = json_encode([
'path' => '/developers',
'permissions' => [
'get',
'put',
'delete',
],
]);
$response = $this->httpClient
->post($url, $body);
$this
->assertEquals('201', $response
->getStatusCode(), 'Permission on role should be created.');
}