@Test public void testAuthenticateFailBadPwd() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "tim").put("password", "eggs"); authProvider.authenticate(authInfo, onFailure(v -> { assertEquals("Invalid username/password", v.getMessage()); testComplete(); })); await(); }
@Test public void testAuthenticateFailBadUser() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "blah").put("password", "whatever"); authProvider.authenticate(authInfo, onFailure(v -> { assertEquals("Invalid username/password", v.getMessage()); testComplete(); })); await(); }
@Test public void testAuthenticateWithNonce() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "paulo").put("password", "secret"); authProvider.authenticate(authInfo, onSuccess(user -> { assertNotNull(user); testComplete(); })); await(); } }
@Test public void testAuthenticate() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "tim").put("password", "sausages"); authProvider.authenticate(authInfo, onSuccess(user -> { assertNotNull(user); testComplete(); })); await(); }
@Test public void testAuthoriseNotHasRole() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "tim").put("password", "sausages"); authProvider.authenticate(authInfo, onSuccess(user -> { assertNotNull(user); user.isAuthorized("role:manager", onSuccess(has -> { assertFalse(has); testComplete(); })); })); await(); }
@Test public void testAuthoriseNotHasPermission() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "tim").put("password", "sausages"); authProvider.authenticate(authInfo, onSuccess(user -> { assertNotNull(user); user.isAuthorized("eat_sandwich", onSuccess(has -> { assertFalse(has); testComplete(); })); })); await(); }
@Test public void testAuthoriseHasRole() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "tim").put("password", "sausages"); authProvider.authenticate(authInfo, onSuccess(user -> { assertNotNull(user); user.isAuthorized("role:dev", onSuccess(has -> { assertTrue(has); testComplete(); })); })); await(); }
@Test public void testAuthoriseHasPermission() { JsonObject authInfo = new JsonObject(); authInfo.put("username", "tim").put("password", "sausages"); authProvider.authenticate(authInfo, onSuccess(user -> { assertNotNull(user); user.isAuthorized("commit_code", onSuccess(has -> { assertTrue(has); testComplete(); })); })); await(); }