Search in sources :

Example 1 with ApprovalStore

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());
}
Also used : ApprovalStore(org.cloudfoundry.identity.uaa.approval.ApprovalStore) Approval(org.cloudfoundry.identity.uaa.approval.Approval) ScimUserProvisioning(org.cloudfoundry.identity.uaa.scim.ScimUserProvisioning) Date(java.util.Date) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ApprovalStore

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)));
}
Also used : ApprovalStore(org.cloudfoundry.identity.uaa.approval.ApprovalStore) Approval(org.cloudfoundry.identity.uaa.approval.Approval) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 3 with ApprovalStore

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)));
}
Also used : ApprovalStore(org.cloudfoundry.identity.uaa.approval.ApprovalStore) Approval(org.cloudfoundry.identity.uaa.approval.Approval) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 4 with ApprovalStore

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)));
}
Also used : ApprovalStore(org.cloudfoundry.identity.uaa.approval.ApprovalStore) Approval(org.cloudfoundry.identity.uaa.approval.Approval) UaaUserDatabase(org.cloudfoundry.identity.uaa.user.UaaUserDatabase) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 5 with ApprovalStore

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)));
}
Also used : ApprovalStore(org.cloudfoundry.identity.uaa.approval.ApprovalStore) Approval(org.cloudfoundry.identity.uaa.approval.Approval) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

ApprovalStore (org.cloudfoundry.identity.uaa.approval.ApprovalStore)9 Approval (org.cloudfoundry.identity.uaa.approval.Approval)7 Test (org.junit.jupiter.api.Test)6 Date (java.util.Date)5 BaseClientDetails (org.springframework.security.oauth2.provider.client.BaseClientDetails)3 BeforeEach (org.junit.jupiter.api.BeforeEach)2 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)2 HashSet (java.util.HashSet)1 ApprovalService (org.cloudfoundry.identity.uaa.approval.ApprovalService)1 EntityDeletedEvent (org.cloudfoundry.identity.uaa.audit.event.EntityDeletedEvent)1 ClientDetailsModification (org.cloudfoundry.identity.uaa.oauth.client.ClientDetailsModification)1 IdentityProvider (org.cloudfoundry.identity.uaa.provider.IdentityProvider)1 IdentityProviderProvisioning (org.cloudfoundry.identity.uaa.provider.IdentityProviderProvisioning)1 JdbcIdentityProviderProvisioning (org.cloudfoundry.identity.uaa.provider.JdbcIdentityProviderProvisioning)1 ResourceMonitor (org.cloudfoundry.identity.uaa.resources.ResourceMonitor)1 ScimUser (org.cloudfoundry.identity.uaa.scim.ScimUser)1 ScimUserProvisioning (org.cloudfoundry.identity.uaa.scim.ScimUserProvisioning)1 ScimResourceNotFoundException (org.cloudfoundry.identity.uaa.scim.exception.ScimResourceNotFoundException)1 JdbcScimGroupProvisioning (org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupProvisioning)1 SecurityContextAccessor (org.cloudfoundry.identity.uaa.security.beans.SecurityContextAccessor)1