Skip to content

Commit

Permalink
Merge branch '2.x' into align2x
Browse files Browse the repository at this point in the history
  • Loading branch information
kedarkhaire authored Dec 5, 2023
2 parents 82a0161 + d319a51 commit 078eee9
Show file tree
Hide file tree
Showing 25 changed files with 1,189 additions and 22 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ env:
APIGEE_EDGE_INSTANCE_TYPE: ${{ secrets.APIGEE_EDGE_INSTANCE_TYPE }}
APIGEE_INTEGRATION_ENABLE: ${{ secrets.APIGEE_INTEGRATION_ENABLE }}
APIGEE_EDGE_ENDPOINT: ${{ secrets.APIGEE_EDGE_ENDPOINT }}
APIGEE_EDGE_ACCOUNT_JSON_KEY: ${{ secrets.APIGEE_EDGE_ACCOUNT_JSON_KEY }}
APIGEE_EDGE_HYBRID_ENDPOINT: ${{ secrets.APIGEE_EDGE_HYBRID_ENDPOINT }}
APIGEE_EDGE_HYBRID_ORGANIZATION: ${{ secrets.APIGEE_EDGE_HYBRID_ORGANIZATION }}
BROWSERTEST_OUTPUT_DIRECTORY: "sites/simpletest/browser_output"
BROWSERTEST_OUTPUT_BASE_URL: ""
MINK_DRIVER_ARGS_WEBDRIVER: '["chrome", { "chromeOptions": { "w3c": false } }, "http://127.0.0.1:9515/wd/hub"]'
Expand All @@ -24,7 +27,7 @@ jobs:

runs-on: ubuntu-latest

name: "PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal-core }}"
name: "PHP ${{ matrix.php-version }} | Drupal ${{ matrix.drupal-core }} | ${{ matrix.instance-type }}"
strategy:
fail-fast: false
matrix:
Expand All @@ -34,6 +37,9 @@ jobs:
drupal-core:
# Should update the following as the minimum supported version from Drupal.org
- "9.5.x"
instance-type:
- "Edge"
- "X"

steps:

Expand Down Expand Up @@ -107,11 +113,17 @@ jobs:
vendor/bin/drush en apigee_edge -y
vendor/bin/drush rs 8000 &
- name: "PHPCS"
- name: "PHPCS and setting up Apigee X environment"
if: ${{ matrix.instance-type == 'X' }}
run: |
cd drupal
cp modules/contrib/apigee_edge/phpcs.xml.dist .
vendor/bin/phpcs --standard=./phpcs.xml.dist modules/contrib/apigee_edge -p -s -n --colors
# Setting environment variables to run Apigee X tests
echo "APIGEE_EDGE_INSTANCE_TYPE=hybrid" >> $GITHUB_ENV
echo "APIGEE_EDGE_ORGANIZATION=$APIGEE_EDGE_HYBRID_ORGANIZATION" >> $GITHUB_ENV
echo "APIGEE_EDGE_ENDPOINT=$APIGEE_EDGE_HYBRID_ENDPOINT" >> $GITHUB_ENV
composer show > composer-show.txt
- name: "Drupal check"
run: |
Expand All @@ -136,20 +148,20 @@ jobs:
run: |
cd drupal
cp modules/contrib/apigee_edge/phpunit.core.xml.dist core/phpunit.xml
vendor/bin/phpunit -c core --verbose --color --group apigee_edge --testsuite unit,kernel,functional,functional-javascript --debug --coverage-clover /tmp/coverage.xml modules/contrib/apigee_edge
vendor/bin/phpunit -c core --verbose --color --group apigee_edge --testsuite unit,kernel,functional,functional-javascript --debug --coverage-clover /tmp/coverage_${{ matrix.instance-type }}.xml modules/contrib/apigee_edge
- name: Artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: browser-output-${{ matrix.php-version }}-${{ matrix.drupal-core }}-artifact
name: browser-output-${{ matrix.php-version }}-${{ matrix.drupal-core }}-${{ matrix.instance-type }}-artifact
path: drupal/sites/simpletest/browser_output/*

- name: Upload coverage to Codecov
if: ${{ matrix.drupal-core == '9.5.x' && matrix.php-version == '8.1' }}
uses: codecov/codecov-action@v3
with:
files: /tmp/coverage.xml
files: /tmp/coverage_${{ matrix.instance-type }}.xml
name: codecov-umbrella
fail_ci_if_error: true
verbose: true
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

namespace Drupal\Tests\apigee_edge_actions\Kernel;

use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\Core\Database\Database;
use Drupal\dblog\Controller\DbLogController;
use Drupal\Tests\apigee_mock_api_client\Traits\ApigeeMockApiClientHelperTrait;
Expand Down Expand Up @@ -67,6 +68,11 @@ class ApigeeEdgeActionsRulesKernelTestBase extends RulesKernelTestBase {
* {@inheritdoc}
*/
protected function setUp(): void {
// Skipping the test if instance type is Public.
$instance_type = getenv('APIGEE_EDGE_INSTANCE_TYPE');
if (!empty($instance_type) && $instance_type === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
$this->markTestSkipped('This test suite is expecting a PUBLIC instance type.');
}
parent::setUp();

$this->storage = $this->container->get('entity_type.manager')->getStorage('rules_reaction_rule');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

/**
* Copyright 2023 Google Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

namespace Drupal\Tests\apigee_edge_teams\Functional\ApigeeX;

use Drupal\apigee_edge\OauthTokenFileStorage;
use Drupal\Tests\apigee_edge\Functional\ApigeeX\ApigeeEdgeFunctionalTestBase;

/**
* Base class for Apigee Edge Teams functional tests.
*/
abstract class ApigeeEdgeTeamsFunctionalTestBase extends ApigeeEdgeFunctionalTestBase {

/**
* {@inheritdoc}
*/
protected static $modules = [
'apigee_edge_teams',
];

/**
* Test token data.
*
* @var array
*/
private $testTokenData = [];

/**
* Stores pre-configured token storage service for testing.
*/
protected function storeToken() {
// Storing the token for Apigeex Hybrid Org.
$this->testTokenData = [
'access_token' => mb_strtolower($this->randomMachineName(32)),
'token_type' => 'bearer',
'expires_in' => 300,
'refresh_token' => mb_strtolower($this->randomMachineName(32)),
'scope' => 'create',
];
$storage = $this->tokenStorage();

// Save the token.
$storage->saveToken($this->testTokenData);
}

/**
* Returns a pre-configured token storage service for testing.
*
* @param bool $rebuild
* Enforces rebuild of the container and with the the token storage
* service.
*
* @return \Drupal\apigee_edge\OauthTokenFileStorage
* The configured and initialized OAuth file token storage service.
*
* @throws \Exception
*/
private function tokenStorage(bool $rebuild = FALSE): OauthTokenFileStorage {
$config = $this->config('apigee_edge.auth');
$config->set('oauth_token_storage_location', OauthTokenFileStorage::DEFAULT_DIRECTORY)->save();
if ($rebuild) {
$this->container->get('kernel')->rebuildContainer();
}
return $this->container->get('apigee_edge.authentication.oauth_token_storage');
}

}
Loading

0 comments on commit 078eee9

Please sign in to comment.