@Test(expected = LoginAttemptsExceededException.class) public void testAuthenticate3Times() throws Exception { LoginHandler lh = new LoginHandler(users); assertFalse(lh.authenticate("username", "psword")); // ID PW 틀릴때 assertEquals(1, lh.getTimes()); assertFalse(lh.authenticate("username", "password")); // ID PW 틀릴때 assertEquals(2, lh.getTimes()); assertFalse(lh.authenticate("admin", "p ")); // ID PW 틀릴때 assertEquals(3, lh.getTimes()); assertFalse(lh.authenticate("admin", "p ")); // ID PW 틀릴때 assertEquals(4, lh.getTimes()); assertFalse(lh.authenticate("admin", "p ")); // ID PW 틀릴때 assertEquals(5, lh.getTimes()); }
@Test public void testAuthenticateTTCase() throws Exception { LoginHandler lh = new LoginHandler(users); assertTrue(lh.authenticate("admin", "password")); // ID PW 틀릴때 assertEquals(0, lh.getTimes()); }
@Test public void testResetHandler() { LoginHandler lh = new LoginHandler(users); lh.resetHandler(); assertEquals(0, lh.getTimes()); }
@Test public void testAuthenticateFTCase() throws Exception { LoginHandler lh = new LoginHandler(users); assertFalse(lh.authenticate("username", "password")); // ID PW 틀릴때 assertEquals(1, lh.getTimes()); }
@Test public void testLoginHandler() { LoginHandler lh = new LoginHandler(users); assertEquals(0, lh.getTimes()); assertSame(users, lh.getValidUsers()); }