public function DeveloperAppApiKeyTest::testAppApiKeyAddSingle in Apigee Edge 8
Tests add API key when app has only one existing key.
Throws
\Exception
File
- tests/
src/ Functional/ DeveloperAppApiKeyTest.php, line 225
Class
- DeveloperAppApiKeyTest
- Developer app API key test.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
public function testAppApiKeyAddSingle() {
$credentials = [];
if (empty($this->consumer_key)) {
$this->consumer_key = $this
->randomMachineName(32);
$credentials = [
[
// Use one api product.
"apiProducts" => [
$this->apiProducts[0],
],
"consumerKey" => $this->consumer_key,
"consumerSecret" => $this
->randomMachineName(),
"status" => AppCredentialInterface::STATUS_APPROVED,
],
];
}
else {
$credController = $this->appCredentialController
->developerAppCredentialController($this->developerApp
->getAppOwner(), $this->developerApp
->getName());
$credController
->addProducts($this->consumer_key, [
$this->apiProducts[0]
->getName(),
]);
}
$path = $this->developerApp
->toUrl('add-api-key-form');
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this
->drupalGet($path);
$this
->assertSession()
->pageTextContains('Add key');
$this
->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
$this->stack
->queueMockResponse([
'api_product' => [
'product' => $this->apiProducts[0],
],
]);
$this
->drupalPostForm(NULL, [
'expiry' => 'date',
'expiry_date' => "07/20/2030",
], 'Confirm');
$this
->assertSession()
->pageTextContains('New API key added to ' . $this->developerApp
->getName() . '.');
$this
->assertSession()
->elementContains('css', '.app-credential .api-product-list-row', 'API One');
}