Skip to content

Commit

Permalink
Use stronger passwords in LDAP tests due to password policy on MSAD2012
Browse files Browse the repository at this point in the history
  • Loading branch information
mposolda committed Sep 2, 2014
1 parent b561080 commit 44937d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 69,7 @@ public void config(RealmManager manager, RealmModel adminstrationRealm, RealmMod
LDAPUtils.removeAllUsers(partitionManager);

User john = LDAPUtils.addUser(partitionManager, "johnkeycloak", "John", "Doe", "[email protected]");
LDAPUtils.updatePassword(partitionManager, john, "password");
LDAPUtils.updatePassword(partitionManager, john, "Password1");

User existing = LDAPUtils.addUser(partitionManager, "existing", "Existing", "Foo", "[email protected]");
}
Expand Down Expand Up @@ -137,7 137,7 @@ public void loginClassic() {
@Test
public void loginLdap() {
loginPage.open();
loginPage.login("johnkeycloak", "password");
loginPage.login("johnkeycloak", "Password1");

Assert.assertEquals(AppPage.RequestType.AUTH_RESPONSE, appPage.getRequestType());
Assert.assertNotNull(oauth.getCurrentQuery().get(OAuth2Constants.CODE));
Expand All @@ -164,7 164,7 @@ public void XdeleteLink() {
}
}
loginPage.open();
loginPage.login("johnkeycloak", "password");
loginPage.login("johnkeycloak", "Password1");
loginPage.assertCurrent();

Assert.assertEquals("Invalid username or password.", loginPage.getError());
Expand All @@ -187,19 187,19 @@ public void XdeleteLink() {
@Test
public void passwordChangeLdap() throws Exception {
changePasswordPage.open();
loginPage.login("johnkeycloak", "password");
changePasswordPage.changePassword("password", "new-password", "new-password");
loginPage.login("johnkeycloak", "Password1");
changePasswordPage.changePassword("Password1", "New-password1", "New-password1");

Assert.assertEquals("Your password has been updated", profilePage.getSuccess());

changePasswordPage.logout();

loginPage.open();
loginPage.login("johnkeycloak", "bad-password");
loginPage.login("johnkeycloak", "Bad-password1");
Assert.assertEquals("Invalid username or password.", loginPage.getError());

loginPage.open();
loginPage.login("johnkeycloak", "new-password");
loginPage.login("johnkeycloak", "New-password1");
Assert.assertEquals(AppPage.RequestType.AUTH_RESPONSE, appPage.getRequestType());
}

Expand All @@ -210,12 210,12 @@ public void registerExistingLdapUser() {
registerPage.assertCurrent();

// check existing username
registerPage.register("firstName", "lastName", "email", "existing", "password", "password");
registerPage.register("firstName", "lastName", "email", "existing", "Password1", "Password1");
registerPage.assertCurrent();
Assert.assertEquals("Username already exists", registerPage.getError());

// Check existing email
registerPage.register("firstName", "lastName", "[email protected]", "nonExisting", "password", "password");
registerPage.register("firstName", "lastName", "[email protected]", "nonExisting", "Password1", "Password1");
registerPage.assertCurrent();
Assert.assertEquals("Email already exists", registerPage.getError());
}
Expand All @@ -226,7 226,7 @@ public void registerUserLdapSuccess() {
loginPage.clickRegister();
registerPage.assertCurrent();

registerPage.register("firstName", "lastName", "email2", "registerUserSuccess2", "password", "password");
registerPage.register("firstName", "lastName", "email2", "registerUserSuccess2", "Password1", "Password1");
Assert.assertEquals(AppPage.RequestType.AUTH_RESPONSE, appPage.getRequestType());

KeycloakSession session = keycloakRule.startSession();
Expand Down Expand Up @@ -274,7 274,7 @@ public void testReadonly() {

}
try {
UserCredentialModel cred = UserCredentialModel.password("poop");
UserCredentialModel cred = UserCredentialModel.password("PoopyPoop1");
user.updateCredential(cred);
Assert.fail("should fail");
} catch (ModelReadOnlyException e) {
Expand Down Expand Up @@ -364,14 364,14 @@ public void testUnsynced() {
Assert.assertNotNull(user.getFederationLink());
Assert.assertEquals(user.getFederationLink(), ldapModel.getId());

UserCredentialModel cred = UserCredentialModel.password("candy");
UserCredentialModel cred = UserCredentialModel.password("Candycand1");
user.updateCredential(cred);
UserCredentialValueModel userCredentialValueModel = user.getCredentialsDirectly().get(0);
Assert.assertEquals(UserCredentialModel.PASSWORD, userCredentialValueModel.getType());
Assert.assertTrue(session.users().validCredentials(appRealm, user, cred));

// LDAP password is still unchanged
Assert.assertTrue(LDAPUtils.validatePassword(getPartitionManager(session, model), "johnkeycloak", "new-password"));
Assert.assertTrue(LDAPUtils.validatePassword(getPartitionManager(session, model), "johnkeycloak", "New-password1"));

// ATM it's not permitted to delete user in unsynced mode. Should be user deleted just locally instead?
Assert.assertFalse(session.users().removeUser(appRealm, user));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 58,15 @@ public void config(RealmManager manager, RealmModel adminstrationRealm, RealmMod
LDAPUtils.removeAllUsers(partitionManager);

User user1 = LDAPUtils.addUser(partitionManager, "user1", "User1FN", "User1LN", "[email protected]");
LDAPUtils.updatePassword(partitionManager, user1, "password1");
LDAPUtils.updatePassword(partitionManager, user1, "Password1");
User user2 = LDAPUtils.addUser(partitionManager, "user2", "User2FN", "User2LN", "[email protected]");
LDAPUtils.updatePassword(partitionManager, user2, "password2");
LDAPUtils.updatePassword(partitionManager, user2, "Password2");
User user3 = LDAPUtils.addUser(partitionManager, "user3", "User3FN", "User3LN", "[email protected]");
LDAPUtils.updatePassword(partitionManager, user3, "password3");
LDAPUtils.updatePassword(partitionManager, user3, "Password3");
User user4 = LDAPUtils.addUser(partitionManager, "user4", "User4FN", "User4LN", "[email protected]");
LDAPUtils.updatePassword(partitionManager, user4, "password4");
LDAPUtils.updatePassword(partitionManager, user4, "Password4");
User user5 = LDAPUtils.addUser(partitionManager, "user5", "User5FN", "User5LN", "[email protected]");
LDAPUtils.updatePassword(partitionManager, user5, "password5");
LDAPUtils.updatePassword(partitionManager, user5, "Password5");

// Add properties provider
dummyModel = appRealm.addUserFederationProvider(DummyUserFederationProviderFactory.PROVIDER_NAME, new HashMap<String, String>(), 1, "test-dummy", -1, 1, 0);
Expand Down

0 comments on commit 44937d3

Please sign in to comment.