public function DeveloperAppApiKeyTest::testAppApiKeyRevoke in Apigee Edge 8
Test app API key revoke action.
Throws
\Behat\Mink\Exception\ResponseTextException
\Drupal\Core\Entity\EntityMalformedException
File
- tests/
src/ Functional/ DeveloperAppApiKeyTest.php, line 331
Class
- DeveloperAppApiKeyTest
- Developer app API key test.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
public function testAppApiKeyRevoke() {
$credentials = [];
if (empty($this->consumer_key)) {
$this->consumer_key = $this
->randomMachineName(32);
$credentials = [
[
"consumerKey" => $this->consumer_key,
"consumerSecret" => $this
->randomMachineName(),
"status" => AppCredentialInterface::STATUS_APPROVED,
],
[
"consumerKey" => $this
->randomMachineName(),
"consumerSecret" => $this
->randomMachineName(),
"status" => AppCredentialInterface::STATUS_APPROVED,
],
];
}
else {
$credController = $this->appCredentialController
->developerAppCredentialController($this->developerApp
->getAppOwner(), $this->developerApp
->getName());
$credController
->create($this
->randomMachineName(), $this
->randomMachineName());
}
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$path = $this->developerApp
->toUrl('revoke-api-key-form')
->setRouteParameter('consumer_key', $this->consumer_key);
$this
->drupalGet($path);
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this->stack
->queueMockResponse('no_content');
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this
->drupalPostForm(NULL, [], 'Revoke');
$this
->assertSession()
->pageTextContains('API key ' . $this->consumer_key . ' revoked from ' . $this->developerApp
->getName() . '.');
// Access denied for the only active key.
$credentials = [
[
"consumerKey" => $this->consumer_key,
"consumerSecret" => $this
->randomMachineName(),
"status" => AppCredentialInterface::STATUS_APPROVED,
],
];
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this
->drupalGet($path);
$this
->assertSession()
->pageTextContains('Access denied');
}