use of org.cloudfoundry.identity.uaa.approval.ApprovalStore in project uaa by cloudfoundry.
the class ScimUserEndpointDocs method setUp.
@BeforeEach
void setUp() throws Exception {
userProvisioning = webApplicationContext.getBean(ScimUserProvisioning.class);
scimReadToken = MockMvcUtils.getClientCredentialsOAuthAccessToken(mockMvc, "admin", "adminsecret", "scim.read", null, true);
scimWriteToken = MockMvcUtils.getClientCredentialsOAuthAccessToken(mockMvc, "admin", "adminsecret", "scim.write", null, true);
user = createScimUserObject();
user = MockMvcUtils.createUser(mockMvc, scimWriteToken, user);
ApprovalStore approvalStore = webApplicationContext.getBean(ApprovalStore.class);
approvalStore.addApproval(new Approval().setClientId("client id").setUserId(user.getId()).setExpiresAt(new Date(System.currentTimeMillis() + 10000)).setScope("scim.read").setStatus(Approval.ApprovalStatus.APPROVED), IdentityZoneHolder.get().getId());
}
use of org.cloudfoundry.identity.uaa.approval.ApprovalStore in project uaa by cloudfoundry.
the class ScimUserEndpointDocs method test_Update_User.
@Test
void test_Update_User() throws Exception {
ApprovalStore store = webApplicationContext.getBean(ApprovalStore.class);
Approval approval = new Approval().setUserId(user.getId()).setStatus(Approval.ApprovalStatus.DENIED).setScope("uaa.user").setClientId("identity").setExpiresAt(new Date(System.currentTimeMillis() + 30000)).setLastUpdatedAt(new Date(System.currentTimeMillis() + 30000));
store.addApproval(approval, IdentityZoneHolder.get().getId());
user.setGroups(Collections.emptyList());
mockMvc.perform(RestDocumentationRequestBuilders.put("/Users/{userId}", user.getId()).accept(APPLICATION_JSON).header("Authorization", "Bearer " + scimWriteToken).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).header("If-Match", user.getVersion()).content(JsonUtils.writeValueAsString(user))).andExpect(status().isOk()).andDo(document("{ClassName}/{methodName}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()), pathParameters(parameterWithName("userId").description(userIdDescription)), requestHeaders(headerWithName("Authorization").description(requiredUserUpdateScopes), headerWithName("If-Match").description("The version of the SCIM object to be updated. Wildcard (*) accepted."), IDENTITY_ZONE_ID_HEADER, IDENTITY_ZONE_SUBDOMAIN_HEADER), updateFields, responseFields(updateResponse)));
}
use of org.cloudfoundry.identity.uaa.approval.ApprovalStore in project uaa by cloudfoundry.
the class ScimUserEndpointDocs method test_Delete_User.
@Test
void test_Delete_User() throws Exception {
ApprovalStore store = webApplicationContext.getBean(ApprovalStore.class);
Approval approval = new Approval().setUserId(user.getId()).setStatus(Approval.ApprovalStatus.APPROVED).setScope("uaa.user").setClientId("identity").setExpiresAt(new Date(System.currentTimeMillis() + 30000)).setLastUpdatedAt(new Date(System.currentTimeMillis() + 30000));
store.addApproval(approval, IdentityZoneHolder.get().getId());
mockMvc.perform(RestDocumentationRequestBuilders.delete("/Users/{userId}", user.getId()).accept(APPLICATION_JSON).header("Authorization", "Bearer " + scimWriteToken).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).header("If-Match", user.getVersion())).andExpect(status().isOk()).andDo(document("{ClassName}/{methodName}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()), pathParameters(parameterWithName("userId").description(userIdDescription)), requestHeaders(headerWithName("Authorization").description("Access token with `scim.write` or `uaa.admin` required"), headerWithName("If-Match").optional().description("The version of the SCIM object to be deleted. Optional."), IDENTITY_ZONE_ID_HEADER, IDENTITY_ZONE_SUBDOMAIN_HEADER), responseFields(updateResponse)));
}
use of org.cloudfoundry.identity.uaa.approval.ApprovalStore in project uaa by cloudfoundry.
the class ScimUserEndpointDocs method test_Get_User.
@Test
void test_Get_User() throws Exception {
ApprovalStore store = webApplicationContext.getBean(ApprovalStore.class);
Approval approval = new Approval().setUserId(user.getId()).setStatus(Approval.ApprovalStatus.APPROVED).setScope("uaa.user").setClientId("identity").setExpiresAt(new Date(System.currentTimeMillis() + 30000)).setLastUpdatedAt(new Date(System.currentTimeMillis() + 30000));
store.addApproval(approval, IdentityZoneHolder.get().getId());
webApplicationContext.getBean(UaaUserDatabase.class).updateLastLogonTime(user.getId());
webApplicationContext.getBean(UaaUserDatabase.class).updateLastLogonTime(user.getId());
mockMvc.perform(RestDocumentationRequestBuilders.get("/Users/{userId}", user.getId()).accept(APPLICATION_JSON).header("Authorization", "Bearer " + scimReadToken).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).header("If-Match", user.getVersion())).andExpect(status().isOk()).andExpect(jsonPath("$.previousLogonTime").exists()).andExpect(jsonPath("$.lastLogonTime").exists()).andDo(document("{ClassName}/{methodName}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()), pathParameters(parameterWithName("userId").description(userIdDescription)), requestHeaders(headerWithName("Authorization").description("Access token with scope `scim.read`, `uaa.admin`, or `zones.uaa.admin` required"), headerWithName("If-Match").optional().description("The version of the SCIM object to be deleted. Optional."), IDENTITY_ZONE_ID_HEADER, IDENTITY_ZONE_SUBDOMAIN_HEADER), responseFields(updateResponse)));
}
use of org.cloudfoundry.identity.uaa.approval.ApprovalStore in project uaa by cloudfoundry.
the class ScimUserEndpointDocs method test_Patch_User.
@Test
void test_Patch_User() throws Exception {
ApprovalStore store = webApplicationContext.getBean(ApprovalStore.class);
Approval approval = new Approval().setUserId(user.getId()).setStatus(Approval.ApprovalStatus.DENIED).setScope("uaa.user").setClientId("identity").setExpiresAt(new Date(System.currentTimeMillis() + 30000)).setLastUpdatedAt(new Date(System.currentTimeMillis() + 30000));
store.addApproval(approval, IdentityZoneHolder.get().getId());
user.setGroups(Collections.emptyList());
mockMvc.perform(RestDocumentationRequestBuilders.patch("/Users/{userId}", user.getId()).accept(APPLICATION_JSON).header("Authorization", "Bearer " + scimWriteToken).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).header("If-Match", user.getVersion()).content(JsonUtils.writeValueAsString(user))).andExpect(status().isOk()).andDo(document("{ClassName}/{methodName}", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()), pathParameters(parameterWithName("userId").description(userIdDescription)), requestHeaders(headerWithName("Authorization").description(requiredUserUpdateScopes), headerWithName("If-Match").description("The version of the SCIM object to be updated. Wildcard (*) accepted.")), patchFields, responseFields(updateResponse)));
}
Aggregations