Skip to content

Commit

Permalink
Code sniffer validations (#482)
Browse files Browse the repository at this point in the history
* [#475] Adding http_client_proxy setting field - code sniffer validations and message strings.

* Fixing code sniffer validations after update to drupal/coder 8.3.10
  • Loading branch information
arlina-espinoza authored Sep 10, 2020
1 parent d8eac5e commit c686f34
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 20 deletions.
4 changes: 4 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
<severity>0</severity>
</rule>
<!-- Ignore long array declaration lines. -->
<rule ref="Drupal.Arrays.Array.LongLineDeclaration">
<severity>0</severity>
</rule>

</ruleset>
4 changes: 1 addition & 3 deletions src/Exception/AuthenticationKeyValueMalformedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Drupal\apigee_edge\Exception;

use Throwable;

/**
* Defines an exception for when a key value is malformed.
*/
Expand All @@ -30,7 +28,7 @@ class AuthenticationKeyValueMalformedException extends AuthenticationKeyExceptio
* @param \Throwable|null $previous
* Previous exception.
*/
public function __construct($problematic_field, $message = 'Apigee Edge API authentication key is malformed or not readable.', $code = 0, Throwable $previous = NULL) {
public function __construct($problematic_field, $message = 'Apigee Edge API authentication key is malformed or not readable.', $code = 0, \Throwable $previous = NULL) {
$this->problematicField = $problematic_field;
$message = strtr($message, ['@field' => $problematic_field]);
parent::__construct($message, $code, $previous);
Expand Down
16 changes: 8 additions & 8 deletions src/Form/ConnectionConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#required' => TRUE,
];

$form['http_proxy'] = [
'#type' => 'textfield',
'#title' => $this->t('HTTP client proxy'),
'#description' => $this->t('The Http proxy used to connect to Apigee Edge.'),
'#default_value' => $this->config('apigee_edge.client')->get('http_client_proxy'),
'#required' => FALSE,
];
$form['http_proxy'] = [
'#type' => 'textfield',
'#title' => $this->t('HTTP client proxy'),
'#description' => $this->t('Leave empty unless an HTTP proxy is needed to connect to Apigee Edge.'),
'#default_value' => $this->config('apigee_edge.client')->get('http_client_proxy'),
'#required' => FALSE,
];

return parent::buildForm($form, $form_state);
}
Expand All @@ -85,7 +85,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('apigee_edge.client')
->set('http_client_connect_timeout', $form_state->getValue('connect_timeout'))
->set('http_client_timeout', $form_state->getValue('request_timeout'))
->set('http_client_proxy', $form_state->getValue('http_proxy'))
->set('http_client_proxy', trim($form_state->getValue('http_proxy')))
->save();
parent::submitForm($form, $form_state);
}
Expand Down
3 changes: 1 addition & 2 deletions src/KeyEntityFormEnhancer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
use Apigee\Edge\Exception\HybridOauth2AuthenticationException;
use Apigee\Edge\Exception\OauthAuthenticationException;
use Apigee\Edge\HttpClient\Plugin\Authentication\Oauth;
use DomainException;
use Drupal\apigee_edge\Exception\AuthenticationKeyException;
use Drupal\apigee_edge\Exception\InvalidArgumentException;
use Drupal\apigee_edge\Exception\KeyProviderRequirementsException;
Expand Down Expand Up @@ -478,7 +477,7 @@ private function createSuggestion(\Exception $exception, KeyInterface $key): Mar
]);

// Invalid key / OpenSSL unable to sign data.
if ($exception->getPrevious() && $exception->getPrevious() instanceof DomainException) {
if ($exception->getPrevious() && $exception->getPrevious() instanceof \DomainException) {
$suggestion = $this->t('@fail_text The private key in the GCP service account key JSON is invalid.', [
'@fail_text' => $fail_text,
]);
Expand Down
3 changes: 1 addition & 2 deletions src/Plugin/FieldStorageFormatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Traversable;

/**
* Provides a FieldStorageFormat plugin manager.
Expand All @@ -33,7 +32,7 @@ class FieldStorageFormatManager extends DefaultPluginManager implements FieldSto
/**
* {@inheritdoc}
*/
public function __construct(Traversable $namespaces, CacheBackendInterface $cache, ModuleHandlerInterface $module_handler) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache, ModuleHandlerInterface $module_handler) {
parent::__construct(
'Plugin/ApigeeFieldStorageFormat',
$namespaces,
Expand Down
9 changes: 6 additions & 3 deletions tests/src/Functional/DeveloperAppUITest.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,10 @@ public function testWarningMessagesIfMultipleProductsDisabled() {
->save();
\Drupal::entityTypeManager()->clearCachedDefinitions();

$this->products[] = $product1 = $this->createProduct();;
$this->products[] = $product2 = $this->createProduct();
$product1 = $this->createProduct();
$product2 = $this->createProduct();
$this->products[] = $product1;
$this->products[] = $product2;
$app = $this->createDeveloperApp(['name' => $this->randomMachineName(), 'displayName' => $this->randomString()], $this->account, [$product1->id(), $product2->id()]);
$app_edit_url = $app->toUrl('edit-form-for-developer');

Expand Down Expand Up @@ -517,7 +519,8 @@ public function testCallbackUrlValidationServerSide() {
->save();

$callback_url = $this->randomMachineName();
$this->products[] = $product = $this->createProduct();;
$product = $this->createProduct();
$this->products[] = $product;
$app = $this->createDeveloperApp([
'name' => $callback_url,
'displayName' => $this->randomString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
use GuzzleHttp\Psr7\Response;
use Prophecy\Argument;
use Psr\Http\Message\RequestInterface;
use ReflectionClass;
use Symfony\Component\Console\Style\StyleInterface;

/**
Expand Down Expand Up @@ -479,7 +478,7 @@ public function testSetDefaultPermissions() {

// Make method under test not private.
$apigee_edge_management_cli_service = new ApigeeEdgeManagementCliService($this->httpClient->reveal());
$apigee_edge_management_cli_service_reflection = new ReflectionClass($apigee_edge_management_cli_service);
$apigee_edge_management_cli_service_reflection = new \ReflectionClass($apigee_edge_management_cli_service);
$method_set_default_permissions = $apigee_edge_management_cli_service_reflection->getMethod('setDefaultPermissions');
$method_set_default_permissions->setAccessible(TRUE);

Expand Down

0 comments on commit c686f34

Please sign in to comment.