diff --git a/NOTICE b/NOTICE index 85c850a6973b0c1558848471b614b82b213ea195..c02515ca00fa6c828bf8dd365a1969133c11ff33 100644 --- a/NOTICE +++ b/NOTICE @@ -17,20 +17,6 @@ The following software have components provided under the terms of this license: - AMQP 1.0 JMS Spring Boot AutoConfiguration (from https://repo1.maven.org/maven2/org/amqphub/spring/amqp-10-jms-spring-boot-autoconfigure) - AMQP 1.0 JMS Spring Boot Starter (from https://repo1.maven.org/maven2/org/amqphub/spring/amqp-10-jms-spring-boot-starter) - ASM based accessors helper used by json-smart (from ) -- AWS Event Stream (from https://github.com/awslabs/aws-eventstream-java) -- AWS Java SDK :: AWS Core (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Annotations (from https://repo1.maven.org/maven2/software/amazon/awssdk/annotations) -- AWS Java SDK :: Auth (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Core :: Protocols :: AWS Json Protocol (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Core :: Protocols :: Protocol Core (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: HTTP Client Interface (from https://repo1.maven.org/maven2/software/amazon/awssdk/http-client-spi) -- AWS Java SDK :: HTTP Clients :: Apache (from https://repo1.maven.org/maven2/software/amazon/awssdk/apache-client) -- AWS Java SDK :: HTTP Clients :: Netty Non-Blocking I/O (from https://repo1.maven.org/maven2/software/amazon/awssdk/netty-nio-client) -- AWS Java SDK :: Profiles (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Regions (from https://repo1.maven.org/maven2/software/amazon/awssdk/regions) -- AWS Java SDK :: SDK Core (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Services :: AWS Simple Systems Management (SSM) (from https://aws.amazon.com/sdkforjava) -- AWS Java SDK :: Utilities (from https://repo1.maven.org/maven2/software/amazon/awssdk/utils) - AWS Java SDK for AWS Elemental MediaLive (from https://aws.amazon.com/sdkforjava) - AWS Java SDK for AWS KMS (from https://aws.amazon.com/sdkforjava) - AWS Java SDK for AWS Lambda (from https://aws.amazon.com/sdkforjava) @@ -125,17 +111,17 @@ The following software have components provided under the terms of this license: - Jackson 2 extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson2) - Jackson dataformat: CBOR (from http://github.com/FasterXML/jackson-dataformats-binary) - Jackson datatype: JSR310 (from http://wiki.fasterxml.com/JacksonModuleJSR310) -- Jackson datatype: Joda (from https://github.com/FasterXML/jackson-datatype-joda) - Jackson datatype: jdk8 (from https://repo1.maven.org/maven2/com/fasterxml/jackson/datatype/jackson-datatype-jdk8) - Jackson extensions to the Google HTTP Client Library for Java. (from https://repo1.maven.org/maven2/com/google/http-client/google-http-client-jackson) - Jackson module: Afterburner (from https://github.com/FasterXML/jackson-modules-base) -- Jackson module: Old JAXB Annotations (javax.xml.bind) (from https://github.com/FasterXML/jackson-modules-base) +- Jackson module: JAXB-annotations (from http://github.com/FasterXML/jackson-module-jaxb-annotations) - Jackson-annotations (from http://github.com/FasterXML/jackson) - Jackson-core (from https://github.com/FasterXML/jackson-core) - Jackson-core (from https://github.com/FasterXML/jackson-core) - Jackson-dataformat-Smile (from http://wiki.fasterxml.com/JacksonForSmile) -- Jackson-dataformat-XML (from https://github.com/FasterXML/jackson-dataformat-xml) +- Jackson-dataformat-XML (from http://wiki.fasterxml.com/JacksonExtensionXmlDataBinding) - Jackson-dataformat-YAML (from https://github.com/FasterXML/jackson-dataformats-text) +- Jackson-datatype-JODA (from http://wiki.fasterxml.com/JacksonModuleJoda) - Jackson-module-parameter-names (from https://repo1.maven.org/maven2/com/fasterxml/jackson/module/jackson-module-parameter-names) - Jakarta Bean Validation API (from https://beanvalidation.org) - Jakarta Expression Language Implementation (from https://projects.eclipse.org/projects/ee4j.el) @@ -183,8 +169,6 @@ The following software have components provided under the terms of this license: - Microsoft Azure Netty HTTP Client Library (from https://github.com/Azure/azure-sdk-for-java) - Microsoft Azure SDK for SQL API of Azure Cosmos DB Service (from https://github.com/Azure/azure-sdk-for-java) - Mockito (from http://www.mockito.org) -- Netty Reactive Streams HTTP support (from https://repo1.maven.org/maven2/com/typesafe/netty/netty-reactive-streams-http) -- Netty Reactive Streams Implementation (from https://repo1.maven.org/maven2/com/typesafe/netty/netty-reactive-streams) - Netty/Buffer (from https://repo1.maven.org/maven2/io/netty/netty-buffer) - Netty/Buffer (from https://repo1.maven.org/maven2/io/netty/netty-buffer) - Netty/Codec (from https://repo1.maven.org/maven2/io/netty/netty-codec) @@ -214,10 +198,11 @@ The following software have components provided under the terms of this license: - Nimbus JOSE+JWT (from https://bitbucket.org/connect2id/nimbus-jose-jwt) - Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags) - Nimbus LangTag (from https://bitbucket.org/connect2id/nimbus-language-tags) -- Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor-core) +- Non-Blocking Reactive Foundation for the JVM (from https://github.com/reactor/reactor) - OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) - OAuth 2.0 SDK with OpenID Connect extensions (from https://bitbucket.org/connect2id/oauth-2.0-sdk-with-openid-connect-extensions) - Objenesis (from http://objenesis.org) +- OkHttp Logging Interceptor (from https://repo1.maven.org/maven2/com/squareup/okhttp3/logging-interceptor) - Okio (from https://github.com/square/okio/) - Okio (from https://github.com/square/okio/) - OpenCensus (from https://github.com/census-instrumentation/opencensus-java) @@ -238,7 +223,6 @@ The following software have components provided under the terms of this license: - SnakeYAML (from http://www.snakeyaml.org) - Spring AOP (from https://github.com/spring-projects/spring-framework) - Spring Beans (from https://github.com/spring-projects/spring-framework) -- Spring Boot Log4j 2 Starter (from http://projects.spring.io/spring-boot/) - Spring Boot Tomcat Starter (from https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-starters/spring-boot-starter-tomcat) - Spring Commons Logging Bridge (from https://github.com/spring-projects/spring-framework) - Spring Context (from https://github.com/spring-projects/spring-framework) @@ -269,17 +253,17 @@ The following software have components provided under the terms of this license: - XNIO API (from http://www.jboss.org/xnio) - XNIO NIO Implementation (from https://repo1.maven.org/maven2/org/jboss/xnio/xnio-nio) - XNIO NIO Implementation (from https://repo1.maven.org/maven2/org/jboss/xnio/xnio-nio) -- Zipkin Core Library (from https://repo1.maven.org/maven2/io/zipkin/zipkin2/zipkin) - Zipkin Reporter Brave (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter-brave) - Zipkin Reporter: Core (from https://repo1.maven.org/maven2/io/zipkin/reporter2/zipkin-reporter) +- Zipkin v2 (from https://repo1.maven.org/maven2/io/zipkin/zipkin2/zipkin) - aalto-xml (from ) - aggs-matrix-stats (from https://github.com/elastic/elasticsearch) - asm (from http://asm.ow2.io/) -- aws-ssm-java-caching-client (from https://github.com/awslabs/aws-ssm-java-caching-client) - cli (from https://github.com/elastic/elasticsearch) - com.google.api.grpc:proto-google-cloud-datastore-v1 (from https://github.com/googleapis/googleapis) - compiler (from http://github.com/spullara/mustache.java) - core (from https://github.com/elastic/elasticsearch) +- core (from https://github.com/elastic/elasticsearch) - datastore-v1-proto-client (from https://repo1.maven.org/maven2/com/google/cloud/datastore/datastore-v1-proto-client) - error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) - error-prone annotations (from https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations) @@ -311,7 +295,6 @@ The following software have components provided under the terms of this license: - jose4j (from https://bitbucket.org/b_c/jose4j/) - lang-mustache (from https://github.com/elastic/elasticsearch) - lettuce (from http://github.com/mp911de/lettuce/wiki) -- logging-interceptor (from https://github.com/square/okhttp) - micrometer-core (from https://github.com/micrometer-metrics/micrometer) - micrometer-registry-azure-monitor (from https://github.com/micrometer-metrics/micrometer) - mockito-core (from https://github.com/mockito/mockito) @@ -332,23 +315,22 @@ The following software have components provided under the terms of this license: - proto-google-cloud-iamcredentials-v1 (from https://github.com/googleapis/java-iamcredentials/proto-google-cloud-iamcredentials-v1) - proto-google-cloud-logging-v2 (from https://repo1.maven.org/maven2/com/google/api/grpc/proto-google-cloud-logging-v2) - proto-google-cloud-pubsub-v1 (from https://github.com/googleapis/java-pubsub/proto-google-cloud-pubsub-v1) -- proto-google-common-protos (from https://github.com/googleapis/api-client-staging) -- proto-google-common-protos (from https://github.com/googleapis/api-client-staging) +- proto-google-common-protos (from https://github.com/googleapis/java-iam/proto-google-common-protos) +- proto-google-common-protos (from https://github.com/googleapis/java-iam/proto-google-common-protos) - proto-google-iam-v1 (from https://github.com/googleapis/java-iam/proto-google-iam-v1) - rank-eval (from https://github.com/elastic/elasticsearch) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io) -- resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://resilience4j.readme.io) - resilience4j (from https://github.com/resilience4j/resilience4j) - resilience4j (from https://resilience4j.readme.io) +- resilience4j (from https://github.com/resilience4j/resilience4j) - rest (from https://github.com/elastic/elasticsearch) - rest-high-level (from https://github.com/elastic/elasticsearch) - rxjava (from https://github.com/ReactiveX/RxJava) - secure-sm (from https://github.com/elastic/elasticsearch) -- server (from https://github.com/elastic/elasticsearch) - spring-boot (from https://spring.io/projects/spring-boot) - spring-boot-actuator (from https://spring.io/projects/spring-boot) - spring-boot-actuator-autoconfigure (from https://spring.io/projects/spring-boot) @@ -358,6 +340,7 @@ The following software have components provided under the terms of this license: - spring-boot-starter-actuator (from https://spring.io/projects/spring-boot) - spring-boot-starter-aop (from https://spring.io/projects/spring-boot) - spring-boot-starter-json (from https://spring.io/projects/spring-boot) +- spring-boot-starter-log4j2 (from https://spring.io/projects/spring-boot) - spring-boot-starter-logging (from https://spring.io/projects/spring-boot) - spring-boot-starter-reactor-netty (from https://spring.io/projects/spring-boot) - spring-boot-starter-security (from https://spring.io/projects/spring-boot) @@ -371,14 +354,14 @@ The following software have components provided under the terms of this license: - spring-boot-starter-webflux (from https://spring.io/projects/spring-boot) - spring-boot-test (from https://spring.io/projects/spring-boot) - spring-boot-test-autoconfigure (from https://spring.io/projects/spring-boot) -- spring-security-config (from http://spring.io/spring-security) -- spring-security-config (from http://spring.io/spring-security) -- spring-security-core (from http://spring.io/spring-security) -- spring-security-oauth2-core (from http://spring.io/spring-security) -- spring-security-oauth2-jose (from http://spring.io/spring-security) -- spring-security-oauth2-resource-server (from http://spring.io/spring-security) -- spring-security-web (from http://spring.io/spring-security) -- spring-security-web (from http://spring.io/spring-security) +- spring-security-config (from https://spring.io/spring-security) +- spring-security-config (from https://spring.io/spring-security) +- spring-security-core (from https://spring.io/spring-security) +- spring-security-oauth2-core (from https://spring.io/spring-security) +- spring-security-oauth2-jose (from https://spring.io/spring-security) +- spring-security-oauth2-resource-server (from https://spring.io/spring-security) +- spring-security-web (from https://spring.io/spring-security) +- spring-security-web (from https://spring.io/spring-security) - springfox-core (from https://github.com/springfox/springfox) - springfox-schema (from https://github.com/springfox/springfox) - springfox-spi (from https://github.com/springfox/springfox) @@ -391,7 +374,7 @@ The following software have components provided under the terms of this license: - swagger-models (from https://repo1.maven.org/maven2/io/swagger/swagger-models) - tomcat-embed-core (from http://tomcat.apache.org/) - tomcat-embed-el (from https://tomcat.apache.org/) -- tomcat-embed-websocket (from https://tomcat.apache.org/) +- tomcat-embed-websocket (from http://tomcat.apache.org/) - wildfly-common (from ) - x-content (from https://github.com/elastic/elasticsearch) @@ -406,7 +389,7 @@ The following software have components provided under the terms of this license: - GAX (Google Api eXtensions) for Java (from https://github.com/googleapis/gax-java) - Lucene Common Analyzers (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-analyzers-common) - Lucene Core (from https://repo1.maven.org/maven2/org/apache/lucene/lucene-core) -- Reflections (from http://github.com/ronmamo/reflections) +- Reflections (from http://code.google.com/p/reflections/) - Stax2 API (from http://github.com/FasterXML/stax2-api) - ThreeTen backport (from https://www.threeten.org/threetenbp) @@ -435,7 +418,7 @@ The following software have components provided under the terms of this license: - Protocol Buffers [Core] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java) - Protocol Buffers [Core] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java) - Protocol Buffers [Util] (from https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java-util) -- Reflections (from http://github.com/ronmamo/reflections) +- Reflections (from http://code.google.com/p/reflections/) - SnakeYAML (from http://www.snakeyaml.org) - Spring Core (from https://github.com/spring-projects/spring-framework) - ThreeTen backport (from https://www.threeten.org/threetenbp) @@ -722,7 +705,7 @@ The following software have components provided under the terms of this license: - mockito-junit-jupiter (from https://github.com/mockito/mockito) - msal4j (from https://github.com/AzureAD/microsoft-authentication-library-for-java) - msal4j-persistence-extension (from https://github.com/AzureAD/microsoft-authentication-extensions-for-java) -- spring-security-core (from http://spring.io/spring-security) +- spring-security-core (from https://spring.io/spring-security) ======================================================================== MPL-1.1 @@ -777,7 +760,7 @@ WTFPL ======================================================================== The following software have components provided under the terms of this license: -- Reflections (from http://github.com/ronmamo/reflections) +- Reflections (from http://code.google.com/p/reflections/) ======================================================================== X11 @@ -791,7 +774,6 @@ public-domain ======================================================================== The following software have components provided under the terms of this license: -- AWS Java SDK :: SDK Core (from https://aws.amazon.com/sdkforjava) - Asynchronous Http Client (from https://repo1.maven.org/maven2/org/asynchttpclient/async-http-client) - Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) - Guava: Google Core Libraries for Java (from https://repo1.maven.org/maven2/com/google/guava/guava) diff --git a/devops/azure/chart/helm-config.yaml b/devops/azure/chart/helm-config.yaml index 9323d6f1afcf141b010c15d465491515ba8de25c..9d27a76c95b777c35b13c5d29641ef63d52ed26d 100644 --- a/devops/azure/chart/helm-config.yaml +++ b/devops/azure/chart/helm-config.yaml @@ -17,6 +17,8 @@ global: # Service(s) Replica Count replicaCount: 1 + nodepool: services + isAutoscalingEnabled: false ################################################################################ # Specify the Gitlab branch being used for image creation diff --git a/devops/azure/chart/templates/authSB.yaml b/devops/azure/chart/templates/authSB.yaml new file mode 100644 index 0000000000000000000000000000000000000000..50e54fb1281dc4c6759c1d4327b16325ffbcb258 --- /dev/null +++ b/devops/azure/chart/templates/authSB.yaml @@ -0,0 +1,33 @@ +# Source: istio/templates/notification.yaml +# Copyright © Microsoft Corporation +# +# 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 +# +# 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. + +apiVersion: security.istio.io/v1beta1 +kind: AuthorizationPolicy +metadata: + name: notification-sb-jwt-authz + namespace: osdu +spec: + selector: + matchLabels: + app: notification-sb + action: DENY + rules: + - from: + - source: + notRequestPrincipals: ["*"] + to: + - operation: + notPaths: ["/","*/swagger-resources","*/swagger", + "/api/notification/v1/swagger-resources/*","*/swagger-ui.html","*/actuator/health"] \ No newline at end of file diff --git a/devops/azure/chart/templates/deployment.yaml b/devops/azure/chart/templates/deployment.yaml index 4651e38c7b35cae5c9035d01d44d268153597b44..a6f9651b77df6cc74a70074ced49168103aaca52 100644 --- a/devops/azure/chart/templates/deployment.yaml +++ b/devops/azure/chart/templates/deployment.yaml @@ -28,6 +28,10 @@ spec: app: {{ .Chart.Name }} aadpodidbinding: osdu-identity spec: +{{- if .Values.global.isAutoscalingEnabled }} + nodeSelector: + nodepool: {{ .Values.global.nodepool }} +{{- end }} volumes: - name: azure-keyvault csi: diff --git a/devops/azure/chart/templates/deploymentSB.yaml b/devops/azure/chart/templates/deploymentSB.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e254ef27454ef8ef09ddec45304a26da3ba0e46f --- /dev/null +++ b/devops/azure/chart/templates/deploymentSB.yaml @@ -0,0 +1,105 @@ +# Copyright © Microsoft Corporation +# +# 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 +# +# 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. + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-sb + namespace: osdu +spec: + replicas: {{ .Values.global.replicaCount }} + selector: + matchLabels: + app: {{ .Chart.Name }}-sb + template: + metadata: + labels: + app: {{ .Chart.Name }}-sb + aadpodidbinding: osdu-identity + spec: + volumes: + - name: azure-keyvault + csi: + driver: secrets-store.csi.k8s.io + readOnly: true + volumeAttributes: + secretProviderClass: azure-keyvault + containers: + - name: {{ .Chart.Name }}-sb + image: {{ .Values.image.repository }}/{{ .Chart.Name }}-{{ .Values.image.branch }}:{{ .Values.image.tag | default .Chart.AppVersion }} + imagePullPolicy: Always + ports: + - containerPort: 81 + readinessProbe: + httpGet: + path: /api/notification/v1/swagger-ui.html + port: 81 + volumeMounts: + - name: azure-keyvault + mountPath: "/mnt/azure-keyvault" + readOnly: true + env: + - name: spring_application_name + value: notification-sb-azure + - name: LOG_PREFIX + value: "notification-sb" + - name: server.servlet.contextPath + value: /api/notification/v1 + - name: server_port + value: "81" + - name: notification_spring_logging_level + value: INFO + - name: KEYVAULT_URI + valueFrom: + configMapKeyRef: + name: osdu-svc-properties + key: ENV_KEYVAULT + - name: aad_client_id + valueFrom: + secretKeyRef: + name: active-directory + key: application-appid + - name: appinsights_key + valueFrom: + secretKeyRef: + name: central-logging + key: appinsights + - name: cosmosdb_database + value: osdu-db + - name: entitlements_service_endpoint + value: http://entitlements/api/entitlements/v2 + - name: entitlements_service_api_key + value: "OBSOLETE" + - name: registeration_service_endpoint + value: http://register/api/register/v1 + - name: partition_service_endpoint + value: http://partition/api/partition/v1 + - name: maxCacheSize + value: "20" + - name: max_concurrent_calls + value: "3" + - name: executor_n_threads + value: "32" + - name: max_lock_renew_duration_seconds + value: "500" + - name: initial_subscription_manager_delay_seconds + value: "0" + - name: consecutive_subscription_manager_delay_seconds + value: "600" + - name: service_bus_enabled + value: "true" + - name: event_grid_to_service_bus_enabled + value: "false" + - name: event_grid_enabled + value: "false" \ No newline at end of file diff --git a/devops/azure/chart/templates/serviceSB.yaml b/devops/azure/chart/templates/serviceSB.yaml new file mode 100644 index 0000000000000000000000000000000000000000..616d3e28c07a0ef0695c940f903d61b0454ba25b --- /dev/null +++ b/devops/azure/chart/templates/serviceSB.yaml @@ -0,0 +1,27 @@ +# Copyright © Microsoft Corporation +# +# 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 +# +# 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. + +apiVersion: v1 +kind: Service +metadata: + name: {{ .Chart.Name }}-sb + namespace: osdu +spec: + type: ClusterIP + ports: + - protocol: TCP + port: 81 + targetPort: 81 + selector: + app: {{ .Chart.Name }}-sb \ No newline at end of file diff --git a/devops/azure/chart/values.yaml b/devops/azure/chart/values.yaml index d503dd73deaa4d89c63c0bc034cac4354c4970b2..67b3587256eb3e1928d86447bf7d58c84813ced9 100644 --- a/devops/azure/chart/values.yaml +++ b/devops/azure/chart/values.yaml @@ -14,8 +14,10 @@ global: replicaCount: 1 + nodepool: services + isAutoscalingEnabled: false image: repository: community.opengroup.org:5555/osdu/platform/system/notification branch: master - tag: latest \ No newline at end of file + tag: latest diff --git a/notification-core/pom.xml b/notification-core/pom.xml index de0485a83f4b62ab52d668ba42b6c852574b6b09..b6f2e702fdcdb8a755d6e3890e08f7288063acb4 100644 --- a/notification-core/pom.xml +++ b/notification-core/pom.xml @@ -19,7 +19,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-core</name> <description>Core module for the notification service</description> <packaging>jar</packaging> @@ -27,7 +27,7 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/pom.xml b/pom.xml index 51b34af47a950def696954f7709d7642ec0e0a35..e180807493e1a530dab432b12edad3c254c5bc00 100644 --- a/pom.xml +++ b/pom.xml @@ -18,14 +18,14 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <description>Root Notification Service project</description> <properties> <java.version>8</java.version> <maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.source>${java.version}</maven.compiler.source> - <os-core-common.version>0.11.0-SNAPSHOT</os-core-common.version> + <os-core-common.version>0.11.0</os-core-common.version> </properties> <licenses> diff --git a/provider/notification-aws/pom.xml b/provider/notification-aws/pom.xml index a586f4aaf721cecd034111c3ebe1541904ebfd26..ff238277d58b6aae0506a19021bb1f318c4c5c12 100644 --- a/provider/notification-aws/pom.xml +++ b/provider/notification-aws/pom.xml @@ -19,7 +19,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-aws</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-aws</name> <description>AWS implementation for Notification service</description> <packaging>jar</packaging> @@ -27,7 +27,7 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> @@ -42,7 +42,7 @@ <dependency> <groupId>org.opengroup.osdu.core.aws</groupId> <artifactId>os-core-lib-aws</artifactId> - <version>0.10.0</version> + <version>0.11.0</version> </dependency> <!-- https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-secretsmanager --> @@ -55,7 +55,7 @@ <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/provider/notification-azure/GUIDELINES_FOR_USING_NOTIFICATION.md b/provider/notification-azure/docs/GUIDELINES_FOR_USING_NOTIFICATION.md similarity index 100% rename from provider/notification-azure/GUIDELINES_FOR_USING_NOTIFICATION.md rename to provider/notification-azure/docs/GUIDELINES_FOR_USING_NOTIFICATION.md diff --git a/provider/notification-azure/docs/MIGRATION.md b/provider/notification-azure/docs/MIGRATION.md new file mode 100644 index 0000000000000000000000000000000000000000..db89d26264619f07288f50e927aa147213183ef8 --- /dev/null +++ b/provider/notification-azure/docs/MIGRATION.md @@ -0,0 +1,85 @@ +## Introduction + +The document talks about the plan to move from Event Grid to Service Bus. The major consumer of the same iss +Notification Service. As Notification Service is consumed by external customers, so a clean migration path is needed. + +## Goals + +The Migration must happen respecting the following + +1. No re-registration +2. Zero downtime. +3. No notification loss. + +#### Prerequisites + +1. Please verify that the topic you want to use exists. If not, + follow [this](https://community.opengroup.org/osdu/platform/system/notification/-/blob/master/provider/notification-azure/PLAYBOOK_FOR_TOPIC_CREATION.md) + guide to create one. +2. Install + the [latest version](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.1) + of PowerShell available for your operating system. + +## How to do the migration + +Migration is something which must be performed by SRE. The flags must be switched in a sequence.The flags are controlled +by deployment.yaml for the service. Following are the steps needed for successful migration. + +1. Have 2 deployment of Notification Service running before migration: + 1. Deployment 1,having event_grid_enabled. + 2. Deployment 2,having service_bus_enabled.The consecutive_subscription_manager_delay_seconds should not be set much + higher as it will pile up alot of SB messages because of the longer time of listening new subscribers on the fly. + **The number of pods for both the deployments should be managed as per the load during migration** +2. Get list of subscriptions per partition and prepare migrationConfig.json [Manual-from azure portal]: +3. Complete powershell Az module installation and Azure login by running script + - [migrationSetup.ps1](https://community.opengroup.org/osdu/platform/system/notification/-/blob/master/provider/notification-azure/src/main/resources/migrationSetup.ps1) + . + +**Note:The Azure Az PowerShell module works with PowerShell 7.x and later on all platforms.To check your PowerShell +version, run the following command from within a PowerShell session:$PSVersionTable.PSVersion** + +4. Create the subscribers on Service Bus with the same notification id as in CosmosDB by providing migrationConfig.json + to the + script-[migrationToServiceBus.ps1](https://community.opengroup.org/osdu/platform/system/notification/-/blob/master/provider/notification-azure/src/main/resources/migrationToServiceBus.ps1) + . All the subscriptions from one Event grid topic will be moved to service bus topic for one execution of above + mentioned script.We need to rerun script for multiple topic across multiple partitions. +5. Turn on **Service bus flags** and turn off **Event Grid flags** in Producer Services. For example Storage service + publishes to Service bus and Event grid both as of now. During migration,while we are moving to Service bus + completely we have to stop publishing to Event Grid as a part of migration, so we can eventually disable it and move + to Service Bus completely.Same applies to other producer services like -Legal, Schema + etc. [Manual- Configuring deployment.yaml for Legal, Schema, Storage Services] +6. Wait for Event Grid subscribers to drain.[Manual-from azure portal] + **Note: If there are delivery failures,then retry can occur after a longer duration,EG should be kept enabled for + sufficiently long time** +7. Turn on **Service bus flags** in Register Service.[Manual] +8. Event Grid Subscriber clean up.[Manual-from azure portal] + +The 3rd and 4th steps would be performed by the scripts in the order given below : +** Powershell must be elevated to admin.** + +1. [migrationSetup.ps1](https://community.opengroup.org/osdu/platform/system/notification/-/blob/master/provider/notification-azure/src/main/resources/migrationSetup.ps1) +2. [migrationToServiceBus.ps1](https://community.opengroup.org/osdu/platform/system/notification/-/blob/master/provider/notification-azure/src/main/resources/migrationToServiceBus.ps1) + +## List of Feature Flags to be used from deployment.yaml of respective services + +1. Notification Service + 1. service_bus_enabled + 2. event_grid_enabled +2. Register Service + 1. azure_serviceBus_enabled + 2. azure_eventGrid_enabled +3. Producer Services + 1. Storage Service : azure_publishToEventGrid + 2. Legal Service : azure.publishToEventGrid + 3. Schema Service : event_grid_enabled + +## Post Migration Plan + +1. Redeploy Notification Service to have only 1 deployment with service_bus_enabled set to true and event_grid_enabled + set to false.The number of pods can be managed as per the load + +## Note + +There would be duplication of notifications that accounts for the time when producer services will be publishing to both +Service bus and Event grid at any time during migration.For example Storage service by default publish to both.We have +to use Publish flags carefully to avoid duplication \ No newline at end of file diff --git a/provider/notification-azure/PLAYBOOK_FOR_TOPIC_CREATION.md b/provider/notification-azure/docs/PLAYBOOK_FOR_TOPIC_CREATION.md similarity index 100% rename from provider/notification-azure/PLAYBOOK_FOR_TOPIC_CREATION.md rename to provider/notification-azure/docs/PLAYBOOK_FOR_TOPIC_CREATION.md diff --git a/provider/notification-azure/pom.xml b/provider/notification-azure/pom.xml index 1aed122928c7a81dd02556ab5938c8f89d19eec0..5a324bcada1460417a3ccfbd9e60f3db49e72d6a 100644 --- a/provider/notification-azure/pom.xml +++ b/provider/notification-azure/pom.xml @@ -18,7 +18,7 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>notification-azure</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-azure</name> <description>Azure implementation for Notification service</description> <packaging>jar</packaging> @@ -26,7 +26,7 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> @@ -35,11 +35,11 @@ <maven.compiler.target>${java.version}</maven.compiler.target> <maven.compiler.source>${java.version}</maven.compiler.source> <jacoco-maven-plugin.version>0.8.2</jacoco-maven-plugin.version> - <osdu.notification-core.version>0.10.0-SNAPSHOT</osdu.notification-core.version> + <osdu.notification-core.version>0.12.0-SNAPSHOT</osdu.notification-core.version> <springframework.version>4.3.0.RELEASE</springframework.version> - <reactor.netty.version>0.10.0.RELEASE</reactor.netty.version> + <reactor.netty.version>0.11.0.RELEASE</reactor.netty.version> <reactor.core.version>3.3.0.RELEASE</reactor.core.version> - <osdu.corelibazure.version>0.11.0-rc3</osdu.corelibazure.version> + <osdu.corelibazure.version>0.11.0</osdu.corelibazure.version> <junit.version>5.6.0</junit.version> <jjwt.version>3.8.1</jjwt.version> <mockito.version>2.23.0</mockito.version> diff --git a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/ServiceAccountJwtAzureClientImpl.java b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/ServiceAccountJwtAzureClientImpl.java index 934dd8672caad9ed2ad945c1af2761d640d1b7b9..88d68e6cfc9dbc3070782945b9309e5a92650784 100644 --- a/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/ServiceAccountJwtAzureClientImpl.java +++ b/provider/notification-azure/src/main/java/org/opengroup/osdu/notification/provider/azure/util/ServiceAccountJwtAzureClientImpl.java @@ -14,82 +14,19 @@ package org.opengroup.osdu.notification.provider.azure.util; -import com.auth0.jwt.JWT; -import com.microsoft.aad.adal4j.AuthenticationContext; -import com.microsoft.aad.adal4j.AuthenticationResult; -import com.microsoft.aad.adal4j.ClientCredential; -import org.apache.http.HttpStatus; -import org.opengroup.osdu.core.common.model.http.AppException; -import org.opengroup.osdu.core.common.model.search.IdToken; -import org.opengroup.osdu.core.common.provider.interfaces.IJwtCache; +import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService; import org.opengroup.osdu.core.common.util.IServiceAccountJwtClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.net.MalformedURLException; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; - @Component public class ServiceAccountJwtAzureClientImpl implements IServiceAccountJwtClient { @Autowired - private AppProperties config; - - @Autowired - private IJwtCache tenantJwtCache; - - public String getIdToken(String tenantName) { - String ACCESS_TOKEN = ""; - ExecutorService service = null; - - try { - // TODO : Refactor to move ID token form Common.Core.model.search to Common.core - IdToken cachedToken = (IdToken) this.tenantJwtCache.get(tenantName); - - if ((cachedToken != null) && !IdToken.refreshToken(cachedToken)) { - return "Bearer " + cachedToken.getTokenValue(); - } - - // TODO : Control the thread count via config and pool should be created once. - service = Executors.newFixedThreadPool(1); - - ACCESS_TOKEN = getAccessToken(service); - IdToken idToken = IdToken.builder().tokenValue(ACCESS_TOKEN).expirationTimeMillis(JWT.decode(ACCESS_TOKEN).getExpiresAt().getTime()).build(); - this.tenantJwtCache.put(tenantName, idToken); - } finally { - if(service != null) { - service.shutdown(); - } - } - return "Bearer " + ACCESS_TOKEN; - } - - // TODO : Refactor for making it test-able. - // THIS METHOD IS PUBLIC ONLY TO ENABLE UNIT TESTING - public String getAccessToken(ExecutorService service) { - AuthenticationContext context = null; - ClientCredential credential = null; - String ACCESS_TOKEN = null; - try { - context = new AuthenticationContext(this.config.getAuthURL(), false, service); - credential = new ClientCredential(this.config.getAuthClientID(), this.config.getAuthClientSecret()); - - Future<AuthenticationResult> future = context.acquireToken(this.config.getAadClientID(), credential, null); + private AzureServicePrincipleTokenService tokenService; - if (future == null) { - throw new AppException(HttpStatus.SC_FORBIDDEN, "Token not generated", "The user is not authorized to obtain Token From AAD"); - } - ACCESS_TOKEN = future.get().getAccessToken(); - } catch (MalformedURLException malformedURLException) { - malformedURLException.printStackTrace(); - } catch (InterruptedException e) { - e.printStackTrace(); - } catch (ExecutionException e) { - e.printStackTrace(); - } - return ACCESS_TOKEN; + @Override + public String getIdToken(String partitionId){ + return "Bearer " + this.tokenService.getAuthorizationToken(); } } diff --git a/provider/notification-azure/src/main/resources/migrationConfig.json b/provider/notification-azure/src/main/resources/migrationConfig.json new file mode 100644 index 0000000000000000000000000000000000000000..f7b6f574d5fb08592b31d53c1bb6663c9447f78a --- /dev/null +++ b/provider/notification-azure/src/main/resources/migrationConfig.json @@ -0,0 +1,18 @@ +[ + { + "ResourceGroupIdCosmos": "This is the subscription ID corresponding to a resource group having Cosmos DB", + "PartitionKeyCosmos": "This is used by Cosmos DB to distribute data among multiple partitions.Example -opendes", + "ReadWriteMasterKeyCosmosDb": "Cosmos read write keys are very sensitive ones and provide access to the administrative resources", + "CosmosDBEndPoint": "Cosmos endpoint URL", + "DatabaseName": "Cosmos Database name. Example - osdu-db", + "ContainerName": "Cosmos Container name. Example -RegisterSubscription", + "ResourceGroupNameServiceBus": "This is the resource group name of a resource group having Service bus", + "ResourceGroupIdServiceBus": "This is the subscription ID corresponding to a resource group having Service Bus.This can be same as ResourceGroupIdCosmos mentioned above", + "NamespaceNameServiceBus": "Service bus namespace name(not host name) under ResourceGroupNameServiceBus", + "ServiceBusTopicName": "Service bus topic name under ResourceGroupNameServiceBus", + "SubscriptionIdsCosmos": [ + "Subs_Id1", + "Subs_Id2" + ] + } +] \ No newline at end of file diff --git a/provider/notification-azure/src/main/resources/migrationSetup.ps1 b/provider/notification-azure/src/main/resources/migrationSetup.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..a9e08258953d15af730618487d06dd7af79bb8e1 --- /dev/null +++ b/provider/notification-azure/src/main/resources/migrationSetup.ps1 @@ -0,0 +1,24 @@ +# This script provides the pre migration setup for subscriptions from event grid to service bus. + +param([Parameter(Mandatory = $true)][Boolean]$InstallAzModule) + +try +{ + # Set execution policy + Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser + + # Installation of modules. This Can be ignored by $InstallAzModule if already installed. + if ($InstallAzModule) + { + Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force -ErrorAction Stop + } + + # Azure login + Connect-AzAccount -ErrorAction Stop + + Write-Output "Migration Setup Successful." +} +catch +{ + Write-Output "Migration Setup Failed" $_ +} \ No newline at end of file diff --git a/provider/notification-azure/src/main/resources/migrationToServiceBus.ps1 b/provider/notification-azure/src/main/resources/migrationToServiceBus.ps1 new file mode 100644 index 0000000000000000000000000000000000000000..e42d68148d1d8df2be0065c6c1a087413f854faa --- /dev/null +++ b/provider/notification-azure/src/main/resources/migrationToServiceBus.ps1 @@ -0,0 +1,162 @@ +<# This script performs migration of event grid subscriptions to service bus subscriptions for a given configuration file. + migrationSetup.ps1 is the prerequistes for successful execution of this script. +#> +Param([Parameter(Mandatory = $true)][String]$migrationConfigFilePath) + +Add-Type -AssemblyName System.Web + +# Generates auth key for cosmos API +Function GenerateAuthorizationSignature +{ + [CmdletBinding()] + Param + ( + [Parameter(Mandatory = $true)][String]$method, + [Parameter(Mandatory = $true)][String]$resourceLink, + [Parameter(Mandatory = $true)][String]$resourceType, + [Parameter(Mandatory = $true)][String]$key, + [Parameter(Mandatory = $true)][String]$keyType, + [Parameter(Mandatory = $true)][String]$tokenVersion, + [Parameter(Mandatory = $true)][String]$dateTime + ) + $hmacSha = New-Object System.Security.Cryptography.HMACSHA256 + $hmacSha.Key = [System.Convert]::FromBase64String($key) + + $payLoad = "$($method.ToLowerInvariant() )`n$($resourceType.ToLowerInvariant() )`n$resourceLink`n$($dateTime.ToLowerInvariant() )`n`n" + $hashPayLoad = $hmacSha.ComputeHash([System.Text.Encoding]::UTF8.GetBytes($payLoad)) + $signature = [System.Convert]::ToBase64String($hashPayLoad); + + [System.Web.HttpUtility]::UrlEncode("type=$keyType&ver=$tokenVersion&sig=$signature") +} + +# Fetch the subscription from cosmos db +Function GetCosmosSubscription +{ + [CmdletBinding()] + Param( + [Parameter(Mandatory = $true)][String]$Partition, + [Parameter(Mandatory = $true)][String]$SubscriptionId, + [Parameter(Mandatory = $true)][String]$ReadWriteMasterKeyCosmosDb, + [Parameter(Mandatory = $true)][String]$CosmosDBEndPoint, + [Parameter(Mandatory = $true)][String]$DatabaseName, + [Parameter(Mandatory = $true)][String]$ContainerName + ) + + $resourceType = "docs"; + $resourceLink = "dbs/$DatabaseName/colls/$ContainerName/docs/$SubscriptionId" + $partitionkey = "[""$( $Partition )""]" + $cosmosURI = "$CosmosDBEndPoint$resourceLink" + $dateTime = [DateTime]::UtcNow.ToString("r") + + $authToken = GenerateAuthorizationSignature -method "GET" -resourceLink $resourceLink -resourceType $resourceType -key $ReadWriteMasterKeyCosmosDb -keyType "master" -tokenVersion "1.0" -dateTime $dateTime + + $headers = @{ authorization = $authToken; "x-ms-version" = "2017-02-22"; "x-ms-documentdb-partitionkey" = $partitionkey; "x-ms-date" = $dateTime } + + # Call cosmos API to get subscription + Invoke-RestMethod -Method "GET" -Uri $cosmosURI -headers $headers -Verbose + +} + +# Update the cosmos subscription +Function UpdateCosmosSubscription +{ + [CmdletBinding()] + Param( + [Parameter(Mandatory = $true)][String]$JsonSubscription, + [Parameter(Mandatory = $true)][String]$Partition, + [Parameter(Mandatory = $true)][String]$SubscriptionId, + [Parameter(Mandatory = $true)][String]$ReadWriteMasterKeyCosmosDb, + [Parameter(Mandatory = $true)][String]$CosmosDBEndPoint, + [Parameter(Mandatory = $true)][String]$DatabaseName, + [Parameter(Mandatory = $true)][String]$ContainerName + ) + + $resourceType = "docs"; + $resourceLink = "dbs/$DatabaseName/colls/$ContainerName/docs/$SubscriptionId" + $partitionkey = "[""$( $Partition )""]" + $contentType = "application/json" + $cosmosURI = "$CosmosDBEndPoint$resourceLink" + $dateTime = [DateTime]::UtcNow.ToString("r") + + $authToken = GenerateAuthorizationSignature -method "PUT" -resourceLink $ResourceLink -resourceType $ResourceType -key $ReadWriteMasterKeyCosmosDb -keyType "master" -tokenVersion "1.0" -dateTime $dateTime + + $headers = @{ authorization = $authToken; "x-ms-version" = "2017-02-22"; "x-ms-documentdb-partitionkey" = $partitionkey; "x-ms-date" = $dateTime } + + # Call cosmos API to update subscription + Invoke-RestMethod -Method "PUT" -ContentType $contentType -Uri $cosmosURI -headers $headers -Body $JsonSubscription -Verbose + +} + +# Migration Execution +try +{ + $configurations = Get-Content -Raw -Path $migrationConfigFilePath| ConvertFrom-Json + + foreach ($config in $configurations) + { + try + { + $ResourceGroupIdCosmos = $config.ResourceGroupIdCosmos + $PartitionKeyCosmos = $config.PartitionKeyCosmos + $ReadWriteMasterKeyCosmosDb = $config.ReadWriteMasterKeyCosmosDb + $CosmosDBEndPoint = $config.CosmosDBEndPoint + $DatabaseName = $config.DatabaseName + $ContainerName = $config.ContainerName + $ResourceGroupNameServiceBus = $config.ResourceGroupNameServiceBus + $ResourceGroupIdServiceBus = $config.ResourceGroupIdServiceBus + $NamespaceNameServiceBus = $config.NamespaceNameServiceBus + $ServiceBusTopicName = $config.ServiceBusTopicName + $SubscriptionIds = $config.SubscriptionIdsCosmos + + foreach ($SubscriptionId in $SubscriptionIds) + { + $Subscription = $null + $ServiceBusSubscription = $null + try + { + # Set resource group susbscription for cosmos + Select-AzSubscription -SubscriptionName $ResourceGroupIdCosmos -Verbose -ErrorAction Stop + + $Subscription = GetCosmosSubscription -Partition $PartitionKeyCosmos -SubscriptionId $SubscriptionId -ReadWriteMasterKeyCosmosDb $ReadWriteMasterKeyCosmosDb -CosmosDBEndPoint $CosmosDBEndPoint -DatabaseName $DatabaseName -ContainerName $ContainerName + if ((!$Subscription) -or (!$Subscription.notificationId) -or (!$Subscription.topic)) + { + throw "Subscription is not present/null/empty or NotificationId/Topic is not present/null/empty in subscription with ID - $SubscriptionId" + } + $NotificationId = $Subscription.notificationId + + # Set resource group susbscription for service bus + Select-AzSubscription -SubscriptionName $ResourceGroupIdServiceBus -Verbose -ErrorAction Stop + + # Create service bus topic subscription + $ServiceBusSubscription = New-AzServiceBusSubscription -ResourceGroupName $ResourceGroupNameServiceBus -Namespace $NamespaceNameServiceBus -Topic $ServiceBusTopicName -Name $NotificationId -Verbose + + if (!$ServiceBusSubscription) + { + throw "Unable to create service bus subscription with Id - $NotificationId and topic - $ServiceBusTopicName " + } + # Update subscription topic name + $Subscription.topic = $ServiceBusTopicName + $JsonSubscription = $Subscription| ConvertTo-Json + + # Update cosmos subscription + $UpdatedSubscription = UpdateCosmosSubscription -JsonSubscription $JsonSubscription -Partition $PartitionKeyCosmos -SubscriptionId $SubscriptionId -ReadWriteMasterKeyCosmosDb $ReadWriteMasterKeyCosmosDb -CosmosDBEndPoint $CosmosDBEndPoint -DatabaseName $DatabaseName -ContainerName $ContainerName + + Write-Output "Migration to Service Bus is Successful for Subscription - $SubscriptionId `n" + } + catch + { + Write-Output "Migration Failed for Subscription - $SubscriptionId." $_ + } + } + } + catch + { + Write-Output "Unable to process configuration -$config.ResourceGroupName." $_ + } + } + +} +catch +{ + Write-Output "Unable to process configurations" $_ +} \ No newline at end of file diff --git a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java index e7caf1d3bf93c6e74b665570e48cb94a0d5c7f3d..59fbfb854e7e3bca9ea106a1706b387890f74e1b 100644 --- a/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java +++ b/provider/notification-azure/src/test/java/org/opengroup/osdu/notification/util/ServiceAccountClientImplTest.java @@ -14,104 +14,56 @@ package org.opengroup.osdu.notification.util; -import org.apache.http.HttpStatus; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnitRunner; -import org.opengroup.osdu.core.common.logging.JaxRsDpsLog; +import org.mockito.junit.jupiter.MockitoExtension; +import org.omg.CORBA.portable.ApplicationException; +import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService; import org.opengroup.osdu.core.common.model.http.AppException; -import org.opengroup.osdu.core.common.model.search.IdToken; -import org.opengroup.osdu.notification.provider.azure.cache.JwtCache; -import org.opengroup.osdu.notification.provider.azure.util.AppProperties; import org.opengroup.osdu.notification.provider.azure.util.ServiceAccountJwtAzureClientImpl; -import java.util.concurrent.ExecutorService; +import java.io.UnsupportedEncodingException; -import static org.junit.Assert.fail; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ServiceAccountClientImplTest { - final String tenantName = "Test Tenant"; - final String validToken = "validToken"; - - @Mock - private IdToken idToken; - - @Mock - private ExecutorService executorService; - - @Mock - private AppProperties appProperties; - - @Mock - private JwtCache tenantJwtCacheMock; - - @Mock - private JaxRsDpsLog logger; + private static final String tenantId = "tenantId"; + private static final String token = "jwt-token"; @InjectMocks - @Spy - private ServiceAccountJwtAzureClientImpl sut; + private ServiceAccountJwtAzureClientImpl serviceAccountJwtAzureClient; - @Before - public void setup() { - initMocks(this); - idToken = IdToken.builder().tokenValue(validToken).expirationTimeMillis(System.currentTimeMillis() + 10000000L).build(); - } + @Mock + private AzureServicePrincipleTokenService azureServicePrincipleTokenService; @Test - public void should_getTokenFromCache_getIdTokenTest() { - // SetUp - when(tenantJwtCacheMock.get(any())).thenReturn(idToken); - String expectedToken = "Bearer " +idToken.getTokenValue(); + public void shouldSuccessfullyGenerateToken() throws UnsupportedEncodingException, ApplicationException { - // Act - String returnedIdToken = sut.getIdToken(tenantName); + when(azureServicePrincipleTokenService.getAuthorizationToken()).thenReturn(token); - // Assert - Assert.assertEquals(expectedToken, returnedIdToken); + String result = serviceAccountJwtAzureClient.getIdToken(tenantId); + + assertEquals("Bearer " + token, result); + verify(azureServicePrincipleTokenService, times(1)).getAuthorizationToken(); } @Test - public void should_updateCache_getIdTokenTest() { - // Set up - when(tenantJwtCacheMock.get(any())).thenReturn(idToken); - String expectedToken = "Bearer " +idToken.getTokenValue(); + public void shouldThrowAppException() throws UnsupportedEncodingException { - // Act - String returnedToken = this.sut.getIdToken(tenantName); + doThrow(AppException.class).when(azureServicePrincipleTokenService).getAuthorizationToken(); - // Assert - Assert.assertEquals(expectedToken, returnedToken); - } + AppException exception = assertThrows(AppException.class, () -> { + serviceAccountJwtAzureClient.getIdToken(tenantId); + }); - @Test - public void should_return403GivenInvalidApplicationProperties_getAccessToken() { - when(appProperties.getAuthURL()).thenReturn("https://login.microsoftonline.com/s/oauth2/token/"); - when(appProperties.getAuthClientID()).thenReturn("testAuthClientID"); - when(appProperties.getAuthClientSecret()).thenReturn("testAuthClientSecret"); - when(appProperties.getAadClientID()).thenReturn("testAadClientID"); - - try { - // Act - sut.getAccessToken(executorService); - - // Assert - fail("Should throw exception"); - } catch (AppException appException) { - Assert.assertEquals(HttpStatus.SC_FORBIDDEN, appException.getError().getCode()); - } catch (Exception e) { - fail("Should not throw this exception" + e.getMessage()); - } + assertNotNull(exception); + verify(azureServicePrincipleTokenService, times(1)).getAuthorizationToken(); } } diff --git a/provider/notification-gcp/pom.xml b/provider/notification-gcp/pom.xml index ffdff897c239f33fcec878a5b8679febac16c072..a86b437ba4371a20cf5b1e3e9d70b00773d9f8bf 100644 --- a/provider/notification-gcp/pom.xml +++ b/provider/notification-gcp/pom.xml @@ -18,7 +18,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-gcp</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-gcp</name> <description>GCP implementation for Notification service</description> <packaging>jar</packaging> @@ -26,7 +26,7 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> @@ -44,13 +44,13 @@ <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>core-lib-gcp</artifactId> - <version>0.10.0</version> + <version>0.11.0</version> </dependency> <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/provider/notification-ibm/pom.xml b/provider/notification-ibm/pom.xml index 062ba56e9e5e38e018cd4a31287eb28ba5cc7107..089f6a66c5f698db00353a63f1e512779929c7e8 100644 --- a/provider/notification-ibm/pom.xml +++ b/provider/notification-ibm/pom.xml @@ -16,7 +16,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-ibm</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-ibm</name> <description>IBM implementation for Notification service</description> <packaging>jar</packaging> @@ -24,7 +24,7 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../../pom.xml</relativePath> </parent> @@ -50,7 +50,7 @@ <dependency> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <!-- unit test dependencies --> diff --git a/testing/notification-test-aws/pom.xml b/testing/notification-test-aws/pom.xml index 00822c0f45c5f4473597844b293a9b2a6afdd44c..c3336063beba95b562f28997ac649e3b8da0cfb6 100644 --- a/testing/notification-test-aws/pom.xml +++ b/testing/notification-test-aws/pom.xml @@ -21,13 +21,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification-testing</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-test-aws</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-test-aws</name> <description>AWS Integration tests for Notification Service</description> <packaging>jar</packaging> @@ -52,7 +52,7 @@ <dependency> <groupId>org.opengroup.osdu.notification</groupId> <artifactId>notification-test-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.opengroup.osdu</groupId> diff --git a/testing/notification-test-azure/pom.xml b/testing/notification-test-azure/pom.xml index b7320b85139b8558dad80a72f74848a9ca8364ab..e206e2afba65d158c5af18936ceb106669981bce 100644 --- a/testing/notification-test-azure/pom.xml +++ b/testing/notification-test-azure/pom.xml @@ -21,13 +21,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification-testing</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-test-azure</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-test-azure</name> <description>Integration tests Azure for notification</description> <packaging>jar</packaging> @@ -42,7 +42,7 @@ <dependency> <groupId>org.opengroup.osdu.notification</groupId> <artifactId>notification-test-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <dependency> diff --git a/testing/notification-test-core/pom.xml b/testing/notification-test-core/pom.xml index 12664d65658a985ad4fa143dde2e681516572d7e..02b337ba0c84b7c175fa568cb40fe05ab4697eb9 100644 --- a/testing/notification-test-core/pom.xml +++ b/testing/notification-test-core/pom.xml @@ -21,13 +21,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification-testing</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu.notification</groupId> <artifactId>notification-test-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-test-core</name> <description>Integration tests core for notification</description> <packaging>jar</packaging> @@ -113,7 +113,7 @@ <dependency> <groupId>com.google.auth</groupId> <artifactId>google-auth-library-oauth2-http</artifactId> - <version>0.10.0</version> + <version>0.11.0</version> </dependency> <dependency> <groupId>io.jsonwebtoken</groupId> diff --git a/testing/notification-test-gcp/pom.xml b/testing/notification-test-gcp/pom.xml index 466935d330cec4e446270287c20dd6337c89cfc5..e22afb311f41d015a0f9a30f1cc19660ec8b7ef6 100644 --- a/testing/notification-test-gcp/pom.xml +++ b/testing/notification-test-gcp/pom.xml @@ -21,12 +21,12 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification-testing</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <artifactId>notification-test-gcp</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-test-gcp</name> <description>Integration tests GCP for notification</description> <packaging>jar</packaging> @@ -41,7 +41,7 @@ <dependency> <groupId>org.opengroup.osdu.notification</groupId> <artifactId>notification-test-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.opengroup.osdu</groupId> diff --git a/testing/notification-test-ibm/pom.xml b/testing/notification-test-ibm/pom.xml index 2b3e4e5a4210906be3fd36824b096f32d544a846..9f52e4f684bcf892861219a9c6d0ab5277caf0e0 100644 --- a/testing/notification-test-ibm/pom.xml +++ b/testing/notification-test-ibm/pom.xml @@ -18,13 +18,13 @@ <parent> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification-testing</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <groupId>org.opengroup.osdu</groupId> <artifactId>notification-test-ibm</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <name>notification-test-ibm</name> <description>Integration tests IBM for notification</description> <packaging>jar</packaging> @@ -45,7 +45,7 @@ <dependency> <groupId>org.opengroup.osdu.notification</groupId> <artifactId>notification-test-core</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.opengroup.osdu</groupId> diff --git a/testing/pom.xml b/testing/pom.xml index 79973d75bbd04e049048f130fd2e68419276de5e..92724d716d54f21bd1aa70cfcacc6aed42992a86 100644 --- a/testing/pom.xml +++ b/testing/pom.xml @@ -18,7 +18,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.opengroup.osdu</groupId> <artifactId>os-notification-testing</artifactId> - <version>0.10.0-SNAPSHOT</version> + <version>0.12.0-SNAPSHOT</version> <description>Root Notification Service project</description> <packaging>pom</packaging>