Skip to content

Commit

Permalink
Merge from 8.x-1.x (#620)
Browse files Browse the repository at this point in the history
* [#603] Change ClientInterface constant names and HybridOauth2 (#604)

* [#603] Change ClientInterface constant names and HybridOauth2

* Required apigee-client-php library to 2.0.9

* Fix error when logging with new SAML user (#615)

* Added the stale plugin to close issues with no activity. (#613)

* Added the stale plugin to close issues with no activity.

* We no longer use Travis on this repository

Remove Travis configuration file.

* Basic Auth is not deprecated for OPDK, Removed deprecated message for private cloud (#619)

Fixes #608

Co-authored-by: phdhiren <[email protected]>
Co-authored-by: Shishir <[email protected]>
Co-authored-by: Gitesh Koli <[email protected]>
  • Loading branch information
4 people authored Sep 7, 2021
1 parent 389fdda commit eee08f1
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 105 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Mark stale issues and pull requests

on:
schedule:
- cron: '05 00 * * *'

jobs:
stale:

runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
stale-pr-message: >
This pull request has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
88 changes: 0 additions & 88 deletions .travis.yml

This file was deleted.

3 changes: 2 additions & 1 deletion apigee_edge.install
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ function apigee_edge_requirements($phase) {
// Warning message in status report if using basic auth.
try {
if ($key && $key->getKeyType() instanceof EdgeKeyTypeInterface &&
$key->getKeyType()->getAuthenticationType($key) === EdgeKeyTypeInterface::EDGE_AUTH_TYPE_BASIC) {
$key->getKeyType()->getAuthenticationType($key) === EdgeKeyTypeInterface::EDGE_AUTH_TYPE_BASIC &&
$key->getKeyType()->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC) {
$requirements['apigee_edge_http_basic_auth'] = [
'title' => t('Apigee Edge'),
'description' => t('Apigee Edge HTTP basic authentication will be deprecated. Please choose another authentication method. Visit the <a href=":url">Apigee Edge general settings</a> page to get more information.', [
Expand Down
4 changes: 3 additions & 1 deletion apigee_edge.libraries.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
apigee_edge.admin:
version: 1.1
version: 1.2
css:
theme:
css/apigee_edge.admin.css: {}
js:
js/apigee_edge.admin.js: {}

apigee_edge.analytics:
version: 1.0
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": ">=7.1",
"ext-json": "*",
"apigee/apigee-client-php": "^2.0.6",
"apigee/apigee-client-php": "^2.0.9",
"drupal/core": "^8.7.7 || ^9",
"drupal/entity": "^1.0",
"drupal/key": "^1.8",
Expand Down
44 changes: 44 additions & 0 deletions js/apigee_edge.admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright 2021 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.
*/

/**
* @file
* Javascript functions related to the Analytics page of app entities.
*/
(function ($, Drupal, drupalSettings) {

'use strict';

/**
* Apigee edge admin configuration.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
*/
Drupal.behaviors.apigeeEdgeAuthForm = {
attach: function attach(context, drupalSettings) {
$('#edit-key-input-settings-instance-type input:radio').click(function() {
if ($(this).val() === 'private') {
$('#edit-key-input-settings-auth-type option[value="basic"]').text(Drupal.t('HTTP basic'));
} else if ($(this).val() === 'public') {
$('#edit-key-input-settings-auth-type option[value="basic"]').text(Drupal.t('HTTP basic (deprecated)'));
}
});
}
}
})(jQuery, Drupal, drupalSettings);
2 changes: 1 addition & 1 deletion src/Command/Util/ApigeeEdgeManagementCliService.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function createEdgeRoleForDrupal(StyleInterface $io,

// Set default base URL if var is null or empty string.
if (empty($base_url)) {
$base_url = ApigeeClientInterface::DEFAULT_ENDPOINT;
$base_url = ApigeeClientInterface::EDGE_ENDPOINT;
}
else {
// Validate it is a valid URL.
Expand Down
4 changes: 2 additions & 2 deletions src/Connector/HybridAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@
namespace Drupal\apigee_edge\Connector;

use Apigee\Edge\ClientInterface;
use Apigee\Edge\HttpClient\Plugin\Authentication\HybridOauth2;
use Apigee\Edge\HttpClient\Plugin\Authentication\ApigeeOnGcpOauth2;
use Apigee\Edge\HttpClient\Plugin\Authentication\NullAuthentication;

/**
* Decorator for Hybrid authentication plugin.
*/
class HybridAuthentication extends HybridOauth2 {
class HybridAuthentication extends ApigeeOnGcpOauth2 {

/**
* {@inheritdoc}
Expand Down
4 changes: 2 additions & 2 deletions src/KeyEntityFormEnhancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace Drupal\apigee_edge;

use Apigee\Edge\Exception\ApiRequestException;
use Apigee\Edge\Exception\HybridOauth2AuthenticationException;
use Apigee\Edge\Exception\ApigeeOnGcpOauth2AuthenticationException;
use Apigee\Edge\Exception\OauthAuthenticationException;
use Apigee\Edge\HttpClient\Plugin\Authentication\Oauth;
use Drupal\apigee_edge\Exception\AuthenticationKeyException;
Expand Down Expand Up @@ -475,7 +475,7 @@ private function createSuggestion(\Exception $exception, KeyInterface $key): Mar
]);
}

elseif ($exception instanceof HybridOauth2AuthenticationException) {
elseif ($exception instanceof ApigeeOnGcpOauth2AuthenticationException) {
$fail_text = $this->t('Failed to connect to the authorization server.');
// General error message.
$suggestion = $this->t('@fail_text Check the debug information below for more details.', [
Expand Down
6 changes: 3 additions & 3 deletions src/Plugin/EdgeKeyTypeBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public function getAuthenticationType(KeyInterface $key): string {
*/
public function getEndpoint(KeyInterface $key): string {
if ($this->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_HYBRID) {
return ClientInterface::HYBRID_ENDPOINT;
return ClientInterface::APIGEE_ON_GCP_ENDPOINT;
}
elseif ($this->getInstanceType($key) === EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC) {
return Client::DEFAULT_ENDPOINT;
return Client::EDGE_ENDPOINT;
}
return $key->getKeyValues()['endpoint'];
}
Expand Down Expand Up @@ -100,7 +100,7 @@ public function getInstanceType(KeyInterface $key): string {
}

// Backwards compatibility, before Hybrid support.
if (empty($key_values['endpoint']) || $key_values['endpoint'] === ClientInterface::DEFAULT_ENDPOINT) {
if (empty($key_values['endpoint']) || $key_values['endpoint'] === ClientInterface::EDGE_ENDPOINT) {
return EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC;
}

Expand Down
5 changes: 4 additions & 1 deletion src/Plugin/KeyInput/ApigeeAuthKeyInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ApigeeAuthKeyInput extends KeyInputBase {
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$values = $this->getFormDefaultValues($form_state);

if (!empty($values['auth_type']) && $values['auth_type'] == EdgeKeyTypeInterface::EDGE_AUTH_TYPE_BASIC) {
if (!empty($values['auth_type']) && $values['auth_type'] == EdgeKeyTypeInterface::EDGE_AUTH_TYPE_BASIC && !empty($values['instance_type']) && $values['instance_type'] == EdgeKeyTypeInterface::INSTANCE_TYPE_PUBLIC) {
$this->messenger()->addWarning($this->t('HTTP basic authentication will be deprecated. Please choose another authentication method.'));
}

Expand Down Expand Up @@ -89,6 +89,9 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'required' => [$state_for_public, $state_for_private],
],
];
if (!empty($values['instance_type']) && EdgeKeyTypeInterface::INSTANCE_TYPE_PRIVATE === $values['instance_type']) {
$form['auth_type']['#options'][EdgeKeyTypeInterface::EDGE_AUTH_TYPE_BASIC] = $this->t('HTTP basic');
}
$form['organization'] = [
'#type' => 'textfield',
'#title' => $this->t('Organization'),
Expand Down
5 changes: 4 additions & 1 deletion src/UserDeveloperConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ public function __construct(ConfigFactory $config_factory, EntityTypeManagerInte
*/
public function convertUser(UserInterface $user): UserToDeveloperConversionResult {
$problems = [];
$developer = NULL;
$successful_changes = 0;
$email = isset($user->original) ? $user->original->getEmail() : $user->getEmail();
$developer = $this->entityTypeManager->getStorage('developer')->load($email);
if ($email) {
$developer = $this->entityTypeManager->getStorage('developer')->load($email);
}
if (!$developer) {
/** @var \Drupal\apigee_edge\Entity\DeveloperInterface $developer */
$developer = $this->entityTypeManager->getStorage('developer')->create([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function testCreateEdgeRoleForDrupalDefaultRoleAndBaseUrl() {
->shouldBeCalledTimes(1)
->willReturn('{ "name": "' . $this->org . '" }');
$this->httpClient
->get(Argument::exact(ApigeeClientInterface::DEFAULT_ENDPOINT . '/o/' . $this->org), Argument::type('array'))
->get(Argument::exact(ApigeeClientInterface::EDGE_ENDPOINT . '/o/' . $this->org), Argument::type('array'))
->shouldBeCalledTimes(1)
->willReturn($response_org->reveal());

Expand All @@ -163,17 +163,17 @@ public function testCreateEdgeRoleForDrupalDefaultRoleAndBaseUrl() {
$response_role->getStatusCode()->willReturn(404);
$exception = new ClientException('Forbidden', $request_role->reveal(), $response_role->reveal());
$this->httpClient
->get(Argument::exact(ApigeeClientInterface::DEFAULT_ENDPOINT . '/o/' . $this->org . '/userroles/' . ApigeeEdgeManagementCliServiceInterface::DEFAULT_ROLE_NAME), Argument::type('array'))
->get(Argument::exact(ApigeeClientInterface::EDGE_ENDPOINT . '/o/' . $this->org . '/userroles/' . ApigeeEdgeManagementCliServiceInterface::DEFAULT_ROLE_NAME), Argument::type('array'))
->willThrow($exception);

// The role should be created.
$this->httpClient
->post(Argument::exact(ApigeeClientInterface::DEFAULT_ENDPOINT . '/o/' . $this->org . '/userroles'), Argument::type('array'))
->post(Argument::exact(ApigeeClientInterface::EDGE_ENDPOINT . '/o/' . $this->org . '/userroles'), Argument::type('array'))
->shouldBeCalledTimes(1);

// The permissions should be set.
$this->httpClient
->post(Argument::exact(ApigeeClientInterface::DEFAULT_ENDPOINT . '/o/' . $this->org . '/userroles/' . ApigeeEdgeManagementCliServiceInterface::DEFAULT_ROLE_NAME . '/permissions'), Argument::type('array'))
->post(Argument::exact(ApigeeClientInterface::EDGE_ENDPOINT . '/o/' . $this->org . '/userroles/' . ApigeeEdgeManagementCliServiceInterface::DEFAULT_ROLE_NAME . '/permissions'), Argument::type('array'))
->shouldBeCalledTimes(12);

$apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient->reveal());
Expand Down

0 comments on commit eee08f1

Please sign in to comment.