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

Copy changes for general settings #36

Closed
wants to merge 7 commits into from
Closed
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 .travis/prepare-test-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

if [[ -z "${APIGEE_EDGE_ENDPOINT}" ]] || [[ -z "${APIGEE_EDGE_USERNAME}" ]] || [[ -z "${APIGEE_EDGE_PASSWORD}" ]] || [[ -z "${APIGEE_EDGE_ORGANIZATION}" ]]; then
echo "Incomplete configuration. Please make sure the following environment variables exist and not empty: APIGEE_EDGE_ENDPOINT, APIGEE_EDGE_USERNAME, APIGEE_EDGE_PASSWORD, APIGEE_EDGE_ORGANIZATION."
echo "Incomplete configuration. Make sure the following environment variables exist and not empty: APIGEE_EDGE_ENDPOINT, APIGEE_EDGE_USERNAME, APIGEE_EDGE_PASSWORD, APIGEE_EDGE_ORGANIZATION."
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion .travis/push-logs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

if [[ -z "${LOGS_REPO_USER}" ]] || [[ -z "${LOGS_REPO_PASSWORD}" ]] || [[ -z "${LOGS_REPO_HOST}" ]] || [[ -z "${LOGS_REPO_NAME}" ]]; then
echo "There is at least one missing information about the destination repo. Please make sure the following environment variables exist and not empty: LOGS_REPO_USER, LOGS_REPO_PASSWORD, LOGS_REPO_HOST, LOGS_REPO_NAME."
echo "There is at least one missing information about the destination repo. Make sure the following environment variables exist and not empty: LOGS_REPO_USER, LOGS_REPO_PASSWORD, LOGS_REPO_HOST, LOGS_REPO_NAME."
exit 0
fi

Expand Down
18 changes: 10 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ This project follows [Google's Open Source Community Guidelines](https://opensou

# Suggested contributing workflow

## For a start
## To start
* Fork this project on Github.
* If you do not have an Apigee Edge trial organization please create a new one
* If you do not have an Apigee Edge trial organization, create a new one
[here](https://login.apigee.com/login).
* Register on https://travis-ci.org.
* Open https://travis-ci.org/[YOUR-GITHUB-USERNAME]/apigee-edge-drupal and click
Expand All @@ -42,10 +42,12 @@ required environment variables in the [Testing](#testing) section.)

## For daily work
* Create a new branch in your fork repository, ex.: patch-1.
* Add changes to the code. If you implement new features please always add new
tests to cover the implemented functionality. If you modify existing features please always update related tests if needed.
* Add changes to the code. If you implement new features, add new
tests to cover the implemented functionality. If you modify existing features, update related tests.
* Push your changes to your repo's patch-1 branch.
* Wait until all Travis CI test jobs finish and _pass_.
* Wait until all Travis CI test jobs finish and _pass_. (If any of them fails
restart them once or twice. They may have failed due to an API communication error. You can
identify these type of issues from logs.)
* Create [new pull request](https://github.com/apigee/apigee-edge-drupal/pull/new/8.x-1.x)
and do not forget to add a link to Travis CI build that can confirm your code is working.

Expand Down Expand Up @@ -117,8 +119,8 @@ PHPUnit tests with the following commands:
```bash
cd [DRUPAL_ROOT]/modules/contrib/apigee_edge/.travis
docker-compose up --build # Build is important because recent changes on module files have to be copied from the host to the container.
docker-compose run php /opt/drupal-module/run-test.sh # to run all tests of this module. This command performs some initial setup tasks if test environment has not been configured yet.
docker-compose run php /opt/drupal-module/run-test.sh --filter testAppSettingsForm AppSettingsFormTest build/modules/contrib/apigee_edge/tests/src/FunctionalJavascript/AppSettingsFormTest.php # to run one specific test. If you pass any arguments to run-test.sh those get passed directly to PHPUnit. See [.travis/run-test.sh](run-test.sh).
docker-compose run php /opt/drupal-module/.travis/run-test.sh # to run all tests of this module. This command performs some initial setup tasks if test environment has not been configured yet.
docker-compose run php /opt/drupal-module/.travis/run-test.sh --filter testAppSettingsForm AppSettingsFormTest build/modules/contrib/apigee_edge/tests/src/FunctionalJavascript/AppSettingsFormTest.php # to run one specific test. If you pass any arguments to run-test.sh those get passed directly to PHPUnit. See [.travis/run-test.sh](run-test.sh).
docker-compose down --remove-orphans -v # Intermediate data (like module files) must be cleared from the shared volumes otherwise recent changes won't be visible in the container.
```

Expand Down Expand Up @@ -146,7 +148,7 @@ repository URL:
`https://${LOGS_REPO_USER}:${LOGS_REPO_PASSWORD}@${LOGS_REPO_HOST}/${LOGS_REPO_USER}/${LOGS_REPO_NAME}.git`

### If your pull request relies on changes that are not yet available in Apigee Edge Client Library for PHP's latest stable release
Please *temporary* add required changes as patches to module's composer.json.
You should *temporarily* add required changes as patches to module's composer.json.
This way this module's tests could pass on Travis CI.

#### Example:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ The Apigee Edge module enables you to integrate Drupal 8 with Apigee Edge.
### Requirements

* Drupal 8's minimum requirement is phpdocumentor/reflection-docblock:2.0.4 but at least 3.0 is required by this module. If you get the error "Your requirements could not be resolved to an installable set of packages" it may be because you are running reflection-docblock version 2. You can update `phpdocumentor/reflection-docblock` with the following command: `composer update phpdocumentor/reflection-docblock --with-dependencies`.
* **Please check [composer.json](https://github.com/apigee/apigee-edge-drupal/blob/8.x-1.x/composer.json) for required patches.** Patches prefixed with "(For testing)" are only required for running tests. Those are not necessary for using this module. Patches can be applied with the [cweagans/composer-patches](https://packagist.org/packages/cweagans/composer-patches) the plugin automatically or manually.
* (For developers) The locked commit from `behat/mink` library is required otherwise tests may fail. This caused by a Drupal core [bug](https://www.drupal.org/project/drupal/issues/2956279). Please see the related pull request for behat/mink [here](https://github.com/minkphp/Mink/pull/760).
* **Check [composer.json](https://github.com/apigee/apigee-edge-drupal/blob/8.x-1.x/composer.json) for required patches.** Patches prefixed with "(For testing)" are only required for running tests. Those are not necessary for using this module. Patches can be applied with the [cweagans/composer-patches](https://packagist.org/packages/cweagans/composer-patches) the plugin automatically or manually.
* (For developers) The locked commit from `behat/mink` library is required otherwise tests may fail. This caused by a Drupal core [bug](https://www.drupal.org/project/drupal/issues/2956279). See the related pull request for behat/mink [here](https://github.com/minkphp/Mink/pull/760).

### Troubleshooting

Expand Down
2 changes: 1 addition & 1 deletion apigee_edge.install
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function apigee_edge_requirements($phase) {
$requirements['apigee_edge_connection_error'] = [
'title' => t('Apigee Edge'),
'value' => $exception->getMessage(),
'description' => t('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the <a href=":url">Apigee Edge Configuration</a> page to get more information.', [
'description' => t('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the <a href=":url">Apigee Edge general configuration</a> page to get more information.', [
':url' => Url::fromRoute('apigee_edge.settings', ['destination' => 'admin/reports/status'])->toString(),
]),
'severity' => REQUIREMENT_WARNING,
Expand Down
18 changes: 9 additions & 9 deletions apigee_edge.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,39 @@ apigee_edge.settings:
path: '/admin/config/apigee-edge/settings'
defaults:
_form: '\Drupal\apigee_edge\Form\AuthenticationForm'
_title: 'Apigee Edge Configuration'
_title: 'Apigee Edge general configuration'
requirements:
_permission: 'administer apigee edge'

apigee_edge.settings.connection_config:
path: '/admin/config/apigee-edge/connection-config'
defaults:
_form: '\Drupal\apigee_edge\Form\ConnectionConfigForm'
_title: 'Connection Config'
_title: 'Connection config'
requirements:
_permission: 'administer apigee edge'

apigee_edge.settings.error_page:
path: '/admin/config/apigee-edge/error-page-settings'
defaults:
_form: '\Drupal\apigee_edge\Form\ErrorPageSettingsForm'
_title: 'Error Page Settings'
_title: 'Error page settings'
requirements:
_permission: 'administer apigee edge'

apigee_edge.settings.developer:
path: '/admin/config/apigee-edge/developer-settings'
defaults:
_form: '\Drupal\apigee_edge\Form\DeveloperSettingsForm'
_title: 'Developer Settings'
_title: 'Developer settings'
requirements:
_permission: 'administer apigee edge'

apigee_edge.settings.developer.email_validation:
path: '/admin/config/apigee-edge/developer-settings/attributes'
defaults:
_form: '\Drupal\apigee_edge\Form\DeveloperAttributesSettingsForm'
_title: 'Custom Attributes'
_title: 'Custom attributes'
requirements:
_permission: 'administer apigee edge'

Expand All @@ -75,30 +75,30 @@ apigee_edge.settings.product.alias:
path: '/admin/config/apigee-edge/product-settings/alias'
defaults:
_form: '\Drupal\apigee_edge\Form\ProductAliasForm'
_title: 'API Product Settings'
_title: 'API product settings'
requirements:
_permission: 'administer apigee edge'

apigee_edge.settings.product.caching:
path: '/admin/config/apigee-edge/product-settings/caching'
defaults:
_form: '\Drupal\apigee_edge\Form\ProductCachingForm'
_title: 'API Product caching'
_title: 'API product caching'
requirements:
_permission: 'administer apigee edge'
apigee_edge.settings.product.access_control:
path: '/admin/config/apigee-edge/product-settings/access-control'
defaults:
_form: '\Drupal\apigee_edge\Form\ProductAccessControlForm'
_title: 'API Product access control'
_title: 'API product access control'
requirements:
_permission: 'administer apigee edge'

apigee_edge.settings.app:
path: '/admin/config/apigee-edge/app-settings'
defaults:
_form: '\Drupal\apigee_edge\Form\AppSettingsForm'
_title: 'App Settings'
_title: 'App settings'
requirements:
_permission: 'administer apigee edge'

Expand Down
4 changes: 2 additions & 2 deletions config/install/apigee_edge.developer_app_settings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
langcode: en
entity_label_singular: ''
entity_label_plural: ''
entity_label_singular: 'App'
entity_label_plural: 'Apps'
cache_expiration: 900
credential_lifetime: 0
locked_base_fields:
Expand Down
4 changes: 2 additions & 2 deletions config/install/apigee_edge.error_page.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
langcode: en
error_page_title: 'Connection Error'
error_page_title: 'Connection error'
error_page_content:
value: 'There is a problem with the connection to the API server. Please contact the Developer Portal support for further assistance.'
value: 'Cannot reach management server. An administrator should check the configuration of this site.'
format: 'plain_text'
9 changes: 0 additions & 9 deletions css/apigee_edge.admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@
margin-top: 10px;
}

.info-circle {
border-radius: 50%;
color: white;
width: 16px;
height: 16px;
background: #5c5c5b;
display: inline-block;
text-align: center;
}

.table--developer-attributes {
margin-top: 20px;
Expand Down
22 changes: 11 additions & 11 deletions src/Form/DeveloperSyncForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,17 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#title' => $this->t('Sync developers'),
'#open' => TRUE,
];

$form['sync']['description'] = [
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this->t('Developer synchronization will run through all users in this portal, adding them as developers in the Apigee Edge org, and making sure all developers on the Apigee Edge org are added to this portal. The "Run Developer Sync" button will sync the developers, displaying a progress bar. The "Background Developer Sync" button will run the developer sync process in batches each time <a href=":cron_url">cron</a> runs.', [
':cron_url' => Url::fromRoute('system.cron_settings')->toString(),
]),
];

$form['sync']['sync_submit'] = [
'#title' => $this->t('Now'),
'#title' => $this->t('Run Developer Sync'),
'#type' => 'link',
'#url' => $this->buildUrl('apigee_edge.user_sync.run'),
'#attributes' => [
Expand All @@ -58,7 +67,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
],
];
$form['sync']['background_sync_submit'] = [
'#title' => $this->t('Background'),
'#title' => $this->t('Background Developer Sync'),
'#type' => 'link',
'#url' => $this->buildUrl('apigee_edge.user_sync.schedule'),
'#attributes' => [
Expand All @@ -67,15 +76,6 @@ public function buildForm(array $form, FormStateInterface $form_state) {
],
],
];
$form['sync']['sync_info'] = [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => '?',
'#attributes' => [
'class' => 'info-circle',
'title' => $this->t('A background sync is recommended for large numbers of developers.'),
],
];

return $form;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Form/ErrorPageSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {

$form['error_page'] = [
'#type' => 'fieldset',
'#title' => $this->t('The displayed title and content on the error page.'),
'#title' => $this->t('Displayed title and content on error page'),
'#collapsible' => FALSE,
];

Expand Down
4 changes: 2 additions & 2 deletions src/Plugin/KeyInput/BasicAuthKeyInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['organization'] = [
'#type' => 'textfield',
'#title' => $this->t('Organization'),
'#description' => $this->t('Name of the organization on Edge. Changing this value could make your site stop working.'),
'#description' => $this->t('Name of the Apigee Edge organization. Changing this value could make your site stop working.'),
'#required' => $key->getKeyType()->getPluginDefinition()['multivalue']['fields']['organization']['required'],
'#default_value' => $values['organization'],
'#attributes' => ['autocomplete' => 'off'],
Expand All @@ -71,7 +71,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$form['endpoint'] = [
'#type' => 'textfield',
'#title' => $this->t('Apigee Edge endpoint'),
'#description' => $this->t('Apigee Edge endpoint where the API calls are being sent. Leave empty to use the default <em>https://api.enterprise.apigee.com/v1</em> endpoint.'),
'#description' => $this->t('Apigee Edge endpoint where the API calls are being sent. Leave empty to use the public cloud endpoint <em>https://api.enterprise.apigee.com/v1</em>.'),
'#required' => $key->getKeyType()->getPluginDefinition()['multivalue']['fields']['endpoint']['required'],
'#default_value' => $values['endpoint'],
'#attributes' => ['autocomplete' => 'off'],
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/KeyProvider/PrivateFileKeyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @KeyProvider(
* id = "apigee_edge_private_file",
* label = @Translation("Apigee Edge: Private File"),
* description = @Translation("Stores Apigee Edge authentication credentials in a private file.<p><strong>Warning! </strong>Private file storage is suitable only for testing environments. In production environments, use the <em>Apigee Edge: Environment Variables</em> key provider.</p>"),
* description = @Translation("Stores Apigee Edge authentication credentials in a private file.</p>"),
* storage_method = "apigee_edge",
* key_value = {
* "accepted" = TRUE,
Expand Down
8 changes: 4 additions & 4 deletions tests/src/Functional/RequirementsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function testInvalidCredentials() {
$this->invalidateKey();
$this->drupalGet('/admin/reports/status');
$this->assertSession()->pageTextContains('Apigee Edge API authentication key not found.');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge Configuration page to get more information.');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge general configuration page to get more information.');

// Create new Apigee Edge basic auth key with private file provider.
$key = Key::create([
Expand Down Expand Up @@ -86,14 +86,14 @@ public function testInvalidCredentials() {

$this->drupalGet('/admin/reports/status');
$this->assertSession()->pageTextContains('Unauthorized');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge Configuration page to get more information.');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge general configuration page to get more information.');

// Delete authentication key.
Key::load('private_file')->delete();

$this->drupalGet('/admin/reports/status');
$this->assertSession()->pageTextContains('Apigee Edge API authentication key not found.');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge Configuration page to get more information.');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge general configuration page to get more information.');

// Create new Apigee Edge OAuth key with private file provider.
$key = Key::create([
Expand Down Expand Up @@ -137,7 +137,7 @@ public function testInvalidCredentials() {

$this->drupalGet('/admin/reports/status');
$this->assertSession()->pageTextContains('Forbidden');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge Configuration page to get more information.');
$this->assertSession()->pageTextContains('Cannot connect to Apigee Edge server. You have either given wrong credential details or the Edge server is unreachable. Visit the Apigee Edge general configuration page to get more information.');

// Unset private file path.
$settings['settings']['file_private_path'] = (object) [
Expand Down