diff --git a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointGSADescriptor.java b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointGSADescriptor.java index 65a359f2fe64029e1195fb0b4e72a259304dfff1..8103c19d425af00860ba7f91c256cb095e3af891 100644 --- a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointGSADescriptor.java +++ b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointGSADescriptor.java @@ -20,6 +20,9 @@ import org.opengroup.osdu.notification.util.Config; import org.opengroup.osdu.notification.util.RestDescriptor; import org.opengroup.osdu.notification.util.TestUtils; +import java.util.HashMap; +import java.util.Map; + public class PubsubEndpointGSADescriptor extends RestDescriptor { @Override @@ -41,7 +44,21 @@ public class PubsubEndpointGSADescriptor extends RestDescriptor { "\t\"data-partition-id\": \"" + TestUtils.getOsduTenant() + "\"},\n" + "\t\"data\": \"W3sia2luZCI6InRlc3RraW5kIiwiaWQiOiJ0ZXN0aWQiLCJvcGVyYXRpb250eXBlIjoiY3JlYXRlIn0seyJraW5kIjoidGVzdGtpbmQyIiwiaWQiOiJ0ZXN0aWQyIiwib3BlcmF0aW9udHlwZSI6InVwZGF0ZSJ9XQ\",\n" + "\t\"messageId\": \"136969346945\"},\n" + - "\t\"subscription\":\"" + Config.Instance().NotificationId + "\"\n" + + "\t\"subscription\":\"" +arg() + "\"\n" + "}"; } + + @Override + public Map<String,String> getOsduTenantHeaders(){ + Map<String, String> headers = new HashMap<>(); + headers.put("data-partition-id", Config.Instance().ClientTenant); + return headers; + } + + @Override + public Map<String,String> getCustomerTenantHeaders(){ + Map<String, String> headers = new HashMap<>(); + headers.put("data-partition-id", Config.Instance().ClientTenant); + return headers; + } } diff --git a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACDescriptor.java b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACDescriptor.java index f0f2e601a56cf5ceaef7b5138cdfc588a1cd2ad4..ea4553e869dba9377b42ace30c892b597335e3b0 100644 --- a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACDescriptor.java +++ b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACDescriptor.java @@ -16,9 +16,13 @@ package org.opengroup.osdu.notification.api; +import org.opengroup.osdu.notification.util.Config; import org.opengroup.osdu.notification.util.RestDescriptor; import org.opengroup.osdu.notification.util.TestUtils; +import java.util.HashMap; +import java.util.Map; + public class PubsubEndpointHMACDescriptor extends RestDescriptor { @Override @@ -45,4 +49,18 @@ public class PubsubEndpointHMACDescriptor extends RestDescriptor { "\t\"subscription\": \""+ arg() +"\"\n" + "}\n"; } + + @Override + public Map<String,String> getOsduTenantHeaders(){ + Map<String, String> headers = new HashMap<>(); + headers.put("data-partition-id", Config.Instance().ClientTenant); + return headers; + } + + @Override + public Map<String,String> getCustomerTenantHeaders(){ + Map<String, String> headers = new HashMap<>(); + headers.put("data-partition-id", Config.Instance().ClientTenant); + return headers; + } } diff --git a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACTests.java b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACTests.java index 98429acbcc16c1e930e9d15a548dc7c39db76df0..20094465104e331a08c1dfb1174573e658f7c29f 100644 --- a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACTests.java +++ b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpointHMACTests.java @@ -92,6 +92,8 @@ public abstract class PubsubEndpointHMACTests extends BaseTestTemplate { Subscription subscriptionCreated = subscriptionService.create(subscription); notificationId = subscriptionCreated.getNotificationId(); subscriptionId = subscriptionCreated.getId(); + + Config.Instance().NotificationId = notificationId; } @Override diff --git a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/RestDescriptor.java b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/RestDescriptor.java index e39016791013f2570f1a181fda47bec50adce8a6..38690fc885965e34570151a04883230632f48c86 100644 --- a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/RestDescriptor.java +++ b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/RestDescriptor.java @@ -18,6 +18,8 @@ package org.opengroup.osdu.notification.util; import com.sun.jersey.api.client.ClientResponse; +import java.util.Map; + public abstract class RestDescriptor { public RestDescriptor() { @@ -30,22 +32,24 @@ public abstract class RestDescriptor { public abstract String getPath(); public abstract String getHttpMethod(); public abstract String getValidBody(); + public abstract Map<String,String> getOsduTenantHeaders(); + public abstract Map<String,String> getCustomerTenantHeaders(); public String getQuery() { return ""; } public ClientResponse runHttp(String arg, String token) throws Exception{ this.arg = arg; - return TestUtils.send(getPath(), getHttpMethod(), token, getValidBody(), getQuery(), true); + return TestUtils.send(getPath(), getHttpMethod(), token, getValidBody(), getQuery(), getOsduTenantHeaders(),true); } public ClientResponse run(String arg, String token) throws Exception{ this.arg = arg; - return TestUtils.send(getPath(), getHttpMethod(), token, getValidBody(), getQuery(), false); + return TestUtils.send(getPath(), getHttpMethod(), token, getValidBody(), getQuery(), getOsduTenantHeaders(),false); } public ClientResponse runOnCustomerTenant(String arg, String token) throws Exception{ this.arg = arg; - return TestUtils.send(getPath(), getHttpMethod(), token, getValidBody(), getQuery(), TestUtils.getCustomerTenantHeaders(), false); + return TestUtils.send(getPath(), getHttpMethod(), token, getValidBody(), getQuery(), getCustomerTenantHeaders(), false); } public ClientResponse runOptions(String arg, String token) throws Exception{ this.arg = arg; - return TestUtils.send(getPath(), "OPTIONS", token, "", "", false); + return TestUtils.send(getPath(), "OPTIONS", token, "", "", getOsduTenantHeaders(),false); } } \ No newline at end of file diff --git a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/TestUtils.java b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/TestUtils.java index 43100436180da85d09bfccebf5f3629d23bcf311..393089845fdad198817e00950eb9e7300dd7ff84 100644 --- a/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/TestUtils.java +++ b/testing/notification-test-core/src/main/java/org/opengroup/osdu/notification/util/TestUtils.java @@ -62,27 +62,6 @@ public abstract class TestUtils { public abstract String getEditorToken() throws Exception; public abstract String getNoAccessToken() throws Exception; - - public static ClientResponse send(String path, String httpMethod, String token, String requestBody, String query, boolean enforceHttp) - throws Exception { - - Map<String, String> headers = getOsduTenantHeaders(); - - return send(path, httpMethod, token, requestBody, query, headers, enforceHttp); - } - - public static Map<String, String> getOsduTenantHeaders() { - Map<String, String> headers = new HashMap<>(); - headers.put("data-partition-id", getOsduTenant()); - return headers; - } - - public static Map<String, String> getCustomerTenantHeaders() { - Map<String, String> headers = new HashMap<>(); - headers.put("data-partition-id", getCustomerTenant()); - return headers; - } - public static ClientResponse send(String path, String httpMethod, String token, String requestBody, String query, Map<String,String> headers, boolean enforceHttp) throws Exception {