public function DeveloperAppApiKeyTest::testAppApiKeyAddMultiple in Apigee Edge 8
Tests add API key when app has multiple keys.
Throws
\Exception
File
- tests/
src/ Functional/ DeveloperAppApiKeyTest.php, line 271
Class
- DeveloperAppApiKeyTest
- Developer app API key test.
Namespace
Drupal\Tests\apigee_edge\FunctionalCode
public function testAppApiKeyAddMultiple() {
// Start with two credentials with different issuedAt dates and different products.
$credentials = [];
if (empty($this->consumer_key)) {
$this->consumer_key = $this
->randomMachineName(32);
$credentials = [
[
"apiProducts" => [
$this->apiProducts[0],
],
"consumerKey" => $this->consumer_key,
"consumerSecret" => $this
->randomMachineName(),
"status" => AppCredentialInterface::STATUS_APPROVED,
"issuedAt" => 1594973277149,
],
[
"apiProducts" => [
$this->apiProducts[1],
],
"consumerKey" => $this
->randomMachineName(32),
"consumerSecret" => $this
->randomMachineName(),
"status" => AppCredentialInterface::STATUS_APPROVED,
"issuedAt" => 1594973277300,
],
];
}
else {
$credController = $this->appCredentialController
->developerAppCredentialController($this->developerApp
->getAppOwner(), $this->developerApp
->getName());
$credController
->addProducts($this->consumer_key, [
$this->apiProducts[0]
->getName(),
]);
$credController
->generate([
$this->apiProducts[1]
->getName(),
], $this->developerApp
->getAttributes(), '');
}
$this
->queueDeveloperAppResponse($this->developerApp);
$path = $this->developerApp
->toUrl('add-api-key-form');
$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->stack
->queueMockResponse([
'api_product' => [
'product' => $this->apiProducts[1],
],
]);
$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:last-child .api-product-list-row', 'API Two');
}