public function DeveloperAppApiKeyTest::testAppApiKeyDelete in Apigee Edge 8
Test app API key delete action.
Throws
\Behat\Mink\Exception\ResponseTextException
\Drupal\Core\Entity\EntityMalformedException
File
- tests/
src/ Functional/ DeveloperAppApiKeyTest.php, line 384
Class
- DeveloperAppApiKeyTest
- Developer app API key test.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
public function testAppApiKeyDelete() {
$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('delete-api-key-form')
->setRouteParameter('consumer_key', $this->consumer_key);
$this
->drupalGet($path);
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
unset($credentials[0]);
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this->stack
->queueMockResponse('no_content');
$this
->drupalPostForm(NULL, [], 'Delete');
$this
->assertSession()
->pageTextContains('API key ' . $this->consumer_key . ' deleted 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');
}