protected function CacheTest::credentialsTest in Apigee Edge 8
Tests that credentials are not cached, but still available if needed.
1 call to CacheTest::credentialsTest()
- CacheTest::testCache in tests/
src/ FunctionalJavascript/ CacheTest.php - Tests cache of Apigee Edge entities.
File
- tests/
src/ FunctionalJavascript/ CacheTest.php, line 125
Class
- CacheTest
- Apigee Edge entity cache related tests.
Namespace
Drupal\Tests\apigee_edge\FunctionalJavascriptCode
protected function credentialsTest() {
/** @var \Drupal\apigee_edge_test\Entity\Storage\DeveloperAppStorage $storage */
$storage = $this->container
->get('entity_type.manager')
->getStorage('developer_app');
/** @var \Drupal\apigee_edge\Entity\DeveloperApp $loadedApp */
$loadedApp = $storage
->load($this->developerApp
->id());
$this
->assertNotEmpty($loadedApp, 'Developer App loaded');
$cached_apps = $storage
->getFromCache([
$loadedApp
->id(),
]);
/** @var \Drupal\apigee_edge\Entity\AppInterface $cached_app */
$cached_app = reset($cached_apps);
// They are not in the cached SDK entity...
$this
->assertEmpty($cached_app
->decorated()
->getCredentials(), 'The credentials property is empty.');
$credentials = $loadedApp
->getCredentials();
// But they still available in the Drupal entity.
$this
->assertNotEmpty($credentials, 'The credentials property is not empty.');
// They should not be visible on the UI.
/** @var \Apigee\Edge\Api\Management\Entity\AppCredential[] $credentials */
$this
->drupalGet(Url::fromRoute('entity.developer_app.canonical_by_developer', [
'user' => $this->account
->id(),
'app' => $this->developerApp
->getName(),
]));
$this
->assertSession()
->pageTextNotContains($credentials[0]
->getConsumerKey());
$this
->assertSession()
->pageTextNotContains($credentials[0]
->getConsumerSecret());
// Until clicking the "show" buttons.
$this
->clickLink('Show key', 0);
$this
->assertSession()
->assertWaitOnAjaxRequest(30000);
$this
->clickLink('Show key', 1);
$this
->assertSession()
->assertWaitOnAjaxRequest(30000);
$this
->assertSession()
->pageTextContainsOnce($credentials[0]
->getConsumerKey());
$this
->assertSession()
->pageTextContainsOnce($credentials[0]
->getConsumerSecret());
// Hide keys.
$this
->clickLink('Hide key', 0);
$this
->assertSession()
->assertWaitOnAjaxRequest(30000);
$this
->clickLink('Hide key', 1);
$this
->assertSession()
->assertWaitOnAjaxRequest(30000);
$this
->assertSession()
->pageTextNotContains($credentials[0]
->getConsumerKey());
$this
->assertSession()
->pageTextNotContains($credentials[0]
->getConsumerSecret());
// And show again (make sure show/hide functionality works).
$this
->clickLink('Show key', 0);
$this
->assertSession()
->assertWaitOnAjaxRequest(30000);
$this
->clickLink('Show key', 1);
$this
->assertSession()
->assertWaitOnAjaxRequest(30000);
$this
->assertSession()
->pageTextContainsOnce($credentials[0]
->getConsumerKey());
$this
->assertSession()
->pageTextContainsOnce($credentials[0]
->getConsumerSecret());
}