From c20beba6a9307baf89654ec590eab55ae6967861 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 30 Sep 2024 15:21:59 -0400 Subject: [PATCH 1/4] Removes unused get/post/put cache endpoint Signed-off-by: Derek Ho --- .../security/dlic/rest/api/FlushCacheApiAction.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index 2f579ecbd9..373ea68882 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -38,10 +38,7 @@ public class FlushCacheApiAction extends AbstractApiAction { private static final List routes = addRoutesPrefix( ImmutableList.of( - new Route(Method.DELETE, "/cache"), - new Route(Method.GET, "/cache"), - new Route(Method.PUT, "/cache"), - new Route(Method.POST, "/cache") + new Route(Method.DELETE, "/cache") ) ); From bb0abc7d88bb3acf7e2af00d732b5b13f6071cfd Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 30 Sep 2024 15:25:24 -0400 Subject: [PATCH 2/4] Spotless Signed-off-by: Derek Ho --- .../security/dlic/rest/api/FlushCacheApiAction.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java index 373ea68882..0135653524 100644 --- a/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java +++ b/src/main/java/org/opensearch/security/dlic/rest/api/FlushCacheApiAction.java @@ -36,11 +36,7 @@ public class FlushCacheApiAction extends AbstractApiAction { private final static Logger LOGGER = LogManager.getLogger(FlushCacheApiAction.class); - private static final List routes = addRoutesPrefix( - ImmutableList.of( - new Route(Method.DELETE, "/cache") - ) - ); + private static final List routes = addRoutesPrefix(ImmutableList.of(new Route(Method.DELETE, "/cache"))); @Inject public FlushCacheApiAction( From 7e3e1437049040e83aa2699b5188a53b9ed22031 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Mon, 30 Sep 2024 17:08:56 -0400 Subject: [PATCH 3/4] Fix test Signed-off-by: Derek Ho --- .../api/DefaultApiAvailabilityIntegrationTest.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java b/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java index f3b701dc38..a64087e6c4 100644 --- a/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java +++ b/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java @@ -96,15 +96,12 @@ private void verifyAuthInfoApi(final TestRestClient client) throws Exception { @Test public void flushCache() throws Exception { withUser(NEW_USER, client -> { - forbidden(() -> client.get(apiPath("cache"))); - forbidden(() -> client.postJson(apiPath("cache"), EMPTY_BODY)); - forbidden(() -> client.putJson(apiPath("cache"), EMPTY_BODY)); forbidden(() -> client.delete(apiPath("cache"))); }); withUser(ADMIN_USER_NAME, localCluster.getAdminCertificate(), client -> { - notImplemented(() -> client.get(apiPath("cache"))); - notImplemented(() -> client.postJson(apiPath("cache"), EMPTY_BODY)); - notImplemented(() -> client.putJson(apiPath("cache"), EMPTY_BODY)); + methodNotAllowed(() -> client.get(apiPath("cache"))); + methodNotAllowed(() -> client.postJson(apiPath("cache"), EMPTY_BODY)); + methodNotAllowed(() -> client.putJson(apiPath("cache"), EMPTY_BODY)); final var response = ok(() -> client.delete(apiPath("cache"))); assertThat(response.getBody(), response.getTextFromJsonBody("/message"), is("Cache flushed successfully.")); }); From 6498e53d0008c47cc47c3b5bb756d75e60fdf29d Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Tue, 1 Oct 2024 15:46:14 -0400 Subject: [PATCH 4/4] Spotless Apply Signed-off-by: Derek Ho --- .../security/api/DefaultApiAvailabilityIntegrationTest.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java b/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java index a64087e6c4..f28d1e63f9 100644 --- a/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java +++ b/src/integrationTest/java/org/opensearch/security/api/DefaultApiAvailabilityIntegrationTest.java @@ -95,9 +95,7 @@ private void verifyAuthInfoApi(final TestRestClient client) throws Exception { @Test public void flushCache() throws Exception { - withUser(NEW_USER, client -> { - forbidden(() -> client.delete(apiPath("cache"))); - }); + withUser(NEW_USER, client -> { forbidden(() -> client.delete(apiPath("cache"))); }); withUser(ADMIN_USER_NAME, localCluster.getAdminCertificate(), client -> { methodNotAllowed(() -> client.get(apiPath("cache"))); methodNotAllowed(() -> client.postJson(apiPath("cache"), EMPTY_BODY));