diff --git a/src/main/java/com/epam/aidial/core/controller/ControllerSelector.java b/src/main/java/com/epam/aidial/core/controller/ControllerSelector.java index ebff4ad27..d2fecccee 100644 --- a/src/main/java/com/epam/aidial/core/controller/ControllerSelector.java +++ b/src/main/java/com/epam/aidial/core/controller/ControllerSelector.java @@ -48,10 +48,10 @@ public class ControllerSelector { private static final Pattern SHARE_RESOURCE_OPERATIONS = Pattern.compile("^/v1/ops/resource/share/(create|list|discard|revoke|copy)$"); private static final Pattern INVITATIONS = Pattern.compile("^/v1/invitations$"); private static final Pattern INVITATION = Pattern.compile("^/v1/invitations/([a-zA-Z0-9]+)$"); - private static final Pattern PUBLICATIONS = Pattern.compile("^/v1/ops/publications/(list|get|create|delete|approve|reject)$"); - private static final Pattern PUBLICATION_RULES = Pattern.compile("^/v1/ops/publications/rules/list$"); + private static final Pattern PUBLICATIONS = Pattern.compile("^/v1/ops/publication/(list|get|create|delete|approve|reject)$"); + private static final Pattern PUBLICATION_RULES = Pattern.compile("^/v1/ops/publication/rule/list$"); - private static final Pattern RESOURCE_OPERATIONS = Pattern.compile("^/v1/ops/resources/(move)$"); + private static final Pattern RESOURCE_OPERATIONS = Pattern.compile("^/v1/ops/resource/(move)$"); private static final Pattern DEPLOYMENT_LIMITS = Pattern.compile("^/v1/deployments/([^/]+)/limits$"); diff --git a/src/test/java/com/epam/aidial/core/PublicationApiTest.java b/src/test/java/com/epam/aidial/core/PublicationApiTest.java index 0ecc26e8c..7f3fdb47d 100644 --- a/src/test/java/com/epam/aidial/core/PublicationApiTest.java +++ b/src/test/java/com/epam/aidial/core/PublicationApiTest.java @@ -55,21 +55,21 @@ void testPublicationCreation() { Response response = resourceRequest(HttpMethod.PUT, "/my/folder/conversation", CONVERSATION_BODY_1); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); + response = operationRequest("/v1/ops/publication/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); verifyJson(response, 200, PUBLICATION_RESPONSE); - response = operationRequest("/v1/ops/publications/get", PUBLICATION_URL); + response = operationRequest("/v1/ops/publication/get", PUBLICATION_URL); verifyJson(response, 200, PUBLICATION_RESPONSE); - response = operationRequest("/v1/ops/publications/get", PUBLICATION_URL, "authorization", "admin"); + response = operationRequest("/v1/ops/publication/get", PUBLICATION_URL, "authorization", "admin"); verifyJson(response, 200, PUBLICATION_RESPONSE); - response = operationRequest("/v1/ops/publications/get", PUBLICATION_URL, "authorization", "user"); + response = operationRequest("/v1/ops/publication/get", PUBLICATION_URL, "authorization", "user"); verify(response, 403); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ { "url": "publications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/" } @@ -112,14 +112,14 @@ void testPublicationDeletion() { Response response = resourceRequest(HttpMethod.PUT, "/my/folder/conversation", CONVERSATION_BODY_1); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); + response = operationRequest("/v1/ops/publication/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/delete", PUBLICATION_URL, "authorization", "user"); + response = operationRequest("/v1/ops/publication/delete", PUBLICATION_URL, "authorization", "user"); verify(response, 403); - response = operationRequest("/v1/ops/publications/delete", PUBLICATION_URL); + response = operationRequest("/v1/ops/publication/delete", PUBLICATION_URL); verify(response, 200); @@ -138,17 +138,17 @@ void testPublicationApprove() { Response response = resourceRequest(HttpMethod.PUT, "/my/folder/conversation", CONVERSATION_BODY_1); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); + response = operationRequest("/v1/ops/publication/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/approve", PUBLICATION_URL); + response = operationRequest("/v1/ops/publication/approve", PUBLICATION_URL); verify(response, 403); - response = operationRequest("/v1/ops/publications/approve", PUBLICATION_URL, "authorization", "user"); + response = operationRequest("/v1/ops/publication/approve", PUBLICATION_URL, "authorization", "user"); verify(response, 403); - response = operationRequest("/v1/ops/publications/approve", PUBLICATION_URL, "authorization", "admin"); + response = operationRequest("/v1/ops/publication/approve", PUBLICATION_URL, "authorization", "admin"); verifyJson(response, 200, """ { "url" : "publications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/0123", @@ -207,17 +207,17 @@ void testPublicationReject() { Response response = resourceRequest(HttpMethod.PUT, "/my/folder/conversation", CONVERSATION_BODY_1); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); + response = operationRequest("/v1/ops/publication/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/reject", PUBLICATION_URL); + response = operationRequest("/v1/ops/publication/reject", PUBLICATION_URL); verify(response, 403); - response = operationRequest("/v1/ops/publications/reject", PUBLICATION_URL, "authorization", "user"); + response = operationRequest("/v1/ops/publication/reject", PUBLICATION_URL, "authorization", "user"); verify(response, 403); - response = operationRequest("/v1/ops/publications/reject", PUBLICATION_URL, "authorization", "admin"); + response = operationRequest("/v1/ops/publication/reject", PUBLICATION_URL, "authorization", "admin"); verifyJson(response, 200, """ { "url" : "publications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/0123", @@ -291,7 +291,7 @@ void testResourceList() { verify(response, 200); - response = operationRequest("/v1/ops/publications/create", """ + response = operationRequest("/v1/ops/publication/create", """ { "url": "publications/%s/", "targetUrl": "public/folder1/", @@ -312,13 +312,13 @@ void testResourceList() { """.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/approve", """ + response = operationRequest("/v1/ops/publication/approve", """ {"url": "publications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/0123"} """, "authorization", "admin"); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", """ + response = operationRequest("/v1/ops/publication/create", """ { "url": "publications/%s/", "targetUrl": "public/folder2/", @@ -339,7 +339,7 @@ void testResourceList() { """.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/approve", """ + response = operationRequest("/v1/ops/publication/approve", """ {"url": "publications/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/0124"} """, "authorization", "admin"); verify(response, 200); @@ -453,17 +453,17 @@ void testResourceList() { @Test void testPublicationList() { - Response response = operationRequest("/v1/ops/publications/list", """ + Response response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """); verify(response, 403); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """, "authorization", "user"); verify(response, 403); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """, "authorization", "admin"); verifyJson(response, 200, """ @@ -476,21 +476,21 @@ void testPublicationList() { response = resourceRequest(HttpMethod.PUT, "/my/folder/conversation", CONVERSATION_BODY_1); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); + response = operationRequest("/v1/ops/publication/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """); verify(response, 403); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """, "authorization", "user"); verify(response, 403); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """, "authorization", "admin"); verifyJson(response, 200, """ @@ -505,11 +505,11 @@ void testPublicationList() { """); - response = operationRequest("/v1/ops/publications/approve", PUBLICATION_URL, "authorization", "admin"); + response = operationRequest("/v1/ops/publication/approve", PUBLICATION_URL, "authorization", "admin"); verify(response, 200); - response = operationRequest("/v1/ops/publications/list", """ + response = operationRequest("/v1/ops/publication/list", """ {"url": "publications/public/"} """, "authorization", "admin"); verifyJson(response, 200, """ @@ -521,17 +521,17 @@ void testPublicationList() { @Test void listRules() { - Response response = operationRequest("/v1/ops/publications/rules/list", """ + Response response = operationRequest("/v1/ops/publication/rule/list", """ {"url": ""} """); verify(response, 400); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public"} """); verify(response, 400); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public/"} """); verifyJson(response, 200, """ @@ -540,7 +540,7 @@ void listRules() { } """); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public/"} """, "authorization", "user"); verifyJson(response, 200, """ @@ -549,7 +549,7 @@ void listRules() { } """); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public/"} """, "authorization", "admin"); verifyJson(response, 200, """ @@ -561,14 +561,14 @@ void listRules() { response = resourceRequest(HttpMethod.PUT, "/my/folder/conversation", CONVERSATION_BODY_1); verify(response, 200); - response = operationRequest("/v1/ops/publications/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); + response = operationRequest("/v1/ops/publication/create", PUBLICATION_REQUEST.formatted(bucket, bucket)); verify(response, 200); - response = operationRequest("/v1/ops/publications/approve", PUBLICATION_URL, "authorization", "admin"); + response = operationRequest("/v1/ops/publication/approve", PUBLICATION_URL, "authorization", "admin"); verify(response, 200); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public/folder/"} """, "authorization", "user"); verifyJson(response, 200, """ @@ -583,7 +583,7 @@ void listRules() { } """); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public/folder/"} """, "authorization", "admin"); verifyJson(response, 200, """ @@ -598,7 +598,7 @@ void listRules() { } """); - response = operationRequest("/v1/ops/publications/rules/list", """ + response = operationRequest("/v1/ops/publication/rule/list", """ {"url": "public/folder/"} """); verify(response, 403); diff --git a/src/test/java/com/epam/aidial/core/ResourceOperationApiTest.java b/src/test/java/com/epam/aidial/core/ResourceOperationApiTest.java index 80b5de229..27178eccf 100644 --- a/src/test/java/com/epam/aidial/core/ResourceOperationApiTest.java +++ b/src/test/java/com/epam/aidial/core/ResourceOperationApiTest.java @@ -20,7 +20,7 @@ void testMoveResourceWorkflow() { verifyJson(response, 200, CONVERSATION_BODY_1); // verify move operation - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation", "destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" @@ -54,7 +54,7 @@ void testMoveResourceWorkflowWhenDestinationResourceExists() { verifyJson(response, 200, CONVERSATION_BODY_2); // verify move operation - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation", "destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" @@ -69,7 +69,7 @@ void testMoveResourceWorkflowWhenDestinationResourceExists() { response = resourceRequest(HttpMethod.GET, "/folder2/conversation2"); verifyJson(response, 200, CONVERSATION_BODY_2); - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation", "destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2", @@ -124,7 +124,7 @@ void testMoveOperationCopySharedAccess() { verify(response, 200, CONVERSATION_BODY_1); // verify move operation - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation", "destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" @@ -210,7 +210,7 @@ void testMoveOperationCopySharedAccess() { @Test void testMoveOperationErrors() { // verify sourceUrl must be present - Response response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + Response response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" } @@ -218,7 +218,7 @@ void testMoveOperationErrors() { verify(response, 400); // verify destinationUrl must be present - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation" } @@ -226,7 +226,7 @@ void testMoveOperationErrors() { verify(response, 400); // verify source and dest must be the same type - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation", "destinationUrl": "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" @@ -235,7 +235,7 @@ void testMoveOperationErrors() { verify(response, 400); // verify source must belong to the user - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/7G9WZNcoY26Vy9D7bEgbv6zqbJGfyDp9KZyEbJR4XMZt/folder/conversation", "destinationUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" @@ -244,7 +244,7 @@ void testMoveOperationErrors() { verify(response, 400); // verify move do not support folders - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/", "destinationUrl": "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2" @@ -253,7 +253,7 @@ void testMoveOperationErrors() { verify(response, 400); // verify sourceUrl do not exists - response = send(HttpMethod.POST, "/v1/ops/resources/move", null, """ + response = send(HttpMethod.POST, "/v1/ops/resource/move", null, """ { "sourceUrl": "conversations/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder/conversation", "destinationUrl": "files/3CcedGxCx23EwiVbVmscVktScRyf46KypuBQ65miviST/folder2/conversation2"