Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#603] Change ClientInterface constant names and HybridOauth2 #604

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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