diff --git a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc
index 9f807d8..c8498fe 100644
--- a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc
+++ b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-docs.adoc
@@ -52,7 +52,3 @@ app:
watchNamespaces: "JOSDK_WATCH_CURRENT"
----
-ACES or comma separated list of namespaces
-watchNamespaces: "JOSDK_WATCH_CURRENT"
-----
-
diff --git a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc
index 8c675ec..0f9f94d 100644
--- a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc
+++ b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator-extensions.adoc
@@ -11,20 +11,20 @@ h| Version
| tkit-quarkus-log-cdi
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link]
-| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
-| 2.22.0
+| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
+| 2.23.0
| tkit-quarkus-log-rs
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link]
-| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
-| 2.22.0
+| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
+| 2.23.0
| tkit-quarkus-log-json
| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link]
-| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
-| 2.22.0
+| https://github.com/1000kit/tkit-quarkus/blob/2.23.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
+| 2.23.0
| quarkus-arc
diff --git a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc
index b582168..3b90af1 100644
--- a/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc
+++ b/docs/modules/onecx-data-orchestrator-operator/pages/onecx-data-orchestrator-operator.adoc
@@ -27,6 +27,57 @@ endif::add-copy-button-to-env-var[]
|`MD5`
+a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-user-name]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-user-name[onecx.data-orchestrator.token.user-name]`
+
+
+[.description]
+--
+Username for rest call.
+
+ifdef::add-copy-button-to-env-var[]
+Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_USER_NAME+++[]
+endif::add-copy-button-to-env-var[]
+ifndef::add-copy-button-to-env-var[]
+Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_USER_NAME+++`
+endif::add-copy-button-to-env-var[]
+--|string
+|`data-orchestrator-operator`
+
+
+a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-header-param]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-header-param[onecx.data-orchestrator.token.header-param]`
+
+
+[.description]
+--
+Token header parameter.
+
+ifdef::add-copy-button-to-env-var[]
+Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_HEADER_PARAM+++[]
+endif::add-copy-button-to-env-var[]
+ifndef::add-copy-button-to-env-var[]
+Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_HEADER_PARAM+++`
+endif::add-copy-button-to-env-var[]
+--|string
+|`apm-principal-token`
+
+
+a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-token-claim-organization-param[onecx.data-orchestrator.token.claim-organization-param]`
+
+
+[.description]
+--
+Token claim organization parameter.
+
+ifdef::add-copy-button-to-env-var[]
+Environment variable: env_var_with_copy_button:+++ONECX_DATA_ORCHESTRATOR_TOKEN_CLAIM_ORGANIZATION_PARAM+++[]
+endif::add-copy-button-to-env-var[]
+ifndef::add-copy-button-to-env-var[]
+Environment variable: `+++ONECX_DATA_ORCHESTRATOR_TOKEN_CLAIM_ORGANIZATION_PARAM+++`
+endif::add-copy-button-to-env-var[]
+--|string
+|`orgId`
+
+
a| [[onecx-data-orchestrator-operator_onecx-data-orchestrator-client-shared]]`link:#onecx-data-orchestrator-operator_onecx-data-orchestrator-client-shared[onecx.data-orchestrator.client.shared]`
diff --git a/docs/modules/onecx-product-store-slot-operator/pages/index.adoc b/docs/modules/onecx-product-store-slot-operator/pages/index.adoc
deleted file mode 100644
index b3ef51d..0000000
--- a/docs/modules/onecx-product-store-slot-operator/pages/index.adoc
+++ /dev/null
@@ -1,8 +0,0 @@
-include::onecx-product-store-slot-operator-attributes.adoc[opts=optional]
-
-== onecx-product-store-slot-operator
-
-include::docs.adoc[opts=optional]
-
-
-include::onecx-product-store-slot-operator-docs.adoc[opts=optional]
diff --git a/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-attributes.adoc b/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-attributes.adoc
deleted file mode 100644
index 254147a..0000000
--- a/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-attributes.adoc
+++ /dev/null
@@ -1,5 +0,0 @@
-
-:docker-registry: https://github.com/onecx/onecx-product-store-slot-operator/pkgs/container/onecx-product-store-slot-operator
-:helm-registry: https://github.com/onecx/onecx-product-store-slot-operator/pkgs/container/charts%2Fonecx-product-store-slot-operator
-:properties-file: src/main/resources/application.properties
-:helm-file: src/main/helm/values.yaml
\ No newline at end of file
diff --git a/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-docs.adoc b/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-docs.adoc
deleted file mode 100644
index f2fa178..0000000
--- a/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-docs.adoc
+++ /dev/null
@@ -1,55 +0,0 @@
-
-include::onecx-product-store-slot-operator-attributes.adoc[opts=optional]
-
-=== Default properties
-
-.{properties-file}
-[%collapsible%open]
-====
-[source,properties,subs=attributes+]
-----
-%prod.quarkus.rest-client.product_store_client.url=http://onecx-product-store-svc:8080
-quarkus.operator-sdk.controllers.microservice.namespaces=JOSDK_WATCH_CURRENT
-quarkus.operator-sdk.helm.enabled=true
-quarkus.openapi-generator.codegen.input-base-dir=target/tmp/openapi
-quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_slot_v1_yaml.config-key=product_store_client
-quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_slot_v1_yaml.base-package=gen.org.tkit.onecx.product.store.slot.v1
-quarkus.openapi-generator.codegen.spec.onecx_product_store_operator_slot_v1_yaml.return-response=true
-quarkus.kubernetes-client.devservices.override-kubeconfig=true
-----
-====
-
-=== Extensions
-
-include::onecx-product-store-slot-operator-extensions.adoc[opts=optional]
-
-=== Container
-
-{docker-registry}[Docker registry]
-
-
-=== Helm
-
-{helm-registry}[Helm registry]
-
-Default values
-
-.{helm-file}
-[source,yaml]
-----
-app:
- name: slot-operator
- image:
- repository: "onecx/onecx-product-store-slot-operator"
- envCustom:
- - name: KUBERNETES_NAMESPACE
- valueFrom:
- fieldRef:
- fieldPath: metadata.namespace
- serviceAccount:
- enabled: true
-
-# Values: JOSDK_WATCH_CURRENT, JOSDK_ALL_NAMESPACES or comma separated list of namespaces
-watchNamespaces: "JOSDK_WATCH_CURRENT"
-----
-
diff --git a/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-extensions.adoc b/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-extensions.adoc
deleted file mode 100644
index cf981eb..0000000
--- a/docs/modules/onecx-product-store-slot-operator/pages/onecx-product-store-slot-operator-extensions.adoc
+++ /dev/null
@@ -1,103 +0,0 @@
-
-include::onecx-product-store-slot-operator-attributes.adoc[opts=optional]
-
-[.extension.table.searchable, cols="50,.^15,.^15,.^20"]
-|===
-h| Extensions
-h| Documentation
-h| Configuration
-h| Version
-
-| tkit-quarkus-log-cdi
-
-| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-cdi.html[Link]
-| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-cdi.adoc[Link]
-| 2.22.0
-
-| tkit-quarkus-log-rs
-
-| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-rs.html[Link]
-| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-rs.adoc[Link]
-| 2.22.0
-
-| tkit-quarkus-log-json
-
-| https://1000kit.github.io/tkit-quarkus/current/tkit-quarkus/tkit-quarkus-log-json.html[Link]
-| https://github.com/1000kit/tkit-quarkus/blob/2.22.0/docs/modules/tkit-quarkus/pages/includes/tkit-quarkus-log-json.adoc[Link]
-| 2.22.0
-
-| quarkus-arc
-
-| https://quarkus.io/guides/cdi-reference[Link]
-| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-arc.adoc[Link]
-| 3.9.3
-
-| quarkus-micrometer-registry-prometheus
-
-| https://quarkus.io/guides/telemetry-micrometer[Link]
-| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-micrometer-registry-prometheus.adoc[Link]
-| 3.9.3
-
-| quarkus-opentelemetry
-
-| https://quarkus.io/guides/opentelemetry[Link]
-| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-opentelemetry.adoc[Link]
-| 3.9.3
-
-| quarkus-openapi-generator
-
-| https://docs.quarkiverse.io/quarkus-openapi-generator/dev/index.html[Link]
-| https://github.com/quarkiverse/quarkus-openapi-generator/blob/2.4.1/docs/modules/ROOT/pages/includes/quarkus-openapi-generator.adoc[Link]
-| 2.4.1
-
-| quarkus-rest-client
-
-| https://quarkus.io/guides/rest-client[Link]
-| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-rest-client.adoc[Link]
-| 3.9.3
-
-| quarkus-rest-client-jackson
-
-| https://quarkus.io/guides/rest-client[Link]
-|
-| 3.9.3
-
-| onecx-core
-
-| https://onecx.github.io/docs/onecx-quarkus/current/onecx-quarkus/onecx-core.html[Link]
-|
-| 0.17.0
-
-| quarkus-container-image-docker
-
-| https://quarkus.io/guides/container-image[Link]
-| https://github.com/quarkusio/quarkusio.github.io/blob/develop/_generated-doc/latest/config/quarkus-container-image-docker.adoc[Link]
-| 3.9.3
-
-
-| quarkus-operator-sdk-bundle-generator
-
-|
-|
-| 6.6.7
-
-| quarkus-operator-sdk
-
-|
-|
-| 6.6.7
-
-| quarkus-oidc-client
-
-|
-|
-| 3.9.3
-
-| quarkus-rest-client-oidc-filter
-
-|
-|
-| 3.9.3
-
-
-|===
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 5ff9b6b..7fb0832 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
org.tkit.onecx
onecx-quarkus3-parent
- 0.48.0
+ 0.49.0
onecx-data-orchestrator-operator
diff --git a/src/main/helm/crds/datas.onecx.tkit.org-v1.yml b/src/main/helm/crds/datas.onecx.tkit.org-v1.yml
index 30ce946..b05ab1e 100644
--- a/src/main/helm/crds/datas.onecx.tkit.org-v1.yml
+++ b/src/main/helm/crds/datas.onecx.tkit.org-v1.yml
@@ -25,6 +25,8 @@ spec:
type: string
key:
type: string
+ orgId:
+ type: string
productName:
type: string
type: object
diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java
index 016840d..651d6bc 100644
--- a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java
+++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataConfig.java
@@ -1,5 +1,7 @@
package org.tkit.onecx.data.orchestrator.operator;
+import java.util.Map;
+
import io.quarkus.runtime.annotations.*;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
@@ -18,4 +20,69 @@ public interface DataConfig {
@WithDefault("MD5")
String digest();
+ /**
+ * Token configuration.
+ */
+ @WithDefault("token")
+ TokenConfig token();
+
+ /**
+ * Client configuration.
+ */
+ @WithDefault("client")
+ ConfigClient client();
+
+ /**
+ * Client configuration.
+ */
+ interface ConfigClient {
+
+ /**
+ * Set to true to share the HTTP client between REST clients.
+ */
+ @WithName("shared")
+ @WithDefault("true")
+ boolean shared();
+
+ /**
+ * The size of the rest client connection pool.
+ */
+ @WithName("connection-pool-size")
+ @WithDefault("30")
+ int connectionPoolSize();
+
+ /**
+ * Clients key configuration
+ */
+ @WithName("key")
+ Map keys();
+ }
+
+ /**
+ * Token configuration.
+ */
+ interface TokenConfig {
+
+ /**
+ * Username for rest call.
+ */
+ @WithName("user-name")
+ @WithDefault("data-orchestrator-operator")
+ String userName();
+
+ /**
+ * Token header parameter.
+ */
+ @WithName("header-param")
+ @WithDefault("apm-principal-token")
+ String headerParam();
+
+ /**
+ * Token claim organization parameter.
+ */
+ @WithName("claim-organization-param")
+ @WithDefault("orgId")
+ String claimOrganizationParam();
+
+ }
}
diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataSpec.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataSpec.java
index 8cd2b3f..21185a4 100644
--- a/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataSpec.java
+++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/DataSpec.java
@@ -6,6 +6,9 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DataSpec {
+ @JsonProperty("orgId")
+ private String orgId;
+
@JsonProperty("key")
private String key;
@@ -21,6 +24,14 @@ public class DataSpec {
@JsonProperty("data")
private String data;
+ public String getOrgId() {
+ return orgId;
+ }
+
+ public void setOrgId(String orgId) {
+ this.orgId = orgId;
+ }
+
public String getData() {
return data;
}
diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataConfigClient.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataConfigClient.java
deleted file mode 100644
index 50f801f..0000000
--- a/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataConfigClient.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.tkit.onecx.data.orchestrator.operator.client;
-
-import java.util.Map;
-
-import io.quarkus.runtime.annotations.ConfigDocFilename;
-import io.quarkus.runtime.annotations.ConfigPhase;
-import io.quarkus.runtime.annotations.ConfigRoot;
-import io.quarkus.runtime.annotations.StaticInitSafe;
-import io.smallrye.config.ConfigMapping;
-import io.smallrye.config.WithDefault;
-import io.smallrye.config.WithName;
-
-@StaticInitSafe
-@ConfigDocFilename("onecx-data-orchestrator-operator.adoc")
-@ConfigMapping(prefix = "onecx.data-orchestrator.client")
-@ConfigRoot(phase = ConfigPhase.RUN_TIME)
-public interface DataConfigClient {
-
- /**
- * Set to true to share the HTTP client between REST clients.
- */
- @WithName("shared")
- @WithDefault("true")
- boolean shared();
-
- /**
- * The size of the rest client connection pool.
- */
- @WithName("connection-pool-size")
- @WithDefault("30")
- int connectionPoolSize();
-
- /**
- * Clients key configuration
- */
- @WithName("key")
- Map keys();
-}
diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataService.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataService.java
index c11643b..c948844 100644
--- a/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataService.java
+++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/DataService.java
@@ -4,35 +4,55 @@
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
+import jakarta.json.Json;
+import jakarta.json.JsonObjectBuilder;
+import jakarta.ws.rs.core.MultivaluedHashMap;
+import jakarta.ws.rs.core.MultivaluedMap;
-import org.eclipse.microprofile.rest.client.RestClientBuilder;
+import org.eclipse.microprofile.jwt.Claims;
import org.jboss.resteasy.reactive.client.api.QuarkusRestClientProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tkit.onecx.data.orchestrator.operator.Data;
+import org.tkit.onecx.data.orchestrator.operator.DataConfig;
import org.tkit.onecx.data.orchestrator.operator.DataSpec;
+import io.quarkus.rest.client.reactive.QuarkusRestClientBuilder;
+import io.quarkus.rest.client.reactive.ReactiveClientHeadersFactory;
+import io.smallrye.jwt.build.Jwt;
+import io.smallrye.mutiny.Uni;
+
@ApplicationScoped
public class DataService {
private static final Logger log = LoggerFactory.getLogger(DataService.class);
@Inject
- DataConfigClient config;
+ DataConfig config;
public int updateData(Data data) {
DataSpec spec = data.getSpec();
- var url = config.keys().get(spec.getKey());
+ var url = config.client().keys().get(spec.getKey());
if (url == null) {
log.warn("No URL defined for the key '{}', resource: {}", spec.getKey(), data.getMetadata().getName());
throw new MissingKeyConfiguration(spec.getKey());
}
- var client = RestClientBuilder.newBuilder()
+ var token = createToken(data);
+ var client = QuarkusRestClientBuilder.newBuilder()
.baseUri(URI.create(url))
- .property(QuarkusRestClientProperties.CONNECTION_POOL_SIZE, config.connectionPoolSize())
+ .property(QuarkusRestClientProperties.CONNECTION_POOL_SIZE, config.client().connectionPoolSize())
.property(QuarkusRestClientProperties.NAME, spec.getKey())
- .property(QuarkusRestClientProperties.SHARED, config.shared())
+ .property(QuarkusRestClientProperties.SHARED, config.client().shared())
+ .clientHeadersFactory(new ReactiveClientHeadersFactory() {
+ @Override
+ public Uni> getHeaders(MultivaluedMap incomingHeaders,
+ MultivaluedMap clientOutgoingHeaders) {
+ MultivaluedMap propagatedHeaders = new MultivaluedHashMap<>();
+ propagatedHeaders.putSingle(config.token().headerParam(), token);
+ return Uni.createFrom().item(propagatedHeaders);
+ }
+ })
.build(DataClientApi.class);
try (var response = client.updateDate(spec.getData())) {
@@ -41,6 +61,20 @@ public int updateData(Data data) {
}
}
+ private String createToken(Data data) {
+
+ var userName = config.token().userName();
+ var orgId = data.getSpec().getOrgId();
+
+ JsonObjectBuilder claims = Json.createObjectBuilder();
+ claims.add(Claims.preferred_username.name(), userName);
+ claims.add(Claims.sub.name(), userName);
+ if (orgId != null) {
+ claims.add(config.token().claimOrganizationParam(), orgId);
+ }
+ return Jwt.claims(claims.build()).sign(KeyFactory.PRIVATE_KEY);
+ }
+
public static class MissingKeyConfiguration extends RuntimeException {
public MissingKeyConfiguration(String key) {
diff --git a/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/KeyFactory.java b/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/KeyFactory.java
new file mode 100644
index 0000000..3be0af2
--- /dev/null
+++ b/src/main/java/org/tkit/onecx/data/orchestrator/operator/client/KeyFactory.java
@@ -0,0 +1,35 @@
+package org.tkit.onecx.data.orchestrator.operator.client;
+
+import java.security.NoSuchAlgorithmException;
+import java.security.PrivateKey;
+
+import io.smallrye.jwt.util.KeyUtils;
+
+class KeyFactory {
+
+ static final PrivateKey PRIVATE_KEY = createKey();
+
+ static PrivateKey createKey() {
+ return createKey(new KeyFactory());
+ }
+
+ static PrivateKey createKey(KeyFactory kf) {
+ try {
+ return kf.createPrivateKey();
+ } catch (NoSuchAlgorithmException ex) {
+ throw new KeyFactoryException(ex);
+ }
+ }
+
+ PrivateKey createPrivateKey() throws NoSuchAlgorithmException {
+ return KeyUtils.generateKeyPair(2048).getPrivate();
+ }
+
+ public static class KeyFactoryException extends RuntimeException {
+
+ public KeyFactoryException(Throwable ex) {
+ super(ex);
+ }
+ }
+
+}
diff --git a/src/test/java/org/tkit/onecx/data/orchestrator/operator/DataControllerTest.java b/src/test/java/org/tkit/onecx/data/orchestrator/operator/DataControllerTest.java
index 42e57fc..9106960 100644
--- a/src/test/java/org/tkit/onecx/data/orchestrator/operator/DataControllerTest.java
+++ b/src/test/java/org/tkit/onecx/data/orchestrator/operator/DataControllerTest.java
@@ -72,6 +72,7 @@ private static DataSpec createSpec(String key, String data) {
spec.setKey(key);
spec.setDescription("description");
spec.setData(data);
+ spec.setOrgId("default");
return spec;
}
diff --git a/src/test/java/org/tkit/onecx/data/orchestrator/operator/client/KeyFactoryTest.java b/src/test/java/org/tkit/onecx/data/orchestrator/operator/client/KeyFactoryTest.java
new file mode 100644
index 0000000..f55ecfb
--- /dev/null
+++ b/src/test/java/org/tkit/onecx/data/orchestrator/operator/client/KeyFactoryTest.java
@@ -0,0 +1,25 @@
+package org.tkit.onecx.data.orchestrator.operator.client;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.catchThrowableOfType;
+
+import java.security.NoSuchAlgorithmException;
+
+import org.junit.jupiter.api.Test;
+import org.mockito.Mockito;
+import org.tkit.onecx.data.orchestrator.operator.AbstractTest;
+
+import io.quarkus.test.junit.QuarkusTest;
+
+@QuarkusTest
+class KeyFactoryTest extends AbstractTest {
+
+ @Test
+ void createKeyFailedTest() throws NoSuchAlgorithmException {
+ var mock = Mockito.mock(KeyFactory.class);
+ Mockito.when(mock.createPrivateKey()).thenThrow(new NoSuchAlgorithmException());
+ KeyFactory.KeyFactoryException throwable = catchThrowableOfType(() -> KeyFactory.createKey(mock),
+ KeyFactory.KeyFactoryException.class);
+ assertThat(throwable).isNotNull();
+ }
+}
diff --git a/src/test/resources/mockserver/onecx-mock.json b/src/test/resources/mockserver/onecx-mock.json
index 570e20f..e408f8f 100644
--- a/src/test/resources/mockserver/onecx-mock.json
+++ b/src/test/resources/mockserver/onecx-mock.json
@@ -1,22 +1,22 @@
[
{
"id": "1",
- "httpRequest": { "method" : "POST", "path": "/workspace" },
+ "httpRequest": { "method" : "POST", "path": "/workspace", "headers": { "apm-principal-token": [ ".*" ] } },
"httpResponse": { "statusCode": 201 }
},
{
"id": "2",
- "httpRequest": { "method" : "POST", "path": "/permission" },
+ "httpRequest": { "method" : "POST", "path": "/permission", "headers": { "apm-principal-token": [ ".*" ] } },
"httpResponse": { "statusCode": 200 }
},
{
"id": "3",
- "httpRequest": { "method" : "POST", "path": "/tenant" },
+ "httpRequest": { "method" : "POST", "path": "/tenant", "headers": { "apm-principal-token": [ ".*" ] } },
"httpResponse": { "statusCode": 500 }
},
{
"id": "4",
- "httpRequest": { "method" : "POST", "path": "/theme" },
+ "httpRequest": { "method" : "POST", "path": "/theme", "headers": { "apm-principal-token": [ ".*" ] } },
"httpResponse": { "statusCode": 400 }
}
]
\ No newline at end of file