You are here

public function DeveloperAppApiKeyTest::testAppApiKeyOperations in Apigee Edge 8

Tests app API key operations.

Throws

\Behat\Mink\Exception\ElementHtmlException

\Drupal\Core\Entity\EntityMalformedException

File

tests/src/Functional/DeveloperAppApiKeyTest.php, line 186

Class

DeveloperAppApiKeyTest
Developer app API key test.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testAppApiKeyOperations() {
  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,
      ],
      [
        "consumerKey" => $this
          ->randomMachineName(),
        "consumerSecret" => $this
          ->randomMachineName(),
        "status" => AppCredentialInterface::STATUS_REVOKED,
      ],
    ];
    $this
      ->queueDeveloperAppResponse($this->developerApp, 200, $credentials);
  }
  else {
    $credController = $this->appCredentialController
      ->developerAppCredentialController($this->developerApp
      ->getAppOwner(), $this->developerApp
      ->getName());
    $credController
      ->create($this
      ->randomMachineName(), $this
      ->randomMachineName());
    $credController
      ->create($this
      ->randomMachineName(), $this
      ->randomMachineName());
  }
  $this
    ->drupalGet($this->developerApp
    ->toUrl('canonical-by-developer'));
  $this
    ->assertSession()
    ->elementContains('css', '.app-credential:first-child .dropbutton', 'Revoke');
  $this
    ->assertSession()
    ->elementContains('css', '.app-credential:first-child .dropbutton', 'Delete');
}