From e95867b32f5152cf4ca66faf9577f840bd0614b0 Mon Sep 17 00:00:00 2001 From: Salvatore Coppola Date: Wed, 4 Oct 2023 15:27:24 +0200 Subject: [PATCH] Revert "deleteUser has again a path parameter" This reverts commit fa214e87cb2669f139b350764280af2fed0b7e31. --- .../provider/IdentityRestService.java | 8 ++--- .../provider/test/IdentityEndpointsTest.java | 31 +++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/kura/org.eclipse.kura.rest.identity.provider/src/main/java/org/eclipse/kura/internal/rest/identity/provider/IdentityRestService.java b/kura/org.eclipse.kura.rest.identity.provider/src/main/java/org/eclipse/kura/internal/rest/identity/provider/IdentityRestService.java index 897bc854d4a..8c58a8a2ad5 100644 --- a/kura/org.eclipse.kura.rest.identity.provider/src/main/java/org/eclipse/kura/internal/rest/identity/provider/IdentityRestService.java +++ b/kura/org.eclipse.kura.rest.identity.provider/src/main/java/org/eclipse/kura/internal/rest/identity/provider/IdentityRestService.java @@ -20,7 +20,6 @@ import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; -import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; @@ -116,11 +115,12 @@ public Response createUser(final UserDTO userName) { @DELETE @RolesAllowed(REST_ROLE_NAME) - @Path("/users/{userName}") - public Response deleteUser(@PathParam("userName") final String userName) { + @Path("/users") + @Consumes(MediaType.APPLICATION_JSON) + public Response deleteUser(final UserDTO userName) { try { logger.debug(DEBUG_MESSAGE, "deleteUser"); - this.identityService.deleteUser(userName); + this.identityService.deleteUser(userName.getUserName()); } catch (Exception e) { throw DefaultExceptionHandler.toWebApplicationException(e); } diff --git a/kura/test/org.eclipse.kura.rest.identity.provider.test/src/main/java/org/eclipse/kura/internal/rest/identity/provider/test/IdentityEndpointsTest.java b/kura/test/org.eclipse.kura.rest.identity.provider.test/src/main/java/org/eclipse/kura/internal/rest/identity/provider/test/IdentityEndpointsTest.java index 72feec8aa4b..394a880bb6d 100644 --- a/kura/test/org.eclipse.kura.rest.identity.provider.test/src/main/java/org/eclipse/kura/internal/rest/identity/provider/test/IdentityEndpointsTest.java +++ b/kura/test/org.eclipse.kura.rest.identity.provider.test/src/main/java/org/eclipse/kura/internal/rest/identity/provider/test/IdentityEndpointsTest.java @@ -100,8 +100,8 @@ public void shouldInvokeDeleteUserSuccessfully() { givenUser(new UserDTO("testuser", Collections.emptySet(), true, false, "testpassw")); - whenRequestIsPerformed(new MethodSpec(METHOD_SPEC_DELETE, MQTT_METHOD_SPEC_DEL), - "/users/" + this.user.getUserName()); + whenRequestIsPerformed(new MethodSpec(METHOD_SPEC_DELETE, MQTT_METHOD_SPEC_DEL), "/users", + gson.toJson(this.user)); thenRequestSucceeds(); thenResponseBodyIsEmpty(); @@ -168,6 +168,33 @@ private static void givenIdentityService() { when(identityServiceMock.getUserConfig()).thenReturn(userConfigs); } + // @Test + // public void shouldRethrowWebApplicationExceptionOnReloadSecurityPolicyFingerprint() throws KuraException { + // givenFailingIdentityService(); + // + // whenRequestIsPerformed(new MethodSpec(METHOD_SPEC_POST), "/security-policy-fingerprint/reload"); + // + // thenResponseCodeIs(Status.INTERNAL_SERVER_ERROR.getStatusCode()); + // } + // + // @Test + // public void shouldRethrowWebApplicationExceptionOnReloadCommandLineFingerprint() throws KuraException { + // givenFailingIdentityService(); + // + // whenRequestIsPerformed(new MethodSpec(METHOD_SPEC_POST), "/command-line-fingerprint/reload"); + // + // thenResponseCodeIs(Status.INTERNAL_SERVER_ERROR.getStatusCode()); + // } + // + // @Test + // public void shouldRethrowWebApplicationExceptionOnGetDebugStatus() throws KuraException { + // givenFailingIdentityService(); + // + // whenRequestIsPerformed(new MethodSpec(METHOD_SPEC_GET), "/debug-enabled"); + // + // thenResponseCodeIs(Status.INTERNAL_SERVER_ERROR.getStatusCode()); + // } + @BeforeClass public static void setUp() throws Exception { createIdentityServiceMock();