Ejemplo n.º 1
0
 @Test
 public void failedAttemptToUpdateUsersNotFatal() throws Exception {
   UaaUser joe = new UaaUser("joe", "password", "*****@*****.**", "Joe", "User");
   ScimUserBootstrap bootstrap = new ScimUserBootstrap(db, gdb, mdb, Arrays.asList(joe));
   bootstrap.afterPropertiesSet();
   joe = new UaaUser("joe", "new", "*****@*****.**", "Joe", "Bloggs");
   bootstrap = new ScimUserBootstrap(db, gdb, mdb, Arrays.asList(joe));
   bootstrap.setOverride(false);
   bootstrap.afterPropertiesSet();
   Collection<ScimUser> users = db.retrieveAll();
   assertEquals(1, users.size());
   assertEquals("User", users.iterator().next().getFamilyName());
 }
Ejemplo n.º 2
0
  @Test
  public void canOverrideAuthorities() throws Exception {
    UaaUser joe = new UaaUser("joe", "password", "*****@*****.**", "Joe", "User");
    joe = joe.authorities(AuthorityUtils.commaSeparatedStringToAuthorityList("openid,read"));
    ScimUserBootstrap bootstrap = new ScimUserBootstrap(db, gdb, mdb, Arrays.asList(joe));
    bootstrap.afterPropertiesSet();
    joe = joe.authorities(AuthorityUtils.commaSeparatedStringToAuthorityList("openid,read,write"));
    bootstrap = new ScimUserBootstrap(db, gdb, mdb, Arrays.asList(joe));
    bootstrap.setOverride(true);
    bootstrap.afterPropertiesSet();
    @SuppressWarnings("unchecked")
    Collection<Map<String, Object>> users =
        (Collection<Map<String, Object>>)
            userEndpoints.findUsers("id", "id pr", "id", "ascending", 1, 100).getResources();
    assertEquals(1, users.size());

    String id = (String) users.iterator().next().get("id");
    ScimUser user = userEndpoints.getUser(id, new MockHttpServletResponse());
    // uaa.user is always added
    assertEquals(4, user.getGroups().size());
  }