use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.
the class UserServiceTest method updateMe.
@Test
public void updateMe() throws Exception {
User u = new User();
u.setFullName("the toto");
u.setUserId("toto");
u.setEmail("toto@toto.fr");
u.setPassword("toto123");
u.setConfirmPassword("toto123");
u.setValidated(true);
getUserService(getAdminAuthzHeader()).createUser(u);
SelfUserData selfUserData = new SelfUserData();
selfUserData.setFullName("the toto123");
selfUserData.setEmail("toto@titi.fr");
selfUserData.setPassword("toto1234");
selfUserData.setCurrentPassword("toto123");
getUserService(getUserAuthzHeader("toto")).updateMe(selfUserData);
UserInfo uInfo = getUserService(getAdminAuthzHeader()).getUser("toto");
assertEquals("the toto123", uInfo.getFullName());
assertEquals("toto@titi.fr", uInfo.getEmail());
selfUserData.setFullName("the toto1234");
selfUserData.setEmail("toto@tititi.fr");
selfUserData.setPassword("toto12345");
selfUserData.setCurrentPassword("toto1234");
getUserService(getUserAuthzHeader("toto")).updateMe(selfUserData);
uInfo = getUserService(getAdminAuthzHeader()).getUser("toto");
assertEquals("the toto1234", uInfo.getFullName());
assertEquals("toto@tititi.fr", uInfo.getEmail());
getUserService(getAdminAuthzHeader()).deleteUser("toto");
}
use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.
the class UserServiceTest method registerWithValidation.
@Test
public void registerWithValidation() throws Exception {
try {
mockJavaMailSender.getSendedEmails().clear();
ServicesAssert assertService = JAXRSClientFactory.create("http://localhost:" + getServerPort() + "/" + getRestServicesPath() + "/testsService/", ServicesAssert.class, Collections.singletonList(getJsonProvider()));
assertService.clearEmailMessages();
UserService service = getUserService(getAdminAuthzHeader());
User u = new User();
u.setFullName("the toto");
u.setUserId("toto");
u.setEmail("toto@toto.fr");
u.setPassword("toto123");
u.setConfirmPassword("toto123");
String key = service.registerUser(u.getUserId(), new UserRegistrationRequest(u, "http://wine.fr/bordeaux")).getKey();
assertNotEquals("-1", key);
List<EmailMessage> emailMessages = assertService.getEmailMessageSended();
assertEquals(1, emailMessages.size());
assertEquals("toto@toto.fr", emailMessages.get(0).getTos().get(0));
assertEquals("Welcome", emailMessages.get(0).getSubject());
String messageContent = emailMessages.get(0).getText();
log.info("messageContent: {}", messageContent);
assertNotNull(messageContent);
assertTrue(messageContent.contains("Use the following URL to validate your account."));
assertTrue(messageContent.contains("http://wine.fr/bordeaux"));
assertTrue(messageContent.contains("toto"));
assertTrue(service.validateUserRegistration("toto", key).isSuccess());
service = getUserService(getAdminAuthzHeader());
UserInfo uInfo = service.getUser("toto");
assertNotNull(uInfo);
assertTrue(uInfo.isValidated());
assertTrue(uInfo.isPasswordChangeRequired());
// assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
deleteUserQuietly("toto");
}
}
use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.
the class UserServiceTest method resetPassword.
@Test
public void resetPassword() throws Exception {
try {
mockJavaMailSender.getSendedEmails().clear();
ServicesAssert assertService = JAXRSClientFactory.create("http://localhost:" + getServerPort() + "/" + getRestServicesPath() + "/testsService/", ServicesAssert.class, Collections.singletonList(getJsonProvider()));
assertService.clearEmailMessages();
UserService service = getUserService(getAdminAuthzHeader());
User u = new User();
u.setFullName("the toto");
u.setUserId("toto");
u.setEmail("toto@toto.fr");
u.setPassword("toto123");
u.setConfirmPassword("toto123");
String key = service.registerUser(u.getUserId(), new UserRegistrationRequest(u, "http://wine.fr/bordeaux")).getKey();
assertNotEquals("-1", key);
WebClient.client(assertService).accept(MediaType.APPLICATION_JSON_TYPE);
WebClient.client(assertService).type(MediaType.APPLICATION_JSON_TYPE);
List<EmailMessage> emailMessages = assertService.getEmailMessageSended();
assertEquals(1, emailMessages.size());
assertEquals("toto@toto.fr", emailMessages.get(0).getTos().get(0));
assertEquals("Welcome", emailMessages.get(0).getSubject());
assertTrue(emailMessages.get(0).getText().contains("Use the following URL to validate your account."));
// assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
service = getUserService(getAdminAuthzHeader());
UserInfo uInfo = service.getUser("toto");
assertNotNull(uInfo);
assertFalse(uInfo.isValidated());
assertTrue(uInfo.isPasswordChangeRequired());
// assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
assertEquals(200, service.resetPassword(u.getUserId()).getStatus());
emailMessages = assertService.getEmailMessageSended();
assertEquals(2, emailMessages.size());
assertEquals("toto@toto.fr", emailMessages.get(1).getTos().get(0));
String messageContent = emailMessages.get(1).getText();
assertNotNull(messageContent);
assertTrue(messageContent.contains("Password Reset"));
assertTrue(messageContent.contains("Username: toto"));
assertTrue(messageContent.contains("/security/login"));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
deleteUserQuietly("toto");
}
}
use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.
the class UserServiceTest method lockUnlockUser.
@Test
public void lockUnlockUser() throws Exception {
try {
// START SNIPPET: create-user
User user = new User("toto", "toto the king", "toto@toto.fr", false, false);
user.setPassword("foo123");
user.setPasswordChangeRequired(false);
user.setLocked(false);
user.setValidated(true);
UserService userService = getUserService(getAdminAuthzHeader());
userService.createUser(user);
// END SNIPPET: create-user
UserInfo userInfo = userService.getUser("toto");
assertNotNull(userInfo);
assertEquals("toto the king", userInfo.getFullName());
assertEquals("toto@toto.fr", userInfo.getEmail());
TokenResponse result = getLoginServiceV2(null).logIn(new TokenRequest("toto", "foo123", GrantType.AUTHORIZATION_CODE));
getLoginServiceV2("Bearer " + result.getAccessToken()).pingWithAutz();
userService.lockUser("toto");
assertTrue(userService.getUser("toto").isLocked());
userService.unlockUser("toto");
assertFalse(userService.getUser("toto").isLocked());
} finally {
getUserService(getAdminAuthzHeader()).deleteUser("toto");
getUserService(getAdminAuthzHeader()).removeFromCache("toto");
try {
getUserService(getAdminAuthzHeader()).getUser("toto");
assertTrue(false, "404 should be thrown for non existing resource");
} catch (NotFoundException e) {
assertEquals(404, e.getResponse().getStatus());
}
}
}
use of org.neo4j.ogm.domain.gh777.UserInfo in project archiva-redback-core by apache.
the class UserServiceTest method register.
@Test
public void register() throws Exception {
try {
mockJavaMailSender.getSendedEmails().clear();
ServicesAssert assertService = JAXRSClientFactory.create("http://localhost:" + getServerPort() + "/" + getRestServicesPath() + "/testsService/", ServicesAssert.class, Collections.singletonList(getJsonProvider()));
assertService.clearEmailMessages();
UserService service = getUserService(getAdminAuthzHeader());
User u = new User();
u.setFullName("the toto");
u.setUserId("toto");
u.setEmail("toto@toto.fr");
u.setPassword("toto123");
u.setConfirmPassword("toto123");
String key = service.registerUser(u.getUserId(), new UserRegistrationRequest(u, "http://wine.fr/bordeaux")).getKey();
assertNotEquals("-1", key);
List<EmailMessage> emailMessages = assertService.getEmailMessageSended();
assertEquals(1, emailMessages.size());
assertEquals("toto@toto.fr", emailMessages.get(0).getTos().get(0));
assertEquals("Welcome", emailMessages.get(0).getSubject());
String messageContent = emailMessages.get(0).getText();
log.info("messageContent: {}", messageContent);
assertNotNull(messageContent);
assertTrue(messageContent.contains("Use the following URL to validate your account."));
assertTrue(messageContent.contains("http://wine.fr/bordeaux"));
assertTrue(messageContent.contains("toto"));
// assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
service = getUserService(getAdminAuthzHeader());
UserInfo uInfo = service.getUser("toto");
assertNotNull(uInfo);
assertFalse(uInfo.isValidated());
assertTrue(uInfo.isPasswordChangeRequired());
// assertTrue( service.validateUserFromKey( key ).isSuccess( ) );
} catch (Exception e) {
log.error(e.getMessage(), e);
throw e;
} finally {
deleteUserQuietly("toto");
}
}
Aggregations