private ScimUser getScimUser() {
   String email = "joe@" + generator.generate().toLowerCase() + ".com";
   ScimUser user = new ScimUser();
   user.setUserName(email);
   user.setName(new ScimUser.Name("Joe", "User"));
   user.addEmail(email);
   return user;
 }
  protected ScimUser updateUser(String token, int status) throws Exception {
    ScimUserProvisioning usersRepository =
        getWebApplicationContext().getBean(ScimUserProvisioning.class);
    String email = "otheruser@" + generator.generate().toLowerCase() + ".com";
    ScimUser user = new ScimUser(null, email, "Other", "User");
    user.addEmail(email);
    user = usersRepository.createUser(user, "pas5Word");
    if (status == HttpStatus.BAD_REQUEST.value()) {
      user.setUserName(null);
    } else {
      String username2 = "ou" + generator.generate().toLowerCase();
      user.setUserName(username2);
    }

    user.setName(new ScimUser.Name("Joe", "Smith"));

    return updateUser(token, status, user);
  }
 @Test
 public void testCanCreateUserWithExclamationMark() throws Exception {
   String email = "joe!!@" + generator.generate().toLowerCase() + ".com";
   ScimUser user = getScimUser();
   user.getEmails().clear();
   user.setUserName(email);
   user.setPrimaryEmail(email);
   createUser(user, scimReadWriteToken, null);
 }
 private ResponseEntity<ScimUser> createUser(
     String username, String firstName, String lastName, String email) {
   ScimUser user = new ScimUser();
   user.setUserName(username);
   user.setName(new ScimUser.Name(firstName, lastName));
   user.addEmail(email);
   user.setPassword("pas5Word");
   user.setVerified(true);
   return client.postForEntity(serverRunning.getUrl(userEndpoint), user, ScimUser.class);
 }
 @Test
 public void test_Create_User_Too_Long_Password() throws Exception {
   String email = "joe@" + generator.generate().toLowerCase() + ".com";
   ScimUser user = getScimUser();
   user.setUserName(email);
   user.setPrimaryEmail(email);
   user.setPassword(new RandomValueStringGenerator(300).generate());
   ResultActions result = createUserAndReturnResult(user, scimReadWriteToken, null, null);
   result
       .andExpect(status().isBadRequest())
       .andExpect(jsonPath("$.error").value("invalid_password"))
       .andExpect(
           jsonPath("$.message").value("Password must be no more than 255 characters in length."))
       .andExpect(
           jsonPath("$.error_description")
               .value("Password must be no more than 255 characters in length."));
 }
Example #6
0
  private ScimUser createUnapprovedUser() throws Exception {
    String userName = "******" + new RandomValueStringGenerator().generate();
    String userEmail = userName + "@example.com";

    RestOperations restTemplate = serverRunning.getRestTemplate();

    ScimUser user = new ScimUser();
    user.setUserName(userName);
    user.setPassword("s3Cretsecret");
    user.addEmail(userEmail);
    user.setActive(true);
    user.setVerified(true);

    ResponseEntity<ScimUser> result =
        restTemplate.postForEntity(serverRunning.getUrl("/Users"), user, ScimUser.class);
    assertEquals(HttpStatus.CREATED, result.getStatusCode());

    return user;
  }
 @Override
 public ScimUser mapRow(ResultSet rs, int rowNum) throws SQLException {
   String id = rs.getString(1);
   int version = rs.getInt(2);
   Date created = rs.getTimestamp(3);
   Date lastModified = rs.getTimestamp(4);
   String userName = rs.getString(5);
   String email = rs.getString(6);
   String givenName = rs.getString(7);
   String familyName = rs.getString(8);
   boolean active = rs.getBoolean(9);
   String phoneNumber = rs.getString(10);
   boolean verified = rs.getBoolean(11);
   String origin = rs.getString(12);
   String externalId = rs.getString(13);
   String zoneId = rs.getString(14);
   String salt = rs.getString(15);
   Date passwordLastModified = rs.getTimestamp(16);
   ScimUser user = new ScimUser();
   user.setId(id);
   ScimMeta meta = new ScimMeta();
   meta.setVersion(version);
   meta.setCreated(created);
   meta.setLastModified(lastModified);
   user.setMeta(meta);
   user.setUserName(userName);
   user.addEmail(email);
   if (phoneNumber != null) {
     user.addPhoneNumber(phoneNumber);
   }
   Name name = new Name();
   name.setGivenName(givenName);
   name.setFamilyName(familyName);
   user.setName(name);
   user.setActive(active);
   user.setVerified(verified);
   user.setOrigin(origin);
   user.setExternalId(externalId);
   user.setZoneId(zoneId);
   user.setSalt(salt);
   user.setPasswordLastModified(passwordLastModified);
   return user;
 }