From 38670df49a39e2bcc256c7d4d56c6382c9ce54a1 Mon Sep 17 00:00:00 2001 From: Guus der Kinderen Date: Fri, 8 Apr 2016 16:34:46 +0200 Subject: [PATCH] KEYCLOAK-2785: Admin client should be able to delete a user. The delete user service should be exposed in the admin client. --- .../admin/client/resource/UsersResource.java | 11 ++++------- .../org/keycloak/testsuite/admin/UserTest.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/UsersResource.java b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/UsersResource.java index 9497f3a67a..93a0638b8c 100755 --- a/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/UsersResource.java +++ b/integration/admin-client/src/main/java/org/keycloak/admin/client/resource/UsersResource.java @@ -19,13 +19,7 @@ package org.keycloak.admin.client.resource; import org.keycloak.representations.idm.UserRepresentation; -import javax.ws.rs.Consumes; -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.QueryParam; +import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import java.util.List; @@ -59,4 +53,7 @@ public interface UsersResource { @Path("{id}") UserResource get(@PathParam("id") String id); + @Path("{id}") + @DELETE + Response delete(@PathParam("id") String id); } diff --git a/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java b/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java index eafe169a74..c2f4b7c010 100755 --- a/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java +++ b/testsuite/integration/src/test/java/org/keycloak/testsuite/admin/UserTest.java @@ -239,6 +239,20 @@ public class UserTest extends AbstractClientTest { assertEquals(9, count.intValue()); } + @Test + public void delete() { + Response response = realm.users().delete( createUser() ); + assertEquals(204, response.getStatus()); + response.close(); + } + + @Test + public void deleteNonExistent() { + Response response = realm.users().delete( "does-not-exist" ); + assertEquals(404, response.getStatus()); + response.close(); + } + @Test public void searchPaginated() { createUsers();