From 1ab3ad16a2c958c635fcb47c809fcaafea46b267 Mon Sep 17 00:00:00 2001 From: "Rustam Lotsmanenko (EPAM)" <rustam_lotsmanenko@epam.com> Date: Wed, 12 Apr 2023 13:37:28 +0000 Subject: [PATCH] Merge branch 'gc-unhardcode-groupid-in-it' into 'master' unhardcode group id in it See merge request osdu/platform/system/notification!370 (cherry picked from commit 1556e541b529704b30d010399d3eb005b7ae787f) 76562307 unhardcode group id in it 716159a5 GONRG-6935: Bring GROUP_ID variable to notification service 28b52e08 Merge branch 'GONRG-6935-Bring-GROUP-ID-variable-to-notification-service' into... --- devops/gc/pipeline/override-stages.yml | 3 ++ .../notification-gc/docs/anthos/README.md | 39 ++++++++++--------- provider/notification-gc/docs/gc/README.md | 1 + .../notification/api/TestPushEndpointGsa.java | 5 ++- .../api/TestPushEndpointHMAC.java | 5 ++- .../osdu/notification/util/Constants.java | 6 +++ .../osdu/notification/util/ServicesUtils.java | 5 ++- .../src/test/resources/StorageRecord.json | 4 +- 8 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/Constants.java diff --git a/devops/gc/pipeline/override-stages.yml b/devops/gc/pipeline/override-stages.yml index 1564301f9..15bfd4e5e 100644 --- a/devops/gc/pipeline/override-stages.yml +++ b/devops/gc/pipeline/override-stages.yml @@ -6,13 +6,16 @@ gc-test: variables: ENVIRONMENT: $GC_ENVIRONMENT REGISTER_BASE_URL: $GC_REGISTER_BASE_URL + GROUP_ID: osdu-gcp.go3-nrg.projects.epam.com gc-dev2-test: variables: ENVIRONMENT: $GC_ENVIRONMENT REGISTER_BASE_URL: $GC_REGISTER_BASE_URL + GROUP_ID: dev2.osdu.club gc-anthos-test: variables: REGISTER_BASE_URL: $GC_REGISTER_BASE_URL GC_VENDOR: anthos + GROUP_ID: osdu-gcp.go3-nrg.projects.epam.com diff --git a/provider/notification-gc/docs/anthos/README.md b/provider/notification-gc/docs/anthos/README.md index c819fb53f..5e1bdf25d 100644 --- a/provider/notification-gc/docs/anthos/README.md +++ b/provider/notification-gc/docs/anthos/README.md @@ -59,25 +59,26 @@ After the service has started it should be accessible via a web browser by visit * Maven * Values for the following environment variables in Config.java -| name | value | description | sensitive? | source | -| --- | --- | --- | --- | --- | -| `TEST_DE_OPS_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_OPS_TESTER` | yes | -- | -| `TEST_DE_OPS_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_OPS_TESTER` | yes | -- | -| `TEST_DE_ADMIN_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_ADMIN_TESTER` | yes | -- | -| `TEST_DE_ADMIN_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_ADMIN_TESTER` | yes | -- | -| `TEST_DE_EDITOR_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_EDITOR_TESTER` | yes | -- | -| `TEST_DE_EDITOR_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_EDITOR_TESTER` | yes | -- | -| `TEST_NO_ACCESS_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_NO_ACCESS_TESTER` | yes | -- | -| `TEST_NO_ACCESS_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_NO_ACCESS_TESTER` | yes | -- | -| `TEST_OPENID_PROVIDER_URL` | `https://keycloak.com/auth/realms/osdu` | OpenID provider url | yes | -- | -| `ENVIRONMENT` | `dev` OR `local` OR `dev_gke`| Local for running locally with services url's predefined as <http://localhost> , Dev & Dev_Gke is configurable environment | no | - | -| `HMAC_SECRET` | ex`7a786376626e` | String in hex , must match pattern ^[a-zA-Z0-9]{8,30}+$ & be in register variable SUBSCRIBER_SECRET | yes | - | -| `REGISTER_BASE_URL` | `http://localhost:8081/api/register/v1` | Register service url | no | - | -| `NOTIFICATION_BASE_URL` | `http://localhost:8080/api/notification/v1/` | Notification service url | no | - | -| `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> | -| `REGISTER_CUSTOM_PUSH_URL_HMAC` | ex `http://localhost:8081/api/register/v1/test/challenge/hmac-integration-test` | Register testing push url | no | - | +| name | value | description | sensitive? | source | +|------------------------------------------------|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------|-----------------------------------------|------------------------------------------------------| +| `TEST_DE_OPS_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_OPS_TESTER` | yes | -- | +| `TEST_DE_OPS_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_OPS_TESTER` | yes | -- | +| `TEST_DE_ADMIN_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_ADMIN_TESTER` | yes | -- | +| `TEST_DE_ADMIN_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_ADMIN_TESTER` | yes | -- | +| `TEST_DE_EDITOR_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_EDITOR_TESTER` | yes | -- | +| `TEST_DE_EDITOR_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_EDITOR_TESTER` | yes | -- | +| `TEST_NO_ACCESS_OPENID_PROVIDER_CLIENT_ID` | `********` | Client Id for `DE_NO_ACCESS_TESTER` | yes | -- | +| `TEST_NO_ACCESS_OPENID_PROVIDER_CLIENT_SECRET` | `********` | | Client secret for `DE_NO_ACCESS_TESTER` | yes | -- | +| `TEST_OPENID_PROVIDER_URL` | `https://keycloak.com/auth/realms/osdu` | OpenID provider url | yes | -- | +| `ENVIRONMENT` | `dev` OR `local` OR `dev_gke` | Local for running locally with services url's predefined as <http://localhost> , Dev & Dev_Gke is configurable environment | no | - | +| `HMAC_SECRET` | ex`7a786376626e` | String in hex , must match pattern ^[a-zA-Z0-9]{8,30}+$ & be in register variable SUBSCRIBER_SECRET | yes | - | +| `REGISTER_BASE_URL` | `http://localhost:8081/api/register/v1` | Register service url | no | - | +| `NOTIFICATION_BASE_URL` | `http://localhost:8080/api/notification/v1/` | Notification service url | no | - | +| `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> | +| `REGISTER_CUSTOM_PUSH_URL_HMAC` | ex `http://localhost:8081/api/register/v1/test/challenge/hmac-integration-test` | Register testing push url | no | - | +| `GROUP_ID` | `osdu-gcp.go3-nrg.projects.epam.com` | Group id, used in storage record ACL. Full group will be "data.default.viewers@{{data-partition-id}}.{{group_id}}" | no | - | **Entitlements configuration for integration accounts** diff --git a/provider/notification-gc/docs/gc/README.md b/provider/notification-gc/docs/gc/README.md index 7802e9ce9..1e1280861 100644 --- a/provider/notification-gc/docs/gc/README.md +++ b/provider/notification-gc/docs/gc/README.md @@ -80,6 +80,7 @@ After the service has started it should be accessible via a web browser by visit | `TOPIC_ID` | ex `records-changed` | PubSub topic id | no | <https://console.cloud.google.com/cloudpubsub/topic> | | `STORAGE_HOST` | `http://localhost:8081/api/storage/v1/` | Storage service url | no | - | | `LEGAL_HOST` | `http://localhost:8081/api/legal/v1/` | Legal service url | no | - | +| `GROUP_ID` | `osdu-gcp.go3-nrg.projects.epam.com` | Group id, used in storage record ACL. Full group will be "data.default.viewers@{{data-partition-id}}.{{group_id}}" | no | - | **Entitlements configuration for integration accounts** diff --git a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointGsa.java b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointGsa.java index a03e03034..2245bebf5 100644 --- a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointGsa.java +++ b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointGsa.java @@ -37,6 +37,7 @@ import java.util.HashMap; import java.util.Map; import static org.junit.Assert.*; +import static org.opengroup.osdu.notification.util.Constants.GROUP_ID; public class TestPushEndpointGsa { public static final String REGISTER_BASE_URL = "REGISTER_BASE_URL"; @@ -58,6 +59,7 @@ public class TestPushEndpointGsa { private String integrationAudience; private String storageHost; private String legalHost; + private String groupId; private static final String LEGAL_TAG_NAME = "notification-test-gsa"; private ServicesUtils servicesUtils; @@ -79,7 +81,8 @@ public class TestPushEndpointGsa { } storageHost = System.getProperty(STORAGE_HOST, System.getenv(STORAGE_HOST)); legalHost = System.getProperty(LEGAL_HOST, System.getenv(LEGAL_HOST)); - servicesUtils = new ServicesUtils(storageHost, legalHost, testUtils, tenant); + groupId = System.getProperty(GROUP_ID, System.getenv(GROUP_ID)); + servicesUtils = new ServicesUtils(storageHost, legalHost, testUtils, tenant, groupId); servicesUtils.createLegalTag(LEGAL_TAG_NAME); createResourceInPartition(tenant); } diff --git a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointHMAC.java b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointHMAC.java index d759d1966..a4b5ec17d 100644 --- a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointHMAC.java +++ b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/api/TestPushEndpointHMAC.java @@ -37,6 +37,7 @@ import java.util.Map; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +import static org.opengroup.osdu.notification.util.Constants.GROUP_ID; public class TestPushEndpointHMAC { public static final String REGISTER_BASE_URL = "REGISTER_BASE_URL"; @@ -57,6 +58,7 @@ public class TestPushEndpointHMAC { private String tenant; private String storageHost; private String legalHost; + private String groupId; private static final String LEGAL_TAG_NAME = "notification-test-hmac"; private ServicesUtils servicesUtils; @@ -75,7 +77,8 @@ public class TestPushEndpointHMAC { tenant = System.getProperty(OSDU_TENANT, System.getenv(OSDU_TENANT)); storageHost = System.getProperty(STORAGE_HOST, System.getenv(STORAGE_HOST)); legalHost = System.getProperty(LEGAL_HOST, System.getenv(LEGAL_HOST)); - servicesUtils = new ServicesUtils(storageHost, legalHost, testUtils, tenant); + groupId = System.getProperty(GROUP_ID, System.getenv(GROUP_ID)); + servicesUtils = new ServicesUtils(storageHost, legalHost, testUtils, tenant, groupId); servicesUtils.createLegalTag(LEGAL_TAG_NAME); createResourceInPartition(tenant); } diff --git a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/Constants.java b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/Constants.java new file mode 100644 index 000000000..7889fab81 --- /dev/null +++ b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/Constants.java @@ -0,0 +1,6 @@ +package org.opengroup.osdu.notification.util; + +public class Constants { + + public static final String GROUP_ID = "GROUP_ID"; +} diff --git a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/ServicesUtils.java b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/ServicesUtils.java index a9a892872..8ccef3040 100644 --- a/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/ServicesUtils.java +++ b/testing/notification-test-gc/src/test/java/org/opengroup/osdu/notification/util/ServicesUtils.java @@ -31,13 +31,15 @@ public class ServicesUtils { private String legalHost; private TestUtils testUtils; private String partitionId; + private String groupId; private FileUtils fileUtils; - public ServicesUtils(String storageHost, String legalHost, TestUtils testUtils, String partitionId) { + public ServicesUtils(String storageHost, String legalHost, TestUtils testUtils, String partitionId, String groupId) { this.storageHost = storageHost; this.legalHost = legalHost; this.testUtils = testUtils; this.partitionId = partitionId; + this.groupId = groupId; this.fileUtils = new FileUtils(); } @@ -68,6 +70,7 @@ public class ServicesUtils { String body = fileUtils.readFromLocalFilePath("/StorageRecord.json"); body = body.replace("{{data-partition-id}}", partitionId); body = body.replace("{{legal-tag}}", partitionId + "-" + legalTag); + body = body.replace("{{group_id}}", groupId); for (int i = 0; i < count; i++) { String actualBody = body.replace("{{ids-suffix}}", suffix + String.valueOf(i)); Map<String, String> headers = new HashMap<>(); diff --git a/testing/notification-test-gc/src/test/resources/StorageRecord.json b/testing/notification-test-gc/src/test/resources/StorageRecord.json index 724c4a75e..c4a8e395f 100644 --- a/testing/notification-test-gc/src/test/resources/StorageRecord.json +++ b/testing/notification-test-gc/src/test/resources/StorageRecord.json @@ -23,10 +23,10 @@ }, "acl": { "viewers": [ - "data.default.viewers@{{data-partition-id}}.osdu-gcp.go3-nrg.projects.epam.com" + "data.default.viewers@{{data-partition-id}}.{{group_id}}" ], "owners": [ - "data.default.owners@{{data-partition-id}}.osdu-gcp.go3-nrg.projects.epam.com" + "data.default.owners@{{data-partition-id}}.{{group_id}}" ] } } -- GitLab