@Test public void testRegisterVerify() throws Exception { TestUser user = new TestUser(); user.setUsername("*****@*****.**"); assertEquals( RegisterResult.PENDING, userService.register(user, "password", "http://www.example.com/verify-email")); assertFalse(user.isPartial()); assertEquals(1, user.getRoles().size()); assertNotNull(user.getRoles().iterator().next()); Email email = EmailTestHelper.getEmailResults().poll(); assertTrue( email.getHtml().contains("http://www.example.com/verify-email?guid=" + user.getGuid())); }
@Test public void testResend() throws IOException, ServletException { EnhancedSecurityContext.logout(); Configuration configuration = makeConfiguration(false); DefaultUser user = makeUser("*****@*****.**"); user.setVerified(false); user.setGuid("test-verify-email-resend"); persistenceService.persist(user); WebappTestRunner runner = new WebappTestRunner(); runner .test("/verify-email") .withMock(Configuration.class, configuration) .withMock(EmailTransportService.class, EmailTestHelper.getService()) .withParameter("email", "*****@*****.**") .post(); assertEquals("verification-email-sent", runner.response.getRedirect()); persistenceService.reload(user); assertFalse(user.isVerified()); assertFalse(user.getGuid().equals("test-verify-email-resend")); assertEquals(1, EmailTestHelper.getEmailResults().size()); }