diff --git a/src/main/helm/crds/permissions.onecx.tkit.org-v1.yml b/src/main/helm/crds/permissions.onecx.tkit.org-v1.yml index 947be67..9b47b1b 100644 --- a/src/main/helm/crds/permissions.onecx.tkit.org-v1.yml +++ b/src/main/helm/crds/permissions.onecx.tkit.org-v1.yml @@ -11,44 +11,46 @@ spec: singular: permission scope: Namespaced versions: - - name: v1 - schema: - openAPIV3Schema: - properties: - spec: - properties: - appId: - type: string - description: - type: string - name: - type: string - permissions: - additionalProperties: + - name: v1 + schema: + openAPIV3Schema: + properties: + spec: + properties: + appId: + type: string + description: + type: string + name: + type: string + permissions: additionalProperties: - type: string + additionalProperties: + type: string + type: object type: object - type: object - type: object - status: - properties: - appId: - type: string - message: - type: string - observedGeneration: - type: integer - response-code: - type: integer - status: - enum: - - ERROR - - UNDEFINED - - UPDATED - type: string - type: object - type: object - served: true - storage: true - subresources: - status: {} + productName: + type: string + type: object + status: + properties: + appId: + type: string + message: + type: string + observedGeneration: + type: integer + response-code: + type: integer + status: + enum: + - ERROR + - UNDEFINED + - UPDATED + type: string + type: object + type: object + served: true + storage: true + subresources: + status: {} diff --git a/src/main/java/org/tkit/onecx/permission/operator/PermissionSpec.java b/src/main/java/org/tkit/onecx/permission/operator/PermissionSpec.java index 39e1dc9..bae17fd 100644 --- a/src/main/java/org/tkit/onecx/permission/operator/PermissionSpec.java +++ b/src/main/java/org/tkit/onecx/permission/operator/PermissionSpec.java @@ -11,6 +11,9 @@ public class PermissionSpec { @JsonProperty(value = "appId", required = true) private String appId; + @JsonProperty(value = "productName", required = true) + private String productName; + @JsonProperty(value = "name", required = true) private String name; @@ -20,6 +23,14 @@ public class PermissionSpec { @JsonProperty("permissions") private Map> permissions; + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + public String getAppId() { return appId; } diff --git a/src/main/java/org/tkit/onecx/permission/operator/client/PermissionService.java b/src/main/java/org/tkit/onecx/permission/operator/client/PermissionService.java index 2ba8283..43b5eb0 100644 --- a/src/main/java/org/tkit/onecx/permission/operator/client/PermissionService.java +++ b/src/main/java/org/tkit/onecx/permission/operator/client/PermissionService.java @@ -26,7 +26,7 @@ public class PermissionService { public int updatePermission(Permission permission) { var spec = permission.getSpec(); var dto = mapper.map(spec); - try (var response = client.createOrUpdatePermission(spec.getAppId(), dto)) { + try (var response = client.createOrUpdatePermission(spec.getProductName(), spec.getAppId(), dto)) { log.info("Update permission appId {} status {}", spec.getAppId(), response.getStatus()); return response.getStatus(); } diff --git a/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerResponseTest.java b/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerResponseTest.java index 0278189..4c78ab9 100644 --- a/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerResponseTest.java +++ b/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerResponseTest.java @@ -38,6 +38,7 @@ void testWrongResponse() throws Exception { p1.put("r1", Map.of("a2", "d1")); var s = new PermissionSpec(); + s.setProductName("test1"); s.setAppId("test-3"); s.setPermissions(p1); diff --git a/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerTest.java b/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerTest.java index d42f3ee..c2d2bb0 100644 --- a/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerTest.java +++ b/src/test/java/org/tkit/onecx/permission/operator/PermissionControllerTest.java @@ -92,6 +92,7 @@ void productUpdateEmptySpecTest() { p1.put("r1", Map.of("a2", "d1")); var m = new PermissionSpec(); + m.setProductName("test1"); m.setAppId("test-3"); m.setPermissions(p1); @@ -135,6 +136,7 @@ void productUpdateNoDescriptionTest() { p1.put("r1", a); var m = new PermissionSpec(); + m.setProductName("test1"); m.setAppId("test-3"); m.setName("test-3"); m.setDescription("description"); @@ -160,6 +162,7 @@ void productRestClientExceptionTest() { p1.put("r1", Map.of("a2", "d1")); var m = new PermissionSpec(); + m.setProductName("test1"); m.setAppId("test-error-1"); m.setPermissions(p1); diff --git a/src/test/resources/mockserver/permission-mock.json b/src/test/resources/mockserver/permission-mock.json index 5514f5c..45bc473 100644 --- a/src/test/resources/mockserver/permission-mock.json +++ b/src/test/resources/mockserver/permission-mock.json @@ -3,7 +3,7 @@ "id": "3", "httpRequest": { "method" : "PUT", - "path": "/operator/v1/update/test-3" + "path": "/operator/v1/test1/test-3" }, "httpResponse": { "statusCode": 200 @@ -13,7 +13,7 @@ "id": "4", "httpRequest": { "method" : "PUT", - "path": "/operator/v1/update/test-error-1" + "path": "/operator/v1/test1/test-error-1" }, "httpResponse": { "statusCode": 500