@Test
public void testAuthenticate() {

    htpasswd.setAllowClearTextPasswords(true);
    Account account = htpasswd.authenticate("user1", "pass1");
    assertNotNull(account);
    assertEquals("user1", account.getUsername());
    account = htpasswd.authenticate("user2", "pass2");
    assertNotNull(account);
    assertEquals("user2", account.getUsername());
    // Test different encryptions
    account = htpasswd.authenticate("plain", "passWord");
    assertNotNull(account);
    assertEquals("plain", account.getUsername());
    htpasswd.setAllowClearTextPasswords(false);
    account = htpasswd.authenticate("crypt", "password");
    assertNotNull(account);
    assertEquals("crypt", account.getUsername());
    account = htpasswd.authenticate("md5", "password");
    assertNotNull(account);
    assertEquals("md5", account.getUsername());
    account = htpasswd.authenticate("sha", "password");
    assertNotNull(account);
    assertEquals("sha", account.getUsername());
    // Test leading and trailing whitespace
    account = htpasswd.authenticate("trailing", "whitespace");
    assertNotNull(account);
    assertEquals("trailing", account.getUsername());
    account = htpasswd.authenticate("tabbed", "frontAndBack");
    assertNotNull(account);
    assertEquals("tabbed", account.getUsername());
    account = htpasswd.authenticate("leading", "whitespace");
    assertNotNull(account);
    assertEquals("leading", account.getUsername());
}