From 845d526c2d858d1cf8dc2d265b99e9f488f817b6 Mon Sep 17 00:00:00 2001 From: Rustam_Lotsmanenko <Rustam_Lotsmanenko@epam.com> Date: Fri, 25 Sep 2020 12:55:19 +0400 Subject: [PATCH] GONRG-843 , GONRG-847 Added README.md to gcp int tests Unhardcoded some values in int test config --- testing/README.md | 3 ++ .../osdu/notification/util/Config.java | 20 ++++++-- testing/notification-test-gcp/README.md | 49 +++++++++++++++++++ 3 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 testing/notification-test-gcp/README.md diff --git a/testing/README.md b/testing/README.md index e23b98fbb..f2f4870f4 100644 --- a/testing/README.md +++ b/testing/README.md @@ -40,3 +40,6 @@ Notification integration tests are refactored so that the business logic for int ###Commands to run tests * Integration tests are refactored into two pieces: Core and Provider. Core contains business logic for tests and is a dependency for executing the tests from provider module. To build the core module, simply navigate to `notification-test-core` directory and run `mvn clean install`. This will build the core module * Next, to execute the integration tests, navigate to the provider module and execute `mvn test` + +### GCP +Instructions for running the GCP integration tests can be found [here](./notification-test-gcp/README.md). \ No newline at end of file diff --git a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/Config.java b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/Config.java index 7812c54cd..cef5ecfe5 100644 --- a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/Config.java +++ b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/Config.java @@ -33,10 +33,10 @@ public class Config { public static Config Instance() { String env = getEnvironment(); - config.ClientTenant = "nonexistenttenant"; - config.IntegrationAudience = "245464679631-ktfdfpl147m1mjpbutl00b3cmffissgq.apps.googleusercontent.com"; - config.OsduTenant = "opendes"; - config.Topic = "records-changed"; + config.ClientTenant = getEnvironmentVariableOrDefaultValue("CLIENT_TENANT","nonexistenttenant"); + config.IntegrationAudience = getEnvironmentVariableOrDefaultValue("INTEGRATION_TEST_AUDIENCE","245464679631-ktfdfpl147m1mjpbutl00b3cmffissgq.apps.googleusercontent.com"); + config.OsduTenant = getEnvironmentVariableOrDefaultValue("OSDU_TENANT","opendes"); + config.Topic = getEnvironmentVariableOrDefaultValue("TOPIC_ID","records-changed"); config.hmacSecretValue = System.getProperty("HMAC_SECRET", System.getenv("HMAC_SECRET")); if (env.equalsIgnoreCase("LOCAL")) { @@ -71,4 +71,16 @@ public class Config { private static String getEnvironment() { return System.getProperty("ENVIRONMENT", System.getenv("ENVIRONMENT")); } + + private static String getEnvironmentVariableOrDefaultValue(String key, String defaultValue) { + String environmentVariable = getEnvironmentVariable(key); + if (environmentVariable == null) { + environmentVariable = defaultValue; + } + return environmentVariable; + } + + private static String getEnvironmentVariable(String propertyKey) { + return System.getProperty(propertyKey, System.getenv(propertyKey)); + } } diff --git a/testing/notification-test-gcp/README.md b/testing/notification-test-gcp/README.md new file mode 100644 index 000000000..90d4c022a --- /dev/null +++ b/testing/notification-test-gcp/README.md @@ -0,0 +1,49 @@ +###Dependencies needed to run the integration tests +* JDK11 +* Maven +* Values for the following environment variables in Config.java + +| name | value | description | sensitive? | source | +| --- | --- | --- | --- | --- | +| `DE_OPS_TESTER` | `*****` | Service account base64 encoded string for API calls. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | +| `DE_ADMIN_TESTER` | `*****` | Service account base64 encoded string for API calls. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | +| `DE_EDITOR_TESTER` | `*****` | Service account base64 encoded string for API calls. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | +| `DE_NO_ACCESS_TESTER` | `*****` | Service account base64 encoded string for API calls. Note: this user must have entitlements configured already | yes | https://console.cloud.google.com/iam-admin/serviceaccounts | +| `ENVIRONMENT` | `dev` OR `local` | Local for running locally with services url's predefined as http://localhost , Dev is configurable environment | no | - | +| `HMAC_SECRET` | `*****` | sensitive secret to run HMAC tests | yes | - | +| `REGISTER_BASE_URL` | `http://localhost:8081/api/register/v1` | Register service url | no | - | +| `NOTIFICATION_BASE_URL` | `http://localhost:8080/` | Notification service url | no | - | +| `INTEGRATION_TEST_AUDIENCE` | `********` | Client application ID | yes | https://console.cloud.google.com/apis/credentials | +| `CLIENT_TENANT` | ex `opendes` | Client tenant | no | - | +| `OSDU_TENANT` | ex `osdu` | Osdu tenant | no | - | +| `TOPIC_ID` | ex `records-changed` | PubSub topic id | no | https://console.cloud.google.com/cloudpubsub/topic | + + **Entitlements configuration for integration accounts** + + | DE_OPS_TESTER | DE_ADMIN_TESTER | DE_EDITOR_TESTER | DE_NO_ACCESS_TESTER | + | --- | --- | --- | --- | + |notification.pubsub<br/>service.entitlements.user<br/>users<br/>| service.entitlements.user<br/>users<br/> | service.entitlements.user<br/>users<br/> | service.entitlements.user<br/>users<br/>| + +Above variables should be configured in the release pipeline to run integration tests. You should also replace them with proper values if you wish to run tests locally. + +###Commands to run tests +* Integration tests are refactored into two pieces: Core and Provider. Core contains business logic for tests and is a dependency for executing the tests from provider module. To build the core module, simply navigate to `notification-test-core` directory and run `mvn clean install`. This will build the core module +* Next, to execute the integration tests, navigate to the provider module and execute `mvn test` + + +## License +Copyright © Google LLC + +Copyright © EPAM Systems + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file -- GitLab