Search in sources :

Example 1 with ScimGroup

use of org.cloudfoundry.identity.uaa.scim.ScimGroup in project uaa by cloudfoundry.

the class ScimGroupEndpointsTests method addGroup.

private String addGroup(String name, List<ScimGroupMember> m) {
    ScimGroup g = new ScimGroup(null, name, identityZoneManager.getCurrentIdentityZoneId());
    g = jdbcScimGroupProvisioning.create(g, identityZoneManager.getCurrentIdentityZoneId());
    for (ScimGroupMember member : m) {
        jdbcScimGroupMembershipManager.addMember(g.getId(), member, identityZoneManager.getCurrentIdentityZoneId());
    }
    return g.getId();
}
Also used : ScimGroupMember(org.cloudfoundry.identity.uaa.scim.ScimGroupMember) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup)

Example 2 with ScimGroup

use of org.cloudfoundry.identity.uaa.scim.ScimGroup in project uaa by cloudfoundry.

the class ScimGroupEndpointsTests method createGroupWithInvalidMemberFails.

@Test
void createGroupWithInvalidMemberFails() {
    ScimGroup g = new ScimGroup(null, "clients.read", identityZoneManager.getCurrentIdentityZoneId());
    g.setMembers(Collections.singletonList(new ScimGroupMember("non-existent id", ScimGroupMember.Type.USER)));
    try {
        scimGroupEndpoints.createGroup(g, new MockHttpServletResponse());
        fail("must have thrown exception");
    } catch (InvalidScimResourceException ex) {
        // ensure that the group was not created
        validateSearchResults(scimGroupEndpoints.listGroups("id", "displayName eq \"clients.read\"", "id", "ASC", 1, 100), 0);
    }
}
Also used : ScimGroupMember(org.cloudfoundry.identity.uaa.scim.ScimGroupMember) InvalidScimResourceException(org.cloudfoundry.identity.uaa.scim.exception.InvalidScimResourceException) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with ScimGroup

use of org.cloudfoundry.identity.uaa.scim.ScimGroup in project uaa by cloudfoundry.

the class ScimGroupEndpointsTests method getGroup.

@Test
void getGroup() {
    MockHttpServletResponse httpServletResponse = new MockHttpServletResponse();
    ScimGroup g = scimGroupEndpoints.getGroup(groupIds.get(groupIds.size() - 1), httpServletResponse);
    validateGroup(g, "uaa.none", 2);
    assertEquals("\"0\"", httpServletResponse.getHeader("ETag"));
}
Also used : ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with ScimGroup

use of org.cloudfoundry.identity.uaa.scim.ScimGroup in project uaa by cloudfoundry.

the class ScimGroupEndpointsTests method deleteGroupRemovesMembershipsInZone.

@Test
void deleteGroupRemovesMembershipsInZone() {
    IdentityZone zone = MultitenancyFixture.identityZone("test-zone-id", "test");
    zone.getConfig().getUserConfig().setDefaultGroups(emptyList());
    identityZoneManager.setCurrentIdentityZone(zone);
    ScimGroup group = new ScimGroup(null, "clients.read", identityZoneManager.getCurrentIdentityZoneId());
    ScimGroupMember member = createMember(ScimGroupMember.Type.GROUP);
    group.setMembers(Collections.singletonList(member));
    group = scimGroupEndpoints.createGroup(group, new MockHttpServletResponse());
    scimGroupEndpoints.deleteGroup(member.getMemberId(), "*", new MockHttpServletResponse());
    List<ScimGroupMember> members = scimGroupEndpoints.listGroupMemberships(group.getId(), true, "").getBody();
    assertEquals(0, members.size());
}
Also used : IdentityZone(org.cloudfoundry.identity.uaa.zone.IdentityZone) ScimGroupMember(org.cloudfoundry.identity.uaa.scim.ScimGroupMember) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with ScimGroup

use of org.cloudfoundry.identity.uaa.scim.ScimGroup in project uaa by cloudfoundry.

the class ScimUserEndpointsTests method groupsIsSyncedCorrectlyOnGet.

@Test
void groupsIsSyncedCorrectlyOnGet() {
    ScimUser user = new ScimUser(null, "dave", "David", "Syer");
    user.setPassword("password");
    user.addEmail("dsyer@vmware.com");
    ScimUser created = scimUserEndpoints.createUser(user, new MockHttpServletRequest(), new MockHttpServletResponse());
    validateUserGroups(created, "uaa.user");
    ScimGroup g = new ScimGroup(null, "test1", identityZone.getId());
    g.setMembers(Collections.singletonList(new ScimGroupMember(created.getId())));
    scimGroupEndpoints.createGroup(g, new MockHttpServletResponse());
    validateUserGroups(scimUserEndpoints.getUser(created.getId(), new MockHttpServletResponse()), "test1");
}
Also used : ScimUser(org.cloudfoundry.identity.uaa.scim.ScimUser) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) ScimGroupMember(org.cloudfoundry.identity.uaa.scim.ScimGroupMember) ScimGroup(org.cloudfoundry.identity.uaa.scim.ScimGroup) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) Test(org.junit.jupiter.api.Test)

Aggregations

ScimGroup (org.cloudfoundry.identity.uaa.scim.ScimGroup)141 Test (org.junit.jupiter.api.Test)61 ScimGroupMember (org.cloudfoundry.identity.uaa.scim.ScimGroupMember)46 ScimUser (org.cloudfoundry.identity.uaa.scim.ScimUser)33 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)24 IdentityZone (org.cloudfoundry.identity.uaa.zone.IdentityZone)16 Test (org.junit.Test)16 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)15 Matchers.containsString (org.hamcrest.Matchers.containsString)13 RandomValueStringGenerator (org.springframework.security.oauth2.common.util.RandomValueStringGenerator)13 Map (java.util.Map)12 ScimException (org.cloudfoundry.identity.uaa.scim.exception.ScimException)12 JdbcScimGroupProvisioning (org.cloudfoundry.identity.uaa.scim.jdbc.JdbcScimGroupProvisioning)12 List (java.util.List)11 ArrayList (java.util.ArrayList)10 SearchResults (org.cloudfoundry.identity.uaa.resources.SearchResults)10 ScimGroupExternalMember (org.cloudfoundry.identity.uaa.scim.ScimGroupExternalMember)10 BeforeEach (org.junit.jupiter.api.BeforeEach)10 ScimGroupProvisioning (org.cloudfoundry.identity.uaa.scim.ScimGroupProvisioning)9