diff --git a/provider/notification-gcp/pom.xml b/provider/notification-gcp/pom.xml index e32c4a09e612f16e9ab87bb0b0d5e6c59b5cce17..50409e65f6b4d4ccaa85ee7f3190b69e02e2d7df 100644 --- a/provider/notification-gcp/pom.xml +++ b/provider/notification-gcp/pom.xml @@ -144,6 +144,25 @@ <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.7.7.201606060606</version> + <executions> + <execution> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <execution> + <id>report</id> + <phase>prepare-package</phase> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> </project> diff --git a/testing/README.md b/testing/README.md index e23b98fbbd0c42d43c467fca28db8b3c7658f7f3..f2f4870f44b49e3f79f29e5072d1f892cfda0e30 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 7812c54cd815ca1dc159f1125a55c1a2051d88ed..cef5ecfe530acfe45fb67559e4b09ef6ee34edba 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 0000000000000000000000000000000000000000..90d4c022afcf3e377cd8ee91edfece97d9b3266e --- /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