From 4d1ee5dc7f8442a35e762b5a1e6f9adb22e5df9b Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Wed, 4 Mar 2020 14:44:04 -0800 Subject: [PATCH 01/10] [#341] Enable kernel and unit tests in circleCI. --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d4b5044f3..d939e0bd9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -197,9 +197,9 @@ workflows: test_and_lint: jobs: - update-dependencies -# - run-unit-kernel-tests: -# requires: -# - update-dependencies + - run-unit-kernel-tests: + requires: + - update-dependencies # - run-functional-tests: # requires: # - update-dependencies From 4ff2f903c2a3ae90ce9959b0fbe97bc15e499d56 Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Wed, 4 Mar 2020 14:52:51 -0800 Subject: [PATCH 02/10] [#341] Fix EdgeExceptionSubscriberTest. --- .../EdgeExceptionSubscriberTest.php | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/tests/src/Unit/EventSubscriber/EdgeExceptionSubscriberTest.php b/tests/src/Unit/EventSubscriber/EdgeExceptionSubscriberTest.php index e10e23135..5c00f0bd3 100644 --- a/tests/src/Unit/EventSubscriber/EdgeExceptionSubscriberTest.php +++ b/tests/src/Unit/EventSubscriber/EdgeExceptionSubscriberTest.php @@ -28,8 +28,8 @@ use Drupal\Core\Config\Config; use Prophecy\Argument; use Psr\Log\LoggerInterface; -use stdClass; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\Routing\Matcher\UrlMatcherInterface; @@ -107,32 +107,26 @@ protected function setUp() { $this->exception = new ApiException("API response error message."); $this->httpKernel = $this->prophesize(HttpKernelInterface::class); + $this->httpKernel->handle(Argument::any(), Argument::any())->willReturn(new Response()); $this->logger = $this->prophesize(LoggerInterface::class); $this->redirectDestination = $this->prophesize(RedirectDestinationInterface::class); + $this->redirectDestination->getAsArray()->willReturn([]); $request = $this->prophesize(RequestContext::class); $this->accessUnawareRouter = $this->prophesize(UrlMatcherInterface::class); $this->accessUnawareRouter->getContext(Argument::any())->willReturn($request->reveal()); + $this->accessUnawareRouter->setContext(Argument::any())->willReturn(); + $this->accessUnawareRouter->match(Argument::any())->willReturn([]); $this->messenger = $this->prophesize(MessengerInterface::class); - $request = $this->prophesize(Request::class); - - // Set empty objects so that clone on request object works. - $request->query = new stdClass(); - $request->request = new stdClass(); - $request->attributes = new stdClass(); - $request->cookies = new stdClass(); - $request->files = new stdClass(); - $request->server = new stdClass(); - $request->headers = new stdClass(); - $this->getResponseForExceptionEvent = $this->prophesize(GetResponseForExceptionEvent::class); $this->getResponseForExceptionEvent->getRequest() - ->willReturn($request->reveal()); + ->willReturn(new Request()); $this->getResponseForExceptionEvent->getException() ->willReturn($this->exception); - + $this->getResponseForExceptionEvent->setResponse(Argument::any()) + ->willReturn(); } /** From 92e9b300eb27537e2b54cfbed30624d939733c00 Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Wed, 4 Mar 2020 15:00:39 -0800 Subject: [PATCH 03/10] [#341] Enable functional tests in circleCI. --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d939e0bd9..25cf82973 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -200,9 +200,9 @@ workflows: - run-unit-kernel-tests: requires: - update-dependencies -# - run-functional-tests: -# requires: -# - update-dependencies + - run-functional-tests: + requires: + - update-dependencies # - run-functional-js-tests: # requires: # - update-dependencies From 45c7ac9ccd0b3d3408f07c98f050536869cf3344 Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Wed, 4 Mar 2020 22:40:22 -0800 Subject: [PATCH 04/10] [#341] Enable functional JS tests in circleCI. --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 25cf82973..9d675a914 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -203,9 +203,9 @@ workflows: - run-functional-tests: requires: - update-dependencies -# - run-functional-js-tests: -# requires: -# - update-dependencies + - run-functional-js-tests: + requires: + - update-dependencies - run-code-sniffer: requires: - update-dependencies From 91709229fcfac823e1bf7953e57f754facfe340c Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Tue, 10 Mar 2020 15:14:27 -0700 Subject: [PATCH 05/10] [#341] Use config storage for the key in functional tests. --- .../Traits/ApigeeEdgeFunctionalTestTrait.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php b/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php index 91b2de5d4..2a7ba0c8e 100644 --- a/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php +++ b/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php @@ -65,15 +65,28 @@ protected function initTestEnv(): void { } /** - * Creates a test key by using environment variables as key storage. + * Creates a test key from environment variables, using config key storage. + * + * Using config storage , as opposed to environment vars, has the advantage + * of the key values persisting in subsequent page requests. */ protected function createTestKey(): void { + $environment_variables = []; + $definition = \Drupal::service('plugin.manager.key.key_type')->getDefinition('apigee_auth'); + foreach ($definition['multivalue']['fields'] as $id => $field) { + $env_var_name = 'APIGEE_EDGE_' . strtoupper($id); + if (getenv($env_var_name)) { + $environment_variables[$id] = getenv($env_var_name); + } + } + $key = Key::create([ 'id' => 'test', 'label' => 'test', 'key_type' => 'apigee_auth', - 'key_provider' => 'apigee_edge_environment_variables', + 'key_provider' => 'config', 'key_input' => 'none', + 'key_provider_settings' => ['key_value' => json_encode($environment_variables)], ]); try { $key->save(); From c29f78bf36011d67e2f632562e6e24daa2ac9cd2 Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Tue, 10 Mar 2020 15:36:17 -0700 Subject: [PATCH 06/10] [#341] Use the same config storage for tests using mocks. --- .../apigee_mock_api_client.module | 35 -------- .../TestEnvironmentVariablesKeyProvider.php | 81 ------------------- .../Traits/ApigeeMockApiClientHelperTrait.php | 35 +------- .../Traits/ApigeeEdgeFunctionalTestTrait.php | 2 +- 4 files changed, 3 insertions(+), 150 deletions(-) delete mode 100644 tests/modules/apigee_mock_api_client/apigee_mock_api_client.module delete mode 100644 tests/modules/apigee_mock_api_client/src/Plugin/KeyProvider/TestEnvironmentVariablesKeyProvider.php diff --git a/tests/modules/apigee_mock_api_client/apigee_mock_api_client.module b/tests/modules/apigee_mock_api_client/apigee_mock_api_client.module deleted file mode 100644 index effe80348..000000000 --- a/tests/modules/apigee_mock_api_client/apigee_mock_api_client.module +++ /dev/null @@ -1,35 +0,0 @@ -state = $state; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $container->get('logger.channel.apigee_edge'), - $container->get('state') - ); - } - - /** - * {@inheritdoc} - */ - public function checkRequirements(KeyInterface $key): void { - // If the key_value is empty during a request callback get credentials from - // state. - $values = $this->state->get(static::KEY_VALUE_STATE_ID); - - foreach ($values as $env_name => $value) { - if (!getenv($env_name)) { - putenv("{$env_name}={$value}"); - } - } - - parent::checkRequirements($key); - } - -} diff --git a/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php b/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php index 9933744cf..2ba0bbc2b 100644 --- a/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php +++ b/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php @@ -69,13 +69,6 @@ trait ApigeeMockApiClientHelperTrait { */ protected $integration_enabled; - /** - * The Apigee Edge key used in tests. - * - * @var string - */ - protected $apigee_edge_test_key = 'apigee_edge_test_auth'; - /** * Setup. */ @@ -101,32 +94,8 @@ protected function apigeeTestPropertiesSetup() { * @throws \Drupal\Core\Entity\EntityStorageException */ protected function initAuth() { - - // Create new Apigee Edge basic auth key. - $key = Key::create([ - 'id' => $this->apigee_edge_test_key, - 'label' => 'Apigee Test Authorization', - 'key_type' => 'apigee_auth', - 'key_provider' => 'apigee_edge_environment_variables', - 'key_input' => 'apigee_auth_input', - ]); - - $key->save(); - - // Collect credentials from environment variables. - $fields = []; - foreach (array_keys($key->getKeyType()->getPluginDefinition()['multivalue']['fields']) as $field) { - $id = 'APIGEE_EDGE_' . strtoupper($field); - if ($value = getenv($id)) { - $fields[$id] = $value; - } - } - // Make sure the credentials persists for functional tests. - \Drupal::state()->set(TestEnvironmentVariablesKeyProvider::KEY_VALUE_STATE_ID, $fields); - - $this->config('apigee_edge.auth') - ->set('active_key', $this->apigee_edge_test_key) - ->save(); + $this->createTestKey(); + $this->restoreKey(); } /** diff --git a/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php b/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php index 2a7ba0c8e..7f13d349b 100644 --- a/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php +++ b/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php @@ -100,7 +100,7 @@ protected function createTestKey(): void { * Restores the active key. */ protected function restoreKey() { - $test_key_id = static::$mock_api_client_ready ? $this->apigee_edge_test_key : 'test'; + $test_key_id = 'test'; $this->config('apigee_edge.auth') ->set('active_key', $test_key_id) ->save(); From 61fd0d32e7aa933c64c277a541f44175cf4677f8 Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Tue, 10 Mar 2020 16:05:17 -0700 Subject: [PATCH 07/10] [#341] Use the same config storage for tests using mocks - ammended. --- .../Traits/ApigeeMockApiClientHelperTrait.php | 5 +- .../Traits/ApigeeEdgeFunctionalTestTrait.php | 65 ------------- tests/src/Traits/ApigeeEdgeUtilTestTrait.php | 93 +++++++++++++++++++ 3 files changed, 96 insertions(+), 67 deletions(-) create mode 100644 tests/src/Traits/ApigeeEdgeUtilTestTrait.php diff --git a/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php b/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php index 2ba0bbc2b..2b86eadcb 100644 --- a/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php +++ b/tests/modules/apigee_mock_api_client/tests/src/Traits/ApigeeMockApiClientHelperTrait.php @@ -24,8 +24,7 @@ use Apigee\MockClient\Generator\ApigeeSdkEntitySource; use Drupal\apigee_edge\Entity\Developer; use Drupal\apigee_edge\Entity\DeveloperInterface; -use Drupal\apigee_mock_api_client\Plugin\KeyProvider\TestEnvironmentVariablesKeyProvider; -use Drupal\key\Entity\Key; +use Drupal\Tests\apigee_edge\Traits\ApigeeEdgeUtilTestTrait; use Drupal\user\UserInterface; use Http\Message\RequestMatcher\RequestMatcher; @@ -34,6 +33,8 @@ */ trait ApigeeMockApiClientHelperTrait { + use ApigeeEdgeUtilTestTrait; + /** * The SDK connector service. * diff --git a/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php b/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php index 7f13d349b..7da4b7b33 100644 --- a/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php +++ b/tests/src/Traits/ApigeeEdgeFunctionalTestTrait.php @@ -23,8 +23,6 @@ use Drupal\apigee_edge\Entity\ApiProduct; use Drupal\apigee_edge\Entity\Developer; use Drupal\apigee_edge\Entity\DeveloperApp; -use Drupal\Core\Entity\EntityStorageException; -use Drupal\key\Entity\Key; use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait; use Drupal\user\Entity\User; use Drupal\user\UserInterface; @@ -64,69 +62,6 @@ protected function initTestEnv(): void { } } - /** - * Creates a test key from environment variables, using config key storage. - * - * Using config storage , as opposed to environment vars, has the advantage - * of the key values persisting in subsequent page requests. - */ - protected function createTestKey(): void { - $environment_variables = []; - $definition = \Drupal::service('plugin.manager.key.key_type')->getDefinition('apigee_auth'); - foreach ($definition['multivalue']['fields'] as $id => $field) { - $env_var_name = 'APIGEE_EDGE_' . strtoupper($id); - if (getenv($env_var_name)) { - $environment_variables[$id] = getenv($env_var_name); - } - } - - $key = Key::create([ - 'id' => 'test', - 'label' => 'test', - 'key_type' => 'apigee_auth', - 'key_provider' => 'config', - 'key_input' => 'none', - 'key_provider_settings' => ['key_value' => json_encode($environment_variables)], - ]); - try { - $key->save(); - } - catch (EntityStorageException $exception) { - $this->fail('Could not create key for testing.'); - } - } - - /** - * Restores the active key. - */ - protected function restoreKey() { - $test_key_id = 'test'; - $this->config('apigee_edge.auth') - ->set('active_key', $test_key_id) - ->save(); - } - - /** - * Removes the active key for testing with unset API credentials. - */ - protected function invalidateKey() { - $this->config('apigee_edge.auth') - ->set('active_key', '') - ->save(); - } - - /** - * Set active authentication keys in config. - * - * @param string $active_key - * The active authentication key. - */ - protected function setKey(string $active_key) { - $this->config('apigee_edge.auth') - ->set('active_key', $active_key) - ->save(); - } - /** * The corresponding developer will be created if a Drupal user is saved. */ diff --git a/tests/src/Traits/ApigeeEdgeUtilTestTrait.php b/tests/src/Traits/ApigeeEdgeUtilTestTrait.php new file mode 100644 index 000000000..e6dab08e8 --- /dev/null +++ b/tests/src/Traits/ApigeeEdgeUtilTestTrait.php @@ -0,0 +1,93 @@ +getDefinition('apigee_auth'); + foreach ($definition['multivalue']['fields'] as $id => $field) { + $env_var_name = 'APIGEE_EDGE_' . strtoupper($id); + if (getenv($env_var_name)) { + $environment_variables[$id] = getenv($env_var_name); + } + } + + $key = Key::create([ + 'id' => 'test', + 'label' => 'test', + 'key_type' => 'apigee_auth', + 'key_provider' => 'config', + 'key_input' => 'none', + 'key_provider_settings' => ['key_value' => json_encode($environment_variables)], + ]); + try { + $key->save(); + } + catch (EntityStorageException $exception) { + $this->fail('Could not create key for testing.'); + } + } + + /** + * Restores the active key. + */ + protected function restoreKey() { + $test_key_id = 'test'; + $this->config('apigee_edge.auth') + ->set('active_key', $test_key_id) + ->save(); + } + + /** + * Removes the active key for testing with unset API credentials. + */ + protected function invalidateKey() { + $this->config('apigee_edge.auth') + ->set('active_key', '') + ->save(); + } + + /** + * Set active authentication keys in config. + * + * @param string $active_key + * The active authentication key. + */ + protected function setKey(string $active_key) { + $this->config('apigee_edge.auth') + ->set('active_key', $active_key) + ->save(); + } + +} From ba65de8bf4c4ed4e5d28be37e38d59d7a47d1735 Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Wed, 11 Mar 2020 00:25:44 -0700 Subject: [PATCH 08/10] [#341] Fixing AuthenticationFormJsTest --- .../Form/AuthenticationFormJsTest.php | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php b/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php index 15dc6a27f..0bf807651 100644 --- a/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php +++ b/tests/src/FunctionalJavascript/Form/AuthenticationFormJsTest.php @@ -112,15 +112,19 @@ public function testAuthenticationForm() { $web_assert = $this->assertSession(); - // Test the authentication form using the default key stored by environment - // variable key provider. + // Test the authentication form. $this->drupalLogin($this->rootUser); $this->drupalGet(Url::fromRoute('apigee_edge.settings')); - $this->assertSession()->pageTextContains("The selected key provider does not accept a value. See the provider's description for instructions on how and where to store the key value."); - $this->assertSession()->pageTextContains('Send request using the active authentication key.'); + + $this->assertSession()->pageTextContains('Send request using the given API credentials.'); $this->assertSendRequestMessage('.messages--status', 'Connection successful.'); $web_assert->elementNotExists('css', 'details[data-drupal-selector="edit-debug"]'); + $page = $this->getSession()->getPage(); + $page->find('css', 'details[data-drupal-selector="edit-provider-section"] > summary')->click(); + $page->selectFieldOption('key_provider', 'apigee_edge_environment_variables'); + $this->assertSession()->waitForText("The selected key provider does not accept a value. See the provider's description for instructions on how and where to store the key value."); + $this->validateForm([$this, 'visitAuthenticationForm']); // Validate that the form actually saved the valid credentials (DRUP-734). @@ -370,17 +374,20 @@ protected function validateForm(callable $visitFormAsAdmin): void { $page->selectFieldOption('key_input_settings[instance_type]', EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC); // Test another invalid endpoint scenario: - // This endpoint is not a Management API endpoint, but still returns + // Some endpoints are not a Management API endpoint, but still return // HTTP 200 with a JSON response. - $invalid_endpoint = 'enterprise.apigee.com/platform/orgname'; - $page->selectFieldOption('key_input_settings[instance_type]', EdgeKeyTypeInterface::INSTANCE_TYPE_PRIVATE); - $page->fillField('Apigee Edge endpoint', "https://{$invalid_endpoint}/"); - $this->assertSendRequestMessage('.messages--error', "Failed to connect to Apigee Edge. The given endpoint (https://{$invalid_endpoint}/) is incorrect or something is wrong with the connection. Error message: "); - $invalid_endpoint_escaped = str_replace('/', '\/', $invalid_endpoint); - $web_assert->elementContains('css', 'textarea[data-drupal-selector="edit-debug-text"]', "\"endpoint\": \"https:\/\/{$invalid_endpoint_escaped}\/\""); - $web_assert->fieldValueEquals('Apigee Edge endpoint', "https://{$invalid_endpoint}/"); - $page->fillField('Apigee Edge endpoint', ''); - $page->selectFieldOption('key_input_settings[instance_type]', EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC); + // Only test with mock client. + if (static::$mock_api_client_ready && !$this->integration_enabled) { + $invalid_endpoint = 'enterprise.apigee.com/platform/orgname'; + $page->selectFieldOption('key_input_settings[instance_type]', EdgeKeyTypeInterface::INSTANCE_TYPE_PRIVATE); + $page->fillField('Apigee Edge endpoint', "https://{$invalid_endpoint}/"); + $this->assertSendRequestMessage('.messages--error', "Failed to connect to Apigee Edge. The given endpoint (https://{$invalid_endpoint}/) is incorrect or something is wrong with the connection. Error message: "); + $invalid_endpoint_escaped = str_replace('/', '\/', $invalid_endpoint); + $web_assert->elementContains('css', 'textarea[data-drupal-selector="edit-debug-text"]', "\"endpoint\": \"https:\/\/{$invalid_endpoint_escaped}\/\""); + $web_assert->fieldValueEquals('Apigee Edge endpoint', "https://{$invalid_endpoint}/"); + $page->fillField('Apigee Edge endpoint', ''); + $page->selectFieldOption('key_input_settings[instance_type]', EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC); + } // Test invalid authorization server. $this->cssSelect('select[data-drupal-selector="edit-key-input-settings-auth-type"]')[0]->setValue('oauth'); From c494a4bef63fd461205f817648c23c22e4b740fe Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Wed, 11 Mar 2020 13:24:52 -0700 Subject: [PATCH 09/10] [#341] Fixing composer dependencies, running functional JS after functional. --- .circleci/RoboFile.php | 6 ++---- .circleci/config.yml | 4 +++- composer.json | 3 --- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.circleci/RoboFile.php b/.circleci/RoboFile.php index 9adc0c6bc..68ccf7313 100644 --- a/.circleci/RoboFile.php +++ b/.circleci/RoboFile.php @@ -45,7 +45,6 @@ public function setupSkeleton() // composer config doesn't allow us to set arrays, so we have to do this by // hand. $config = json_decode(file_get_contents('composer.json')); - $config->require->{"drush/drush"} = "~9.0"; $config->extra->{"enable-patching"} = 'true'; $config->extra->{"patches"} = new \stdClass(); file_put_contents('composer.json', json_encode($config)); @@ -81,9 +80,8 @@ public function addCodingStandardsDeps() public function addBehatDeps() { $config = json_decode(file_get_contents('composer.json')); - $config->require->{"behat/mink-selenium2-driver"} = "^1.3"; + // Package behat/mink-selenium2-driver is included in drupal/core-dev. $config->require->{"drupal/drupal-extension"} = "master-dev"; - $config->require->{"drush/drush"} = "~9.0"; $config->require->{"guzzlehttp/guzzle"} = "^6.0@dev"; file_put_contents('composer.json', json_encode($config)); } @@ -410,7 +408,7 @@ public function configureModuleDependencies() $config = json_decode(file_get_contents('composer.json')); // The Drupal core image might need updating. Request the newest stable. - $config->require->{"drupal/core"} = "~8.8"; + unset($config->require->{"drupal/core"}); $config->require->{"drupal/core-recommended"} = "~8.8"; // We require Drupal console and drush for some tests. diff --git a/.circleci/config.yml b/.circleci/config.yml index 9d675a914..d64f9223a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -193,7 +193,8 @@ jobs: workflows: version: 2 - # Declare a workflow that runs all of our jobs in parallel. + # Declare a workflow that runs jobs in parallel. + # Functional JS tests need to run after functional due to a conflict in apigee_edge_apiproduct_rbac tests. test_and_lint: jobs: - update-dependencies @@ -206,6 +207,7 @@ workflows: - run-functional-js-tests: requires: - update-dependencies + - run-functional-tests - run-code-sniffer: requires: - update-dependencies diff --git a/composer.json b/composer.json index db55ea850..3ccd495cf 100644 --- a/composer.json +++ b/composer.json @@ -14,12 +14,9 @@ }, "require-dev": { "apigee/apigee-mock-client-php": "^1.0", - "behat/mink" : "dev-master#9ea1cebe", "behat/mink-extension": "v2.2", - "behat/mink-selenium2-driver": "1.3.x-dev", "bex/behat-screenshot": "^1.2", "cweagans/composer-patches": "^1.6", - "drupal/coder": "^8.3", "drupal/core-dev": "^8.7", "drupal/drupal-extension": "master-dev", "drush/drush": "^9.0", From e7fc6b9a075c3870a9c6634fafebd5a55dc60cbe Mon Sep 17 00:00:00 2001 From: Arlina Espinoza Date: Thu, 12 Mar 2020 13:39:31 -0700 Subject: [PATCH 10/10] [#341] Fixing apigee_edge_apiproduct_rbac tests. --- .circleci/config.yml | 1 - .../ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php | 6 +++--- .../ApiProductRoleBasedAccessAnonymousInternalTest.php | 6 +++--- .../ApiProductRoleBasedAccessAuthenticatedInternalTest.php | 2 +- .../ApiProductRoleBasedAccessMissingAttributeTest.php | 6 +++--- .../ApiProductRoleBasedAccessTestBase.php | 4 ++-- .../tests/src/Functional/TeamApiProductAccessTest.php | 2 +- .../ApiProductAccessTest.php | 4 ++-- 8 files changed, 15 insertions(+), 16 deletions(-) rename modules/apigee_edge_apiproduct_rbac/tests/src/{Functional => FunctionalJavascript}/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php (88%) rename modules/apigee_edge_apiproduct_rbac/tests/src/{Functional => FunctionalJavascript}/ApiProductRoleBasedAccessAnonymousInternalTest.php (88%) rename modules/apigee_edge_apiproduct_rbac/tests/src/{Functional => FunctionalJavascript}/ApiProductRoleBasedAccessAuthenticatedInternalTest.php (94%) rename modules/apigee_edge_apiproduct_rbac/tests/src/{Functional => FunctionalJavascript}/ApiProductRoleBasedAccessMissingAttributeTest.php (95%) rename modules/apigee_edge_apiproduct_rbac/tests/src/{Functional => FunctionalJavascript}/ApiProductRoleBasedAccessTestBase.php (96%) rename tests/src/{Functional => FunctionalJavascript}/ApiProductAccessTest.php (99%) diff --git a/.circleci/config.yml b/.circleci/config.yml index d64f9223a..6d63a78f2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -207,7 +207,6 @@ workflows: - run-functional-js-tests: requires: - update-dependencies - - run-functional-tests - run-code-sniffer: requires: - update-dependencies diff --git a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php similarity index 88% rename from modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php rename to modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php index c24f260f7..941397bc3 100644 --- a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php +++ b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAnonymousAuthenticatedTest.php @@ -18,7 +18,7 @@ * MA 02110-1301, USA. */ -namespace Drupal\Tests\apigee_edge_apiproduct_rbac\Functional; +namespace Drupal\Tests\apigee_edge_apiproduct_rbac\FunctionalJavascript; use Drupal\Core\Session\AccountInterface; @@ -46,8 +46,8 @@ protected function setUp() { /** * {@inheritdoc} * - * \Drupal\Tests\apigee_edge\Functional\ApiProductAccessTest validates - * developerAppEditFormTest(). + * \Drupal\Tests\apigee_edge\FunctionalJavascript\ApiProductAccessTest + * validates developerAppEditFormTest(). */ public function testApiProductAccess() { $this->entityAccessTest(); diff --git a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAnonymousInternalTest.php b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAnonymousInternalTest.php similarity index 88% rename from modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAnonymousInternalTest.php rename to modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAnonymousInternalTest.php index fe84e2b87..045bcc839 100644 --- a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAnonymousInternalTest.php +++ b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAnonymousInternalTest.php @@ -18,7 +18,7 @@ * MA 02110-1301, USA. */ -namespace Drupal\Tests\apigee_edge_apiproduct_rbac\Functional; +namespace Drupal\Tests\apigee_edge_apiproduct_rbac\FunctionalJavascript; use Drupal\Core\Session\AccountInterface; @@ -46,8 +46,8 @@ protected function setUp() { /** * {@inheritdoc} * - * \Drupal\Tests\apigee_edge\Functional\ApiProductAccessTest validates - * developerAppEditFormTest(). + * \Drupal\Tests\apigee_edge\FunctionalJavascript\ApiProductAccessTest + * validates developerAppEditFormTest(). */ public function testApiProductAccess() { $this->entityAccessTest(); diff --git a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAuthenticatedInternalTest.php b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAuthenticatedInternalTest.php similarity index 94% rename from modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAuthenticatedInternalTest.php rename to modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAuthenticatedInternalTest.php index 4b6f1d8d5..2e19f810c 100644 --- a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessAuthenticatedInternalTest.php +++ b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessAuthenticatedInternalTest.php @@ -18,7 +18,7 @@ * MA 02110-1301, USA. */ -namespace Drupal\Tests\apigee_edge_apiproduct_rbac\Functional; +namespace Drupal\Tests\apigee_edge_apiproduct_rbac\FunctionalJavascript; use Drupal\Core\Session\AccountInterface; diff --git a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessMissingAttributeTest.php b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessMissingAttributeTest.php similarity index 95% rename from modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessMissingAttributeTest.php rename to modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessMissingAttributeTest.php index 68ca9c848..b4f81b009 100644 --- a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessMissingAttributeTest.php +++ b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessMissingAttributeTest.php @@ -18,7 +18,7 @@ * MA 02110-1301, USA. */ -namespace Drupal\Tests\apigee_edge_apiproduct_rbac\Functional; +namespace Drupal\Tests\apigee_edge_apiproduct_rbac\FunctionalJavascript; use Drupal\Core\Session\AccountInterface; @@ -39,8 +39,8 @@ class ApiProductRoleBasedAccessMissingAttributeTest extends ApiProductRoleBasedA /** * {@inheritdoc} * - * \Drupal\Tests\apigee_edge\Functional\ApiProductAccessTest validates - * developerAppEditFormTest(). + * \Drupal\Tests\apigee_edge\FunctionalJavascript\ApiProductAccessTest + * validates developerAppEditFormTest(). */ public function testApiProductAccess() { $this->entityAccessTest(); diff --git a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessTestBase.php b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessTestBase.php similarity index 96% rename from modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessTestBase.php rename to modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessTestBase.php index 98d063946..0f4c7e885 100644 --- a/modules/apigee_edge_apiproduct_rbac/tests/src/Functional/ApiProductRoleBasedAccessTestBase.php +++ b/modules/apigee_edge_apiproduct_rbac/tests/src/FunctionalJavascript/ApiProductRoleBasedAccessTestBase.php @@ -18,11 +18,11 @@ * MA 02110-1301, USA. */ -namespace Drupal\Tests\apigee_edge_apiproduct_rbac\Functional; +namespace Drupal\Tests\apigee_edge_apiproduct_rbac\FunctionalJavascript; use Drupal\apigee_edge\Entity\ApiProductInterface; use Drupal\Core\Url; -use Drupal\Tests\apigee_edge\Functional\ApiProductAccessTest; +use Drupal\Tests\apigee_edge\FunctionalJavascript\ApiProductAccessTest; use Drupal\user\UserInterface; /** diff --git a/modules/apigee_edge_teams/tests/src/Functional/TeamApiProductAccessTest.php b/modules/apigee_edge_teams/tests/src/Functional/TeamApiProductAccessTest.php index 485b41f27..79eb1c9f0 100644 --- a/modules/apigee_edge_teams/tests/src/Functional/TeamApiProductAccessTest.php +++ b/modules/apigee_edge_teams/tests/src/Functional/TeamApiProductAccessTest.php @@ -261,7 +261,7 @@ public function testTeamApiProductAccess() { // we do not need to validate the developer app/edit forms because those // are covered by the parent module's ApiProductAccessTest which ensures // the API product list is filtered properly there. - // \Drupal\Tests\apigee_edge\Functional\ApiProductAccessTest. + // \Drupal\Tests\apigee_edge\FunctionalJavascript\ApiProductAccessTest. $this->drupalLogout(); // <<< Team member. // If team member gets removed from the team its API Product access diff --git a/tests/src/Functional/ApiProductAccessTest.php b/tests/src/FunctionalJavascript/ApiProductAccessTest.php similarity index 99% rename from tests/src/Functional/ApiProductAccessTest.php rename to tests/src/FunctionalJavascript/ApiProductAccessTest.php index 8f0f1d392..b764dfc98 100644 --- a/tests/src/Functional/ApiProductAccessTest.php +++ b/tests/src/FunctionalJavascript/ApiProductAccessTest.php @@ -18,7 +18,7 @@ * MA 02110-1301, USA. */ -namespace Drupal\Tests\apigee_edge\Functional; +namespace Drupal\Tests\apigee_edge\FunctionalJavascript; use Apigee\Edge\Api\Management\Entity\App; use Drupal\apigee_edge\Entity\ApiProduct; @@ -37,7 +37,7 @@ * @group apigee_edge_api_product * @group apigee_edge_api_product_access */ -class ApiProductAccessTest extends ApigeeEdgeFunctionalTestBase { +class ApiProductAccessTest extends ApigeeEdgeFunctionalJavascriptTestBase { protected const USER_WITH_BYPASS_PERM = 'user_with_bypass_perm'; protected const INTERNAL_ROLE = 'internal';