Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JSON-API] Remove /user/delete GET endpoint #12486

Merged
merged 1 commit into from
Jan 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -384,44 +384,6 @@ class HttpServiceIntegrationTestUserManagementNoAuth
getResult(output3).convertTo[List[UserDetails]] should not contain createUserRequest.userId
}
}

"deleting the current user should be possible via the user/delete endpoint" in withHttpServiceAndClient(
participantAdminJwt
) { (uri, _, _, _, _) =>
import spray.json._
import spray.json.DefaultJsonProtocol._
val alice = getUniqueParty("Alice")
val createUserRequest = domain.CreateUserRequest(
getUniqueUserName("nice.user"),
Some(alice.unwrap),
List(alice),
List.empty,
isAdmin = true,
)
for {
(status1, output1) <- postRequest(
uri.withPath(Uri.Path("/v1/user/create")),
createUserRequest.toJson,
headers = authorizationHeader(participantAdminJwt),
)
_ <- {
status1 shouldBe StatusCodes.OK
getResult(output1).convertTo[Boolean] shouldBe true
}
(status2, _) <- getRequest(
uri.withPath(Uri.Path(s"/v1/user/delete")),
headers = headersWithUserAuth(createUserRequest.userId),
)
_ = status2 shouldBe StatusCodes.OK
(status3, output3) <- getRequest(
uri.withPath(Uri.Path("/v1/users")),
headers = authorizationHeader(participantAdminJwt),
)
} yield {
status3 shouldBe StatusCodes.OK
getResult(output3).convertTo[List[UserDetails]] should not contain createUserRequest.userId
}
}
}

class HttpServiceIntegrationTestUserManagement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ class Endpoints(
path("query") & withTimer(queryAllTimer) apply
toRoute(retrieveAll(req)),
path("user") apply toRoute(getAuthenticatedUser(req)),
path("user" / "delete") apply toRoute(deleteAuthenticatedUser(req)),
path("user" / "rights") apply toRoute(
listAuthenticatedUserRights(req)
),
Expand Down Expand Up @@ -496,15 +495,6 @@ class Endpoints(
} yield domain.OkResponse(true): domain.SyncResponse[Boolean]
}(req)

def deleteAuthenticatedUser(req: HttpRequest)(implicit
lc: LoggingContextOf[InstanceUUID with RequestID]
): ET[domain.SyncResponse[Boolean]] =
for {
jwt <- eitherT(input(req)).bimap(identity[Error], _._1)
userId <- decodeAndParseUserIdFromToken(jwt, decodeJwt).leftMap(identity[Error])
_ <- EitherT.rightT(userManagementClient.deleteUser(userId, Some(jwt.value)))
} yield domain.OkResponse(true)

def listUsers(req: HttpRequest)(implicit
lc: LoggingContextOf[InstanceUUID with RequestID]
): ET[domain.SyncResponse[List[domain.UserDetails]]] =
Expand Down