diff --git a/.gitlab/merge_request_templates/default.md b/.gitlab/merge_request_templates/default.md new file mode 100644 index 0000000000000000000000000000000000000000..30b5728265169035761fddd28062b2664024c71d --- /dev/null +++ b/.gitlab/merge_request_templates/default.md @@ -0,0 +1,25 @@ +## Type of change +- [ ] Bug Fix +- [ ] Feature + +**Please provide link to gitlab issue or ADR(Architecture Decision Record)** + +## Does this introduce a change in the core logic? +- [YES/NO] + +## Does this introduce a change in the cloud provider implementation, if so which cloud? +- [ ] AWS +- [ ] Azure +- [ ] GCP +- [ ] IBM + +## Does this introduce a breaking change? +- [YES/NO] + +## What is the current behavior? + +## What is the new/expected behavior? + +## Have you added/updated Unit Tests and Integration Tests? + +## Any other useful information diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java b/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java index 975d66958a16e46da89103d1441d97219be42fe1..89a3376a13fccbd420fbdd17a75189cbc9f6776e 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/api/PubsubEndpoint.java @@ -36,7 +36,7 @@ import org.opengroup.osdu.core.common.notification.SubscriptionException; import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java index c720b2d5c9f10d34d48f91b9abb68f9eef38c421..36bfc80393762c8fcee8abd64a82c39dda253e48 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationFilter.java @@ -23,7 +23,7 @@ import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService; import org.opengroup.osdu.notification.di.RequestInfoExt; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.web.context.annotation.RequestScope; @@ -40,7 +40,7 @@ public class AuthorizationFilter { @Autowired private RequestInfoExt requestInfoExt; @Autowired - private ServiceAccountValidator validator; + private IServiceAccountValidator validator; public boolean hasAnyPermission(String... requiredRoles) { DpsHeaders dpsHeaders = requestInfoExt.getHeaders(); diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java index efd7a908ed9e536d9e9ece3fe4e22dae127b4d33..53a5427d160a4abb8949c8cfbd55274ea19c5eb0 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/auth/EntitlementsClientFactory.java @@ -19,7 +19,7 @@ package org.opengroup.osdu.notification.auth; import org.opengroup.osdu.core.common.entitlements.EntitlementsAPIConfig; import org.opengroup.osdu.core.common.entitlements.EntitlementsFactory; import org.opengroup.osdu.core.common.entitlements.IEntitlementsFactory; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.stereotype.Component; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java b/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java index f27e7815c3f1a3b575e70a070a18a017ea7f9b02..24b6646c8b93cb795ba8fedb04e9ade785d65788 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/di/CredentialHeadersProvider.java @@ -18,7 +18,6 @@ package org.opengroup.osdu.notification.di; import org.opengroup.osdu.core.common.model.http.DpsHeaders; import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; -import org.opengroup.osdu.notification.utils.IAppProperties; import org.springframework.beans.factory.FactoryBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Primary; diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java b/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java index b367f7fc1eec6639e0766b44922a5e88e488f5a4..feda29e96750cec68e9d1c9bb33db65e9767233a 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/di/SubscriptionClientFactory.java @@ -16,17 +16,13 @@ package org.opengroup.osdu.notification.di; +import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; import org.opengroup.osdu.core.common.notification.SubscriptionAPIConfig; import org.opengroup.osdu.core.common.notification.SubscriptionFactory; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.AbstractFactoryBean; -import org.springframework.beans.factory.config.ConfigurableBeanFactory; -import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; -import org.opengroup.osdu.core.common.notification.ISubscriptionFactory; -import org.opengroup.osdu.core.common.model.notification.*; @Component public class SubscriptionClientFactory extends AbstractFactoryBean<ISubscriptionFactory> { diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationService.java b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java similarity index 74% rename from notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationService.java rename to notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java index 24b05695a8862d897a61a832d5fecf7213e2743f..c5bf01120a9e3f9fbb0b1da63ad73d6472d826a0 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/auth/AuthorizationService.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IAppProperties.java @@ -14,10 +14,11 @@ * limitations under the License. */ -package org.opengroup.osdu.notification.auth; +package org.opengroup.osdu.notification.provider.interfaces; -import org.opengroup.osdu.core.common.model.http.DpsHeaders; +public interface IAppProperties { -public interface AuthorizationService { - String authorizeAny(DpsHeaders headers, String... roles); -} + String getAuthorizeAPI(); + + String getRegisterAPI(); +} \ No newline at end of file diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/IGoogleServiceAccount.java b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java similarity index 92% rename from notification-core/src/main/java/org/opengroup/osdu/notification/utils/IGoogleServiceAccount.java rename to notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java index ae067a8a9fdf7c4aa3306945161349a21f734e85..33628ba3df8ab160b647a5cd69dbe5d0ef477d38 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/IGoogleServiceAccount.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IGoogleServiceAccount.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package org.opengroup.osdu.notification.utils; +package org.opengroup.osdu.notification.provider.interfaces; public interface IGoogleServiceAccount { diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/ServiceAccountValidator.java b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IServiceAccountValidator.java similarity index 87% rename from notification-core/src/main/java/org/opengroup/osdu/notification/utils/ServiceAccountValidator.java rename to notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IServiceAccountValidator.java index 1491eba4fb1b320a01ffa8f45d249ec1499b9927..3b36bb1de5386413fac23f5d617899735c3cf1cc 100644 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/ServiceAccountValidator.java +++ b/notification-core/src/main/java/org/opengroup/osdu/notification/provider/interfaces/IServiceAccountValidator.java @@ -14,9 +14,10 @@ * limitations under the License. */ -package org.opengroup.osdu.notification.utils; +package org.opengroup.osdu.notification.provider.interfaces; + +public interface IServiceAccountValidator { -public interface ServiceAccountValidator { boolean isValidPublisherServiceAccount(String jwt); boolean isValidServiceAccount(String jwt, String userIdentity, String... audiences); diff --git a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/IAppProperties.java b/notification-core/src/main/java/org/opengroup/osdu/notification/utils/IAppProperties.java deleted file mode 100644 index 16049cc1078b16103f61a82dfdf214a729fef2ac..0000000000000000000000000000000000000000 --- a/notification-core/src/main/java/org/opengroup/osdu/notification/utils/IAppProperties.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.opengroup.osdu.notification.utils; - -public interface IAppProperties { - String getAuthorizeAPI(); - - String getRegisterAPI(); -} \ No newline at end of file diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java b/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java index 67b9a4a813675698e8e57f07651102c762505dc1..d3155489b3a8e6948fdb4e45e1dc43c90c2d6ab0 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/api/PubsubEndpointTests.java @@ -37,7 +37,7 @@ import org.opengroup.osdu.core.common.notification.SubscriptionService; import org.opengroup.osdu.notification.di.CredentialHeadersProvider; import org.opengroup.osdu.notification.di.SubscriptionCacheFactory; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.powermock.modules.junit4.PowerMockRunner; import org.springframework.http.ResponseEntity; diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java index c73e87d111a18a0e8077604389a2c8e396eb9c8b..50a46790c9789b4d9257833fa0437771aca0eb40 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/auth/AuthorizationFilterTest.java @@ -28,7 +28,7 @@ import org.opengroup.osdu.core.common.provider.interfaces.IAuthorizationService; import org.opengroup.osdu.notification.di.RequestInfoExt; import org.opengroup.osdu.notification.pubsub.PubsubRequestBodyExtractor; import org.opengroup.osdu.notification.utils.Config; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator; import org.powermock.modules.junit4.PowerMockRunner; import java.util.HashMap; @@ -57,7 +57,7 @@ public class AuthorizationFilterTest { @Mock private IAuthorizationService authorizationService; @Mock - private ServiceAccountValidator validator; + private IServiceAccountValidator validator; @Mock private PubsubRequestBodyExtractor extractor; @InjectMocks diff --git a/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java b/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java index 2518ce8e1adc8a6d9551b48cdff5462508b50122..a0a7d4814d7c96e1bbe137188c7b28225fc8cd76 100644 --- a/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java +++ b/notification-core/src/test/java/org/opengroup/osdu/notification/di/RequestInfoTest.java @@ -20,7 +20,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.powermock.modules.junit4.PowerMockRunner; import javax.servlet.http.HttpServletRequest; diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AppProperties.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AppProperties.java index 10bac0d15fe8959c487a1922a75d2c3e122a1fda..8d751e083b69e353ce87938107eaaf3ade42c426 100644 --- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AppProperties.java +++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AppProperties.java @@ -19,7 +19,7 @@ import com.azure.cosmos.CosmosClient; import com.azure.security.keyvault.secrets.SecretClient; import com.azure.security.keyvault.secrets.models.KeyVaultSecret; import org.opengroup.osdu.azure.KeyVaultFacade; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AzureServiceAccountValidatorImpl.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AzureServiceAccountValidatorImpl.java index 7f153b36451596108a2acf6b46725d54269e6ef1..971666dd829edb794bcaac7fa7cfab32d56eafc8 100644 --- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AzureServiceAccountValidatorImpl.java +++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/AzureServiceAccountValidatorImpl.java @@ -14,11 +14,11 @@ package org.opengroup.osdu.notification.provider.azure.util; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator; import org.springframework.stereotype.Component; @Component -public class AzureServiceAccountValidatorImpl implements ServiceAccountValidator { +public class AzureServiceAccountValidatorImpl implements IServiceAccountValidator { @Override public boolean isValidPublisherServiceAccount(String jwt) { diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java index ed463192657c89e753cd19acb7b6664ec34d33bf..9b0adf6c0906062a7bacad1c5e516def27b60ea7 100644 --- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java +++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/GoogleServiceAccountImpl.java @@ -15,7 +15,7 @@ package org.opengroup.osdu.notification.provider.azure.util; import lombok.SneakyThrows; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.springframework.stereotype.Component; import javax.naming.AuthenticationNotSupportedException; diff --git a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java index 19789adf6ba239bb6a6acc0f532b2a69c6459e09..1aa85c59dc6133074d6e2c55e025c558f8f238f1 100644 --- a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java +++ b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/AppProperties.java @@ -16,7 +16,7 @@ package org.opengroup.osdu.notification.provider.gcp.util; -import org.opengroup.osdu.notification.utils.IAppProperties; +import org.opengroup.osdu.notification.provider.interfaces.IAppProperties; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java index 7dcf3ba6627812a71e7c27de7530d78f83125c6f..1555ab181b10abe173a290752a13ed0628f7409d 100644 --- a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java +++ b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountImpl.java @@ -19,7 +19,7 @@ package org.opengroup.osdu.notification.provider.gcp.util; import lombok.SneakyThrows; import org.apache.http.impl.client.CloseableHttpClient; import org.opengroup.osdu.core.gcp.GoogleIdToken.IGoogleIdTokenFactory; -import org.opengroup.osdu.notification.utils.IGoogleServiceAccount; +import org.opengroup.osdu.notification.provider.interfaces.IGoogleServiceAccount; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java index 2d70b3d3c601a05a508dc9f7524ac9b4ac76b976..3a1736a921a1f0b89ec123da25166804a2e12d53 100644 --- a/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java +++ b/provider/notification-gcp/src/main/java/org/opengroup/osdu/notification/provider/gcp/util/GoogleServiceAccountValidatorImpl.java @@ -21,12 +21,12 @@ import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier; import com.google.api.client.http.javanet.NetHttpTransport; import com.google.api.client.json.jackson2.JacksonFactory; import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; -import org.opengroup.osdu.notification.utils.ServiceAccountValidator; +import org.opengroup.osdu.notification.provider.interfaces.IServiceAccountValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @Service -public class GoogleServiceAccountValidatorImpl implements ServiceAccountValidator { +public class GoogleServiceAccountValidatorImpl implements IServiceAccountValidator { private final NetHttpTransport netHttpTransport = new NetHttpTransport(); private final JacksonFactory jacksonFactory = new JacksonFactory();