You are here

protected function ApiProductAccessTest::setUp in Apigee Edge 8

Overrides ApigeeEdgeFunctionalJavascriptTestBase::setUp

1 call to ApiProductAccessTest::setUp()
ApiProductRoleBasedAccessTestBase::setUp in modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessTestBase.php
1 method overrides ApiProductAccessTest::setUp()
ApiProductRoleBasedAccessTestBase::setUp in modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessTestBase.php

File

tests/src/FunctionalJavascript/ApiProductAccessTest.php, line 99

Class

ApiProductAccessTest
Validates built-in access control on API products.

Namespace

Drupal\Tests\apigee_edge\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this->roleStorage = $this->container
    ->get('entity_type.manager')
    ->getStorage('user_role');
  $this->accessControlHandler = $this->container
    ->get('entity_type.manager')
    ->getAccessControlHandler('api_product');
  $this->users[AccountInterface::ANONYMOUS_ROLE] = User::getAnonymousUser();
  $this->users[AccountInterface::AUTHENTICATED_ROLE] = $this
    ->createAccount();

  // We granted "Administer developer apps" permission to this role as well
  // just to be able to test the UI.
  $this->users[self::USER_WITH_BYPASS_PERM] = $this
    ->createAccount([
    'bypass api product access control',
  ]);
  $this
    ->createRole([], self::INTERNAL_ROLE, self::INTERNAL_ROLE);
  $this->users[self::INTERNAL_ROLE] = $this
    ->createAccount([]);
  $this->users[self::INTERNAL_ROLE]
    ->addRole(self::INTERNAL_ROLE);
  $this->users[self::INTERNAL_ROLE]
    ->save();
  foreach (self::VISIBILITIES as $visibility) {

    /** @var \Drupal\apigee_edge\Entity\ApiProductInterface $api_product */
    $api_product = ApiProduct::create([
      'name' => $this
        ->randomMachineName(),
      'displayName' => $this
        ->randomMachineName() . " ({$visibility})",
      'approvalType' => ApiProduct::APPROVAL_TYPE_AUTO,
    ]);
    $api_product
      ->setAttribute('access', $visibility);
    $api_product
      ->save();
    $this->apiProducts[$visibility] = $api_product;
  }
  $this->ridCombinations = $this
    ->calculateRidCombinations(array_keys($this->roleStorage
    ->loadMultiple()));
}