use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testCreateUserInOtherZoneIsUnauthorized.
@Test
void testCreateUserInOtherZoneIsUnauthorized() throws Exception {
String subdomain = generator.generate();
MockMvcUtils.createOtherIdentityZone(subdomain, mockMvc, webApplicationContext, IdentityZoneHolder.getCurrentZoneId());
String otherSubdomain = generator.generate();
MockMvcUtils.createOtherIdentityZone(otherSubdomain, mockMvc, webApplicationContext, IdentityZoneHolder.getCurrentZoneId());
String zoneAdminToken = testClient.getClientCredentialsOAuthAccessToken("admin", "admin-secret", "scim.write", subdomain);
ScimUser user = getScimUser();
byte[] requestBody = JsonUtils.writeValueAsBytes(user);
MockHttpServletRequestBuilder post = post("/Users").with(new SetServerNameRequestPostProcessor(otherSubdomain + ".localhost")).header("Authorization", "Bearer " + zoneAdminToken).contentType(APPLICATION_JSON).content(requestBody);
mockMvc.perform(post).andExpect(status().isUnauthorized());
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testForcePasswordExpireAccountInvalid.
@Test
void testForcePasswordExpireAccountInvalid() throws Exception {
ScimUser user = createUser(uaaAdminToken);
UserAccountStatus alteredAccountStatus = new UserAccountStatus();
alteredAccountStatus.setPasswordChangeRequired(false);
updateAccountStatus(user, alteredAccountStatus).andExpect(status().isBadRequest());
assertFalse(usersRepository.checkPasswordChangeIndividuallyRequired(user.getId(), IdentityZoneHolder.get().getId()));
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method updateUser.
private ScimUser updateUser(String token, int status) throws Exception {
ScimUserProvisioning usersRepository = webApplicationContext.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", IdentityZoneHolder.get().getId());
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);
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method verification_link_secured_with_scimcreate.
@Test
void verification_link_secured_with_scimcreate() throws Exception {
ScimUser joel = setUpScimUser();
MockHttpServletRequestBuilder get = setUpVerificationLinkRequest(joel, scimReadWriteToken);
mockMvc.perform(get).andExpect(status().isForbidden());
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method createUser.
private ScimUser createUser(ScimUser user, String token, String subdomain, String switchZone) throws Exception {
String password = hasText(user.getPassword()) ? user.getPassword() : "pas5word";
user.setPassword(password);
MvcResult result = createUserAndReturnResult(user, token, subdomain, switchZone).andExpect(status().isCreated()).andExpect(header().string("ETag", "\"0\"")).andExpect(jsonPath("$.userName").value(user.getUserName())).andExpect(jsonPath("$.emails[0].value").value(user.getUserName())).andExpect(jsonPath("$.name.familyName").value(user.getFamilyName())).andExpect(jsonPath("$.name.givenName").value(user.getGivenName())).andReturn();
user = JsonUtils.readValue(result.getResponse().getContentAsString(), ScimUser.class);
user.setPassword(password);
return user;
}
Aggregations