use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testForcePasswordExpireAccountExternalUser.
@Test
void testForcePasswordExpireAccountExternalUser() throws Exception {
ScimUser user = createUser(uaaAdminToken);
user.setOrigin("NOT_UAA");
updateUser(uaaAdminToken, HttpStatus.OK.value(), user);
UserAccountStatus alteredAccountStatus = new UserAccountStatus();
alteredAccountStatus.setPasswordChangeRequired(true);
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 verification_link.
@Test
void verification_link() throws Exception {
ScimUser joel = setUpScimUser();
MockHttpServletRequestBuilder get = setUpVerificationLinkRequest(joel, scimCreateToken);
MvcResult result = mockMvc.perform(get).andExpect(status().isOk()).andReturn();
VerificationResponse verificationResponse = JsonUtils.readValue(result.getResponse().getContentAsString(), VerificationResponse.class);
assertThat(verificationResponse.getVerifyLink().toString(), startsWith("http://localhost/verify_user"));
String query = verificationResponse.getVerifyLink().getQuery();
String code = getQueryStringParam(query, "code");
assertThat(code, is(notNullValue()));
ExpiringCode expiringCode = codeStore.retrieveCode(code, IdentityZoneHolder.get().getId());
assertThat(expiringCode.getExpiresAt().getTime(), is(greaterThan(System.currentTimeMillis())));
assertThat(expiringCode.getIntent(), is(REGISTRATION.name()));
Map<String, String> data = JsonUtils.readValue(expiringCode.getData(), new TypeReference<Map<String, String>>() {
});
assertThat(data.get(USER_ID), is(notNullValue()));
assertThat(data.get(CLIENT_ID), is(clientDetails.getClientId()));
assertThat(data.get(REDIRECT_URI), is(HTTP_REDIRECT_EXAMPLE_COM));
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method verification_link_is_authorized_endpoint.
@Test
void verification_link_is_authorized_endpoint() throws Exception {
ScimUser joel = setUpScimUser();
MockHttpServletRequestBuilder get = MockMvcRequestBuilders.get("/Users/" + joel.getId() + "/verify-link").param("redirect_uri", HTTP_REDIRECT_EXAMPLE_COM).accept(APPLICATION_JSON);
mockMvc.perform(get).andExpect(status().isUnauthorized());
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsTests method patchIncorrectVersionFails.
@Test
void patchIncorrectVersionFails() {
ScimUser user = new ScimUser(null, "uname", "gname", "fname");
user.setPassword("password");
user.addEmail("test@example.org");
ScimUser createdUser = scimUserEndpoints.createUser(user, new MockHttpServletRequest(), new MockHttpServletResponse());
assertThrows(ScimResourceConflictException.class, () -> scimUserEndpoints.patchUser(createdUser, createdUser.getId(), Integer.toString(createdUser.getVersion() + 1), new MockHttpServletRequest(), new MockHttpServletResponse(), null));
}
use of org.cloudfoundry.identity.uaa.scim.ScimUser in project uaa by cloudfoundry.
the class ScimUserEndpointsMockMvcTests method testUserSelfAccess_Get_and_Post.
@Test
void testUserSelfAccess_Get_and_Post() throws Exception {
ScimUser user = getScimUser();
user.setPassword("secret");
ScimUser savedUser = createUser(user, scimReadWriteToken, IdentityZone.getUaa().getSubdomain());
String selfToken = testClient.getUserOAuthAccessToken("cf", "", savedUser.getUserName(), "secret", "");
savedUser.setName(new ScimUser.Name("Given1", "Family1"));
ScimUser updatedUser = updateUser(selfToken, HttpStatus.OK.value(), savedUser);
getAndReturnUser(HttpStatus.OK.value(), updatedUser, selfToken);
}
Aggregations