@Test
  public void testVerifyBadGUID() throws IOException, ServletException {
    EnhancedSecurityContext.logout();
    Configuration configuration = makeConfiguration(false);
    DefaultUser user = makeUser("*****@*****.**");
    user.setVerified(false);
    persistenceService.persist(user);

    WebappTestRunner runner = new WebappTestRunner();
    runner
        .test("/verify-email")
        .withMock(Configuration.class, configuration)
        .withMock(EmailTransportService.class, EmailTestHelper.getService())
        .withParameter("guid", "bad-guid")
        .get();

    assertEquals(1, runner.messageStore.getActionMessages(MessageType.ERROR).size());
    assertNull(runner.response.getRedirect());
    assertTrue(runner.response.getStream().toString().contains("<form"));

    persistenceService.reload(user);
    assertFalse(user.isVerified());
  }
  @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());
  }