Added test for registration on first social login

This commit is contained in:
Stian Thorgersen 2013-10-21 10:24:04 +01:00
parent 1971fa0326
commit c28f30915b
2 changed files with 48 additions and 0 deletions

View file

@ -85,6 +85,22 @@ public class RegisterPage extends AbstractPage {
return loginErrorMessage != null ? loginErrorMessage.getText() : null;
}
public String getFirstName() {
return firstNameInput.getAttribute("value");
}
public String getLastName() {
return lastNameInput.getAttribute("value");
}
public String getEmail() {
return emailInput.getAttribute("value");
}
public String getUsername() {
return usernameInput.getAttribute("value");
}
public boolean isCurrent() {
return driver.getTitle().equals("Register with test");
}

View file

@ -35,6 +35,7 @@ import org.keycloak.testsuite.OAuthClient.AccessTokenResponse;
import org.keycloak.testsuite.pages.AppPage;
import org.keycloak.testsuite.pages.AppPage.RequestType;
import org.keycloak.testsuite.pages.LoginPage;
import org.keycloak.testsuite.pages.RegisterPage;
import org.keycloak.testsuite.rule.KeycloakRule;
import org.keycloak.testsuite.rule.KeycloakRule.KeycloakSetup;
import org.keycloak.testsuite.rule.WebResource;
@ -68,6 +69,9 @@ public class SocialLoginTest {
@WebResource
protected LoginPage loginPage;
@WebResource
protected RegisterPage registerPage;
@WebResource
protected OAuthClient oauth;
@ -97,4 +101,32 @@ public class SocialLoginTest {
Assert.assertTrue(token.getRealmAccess().isUserInRole("user"));
}
@Test
public void registerRequired() {
keycloakRule.configure(new KeycloakSetup() {
@Override
public void config(RealmManager manager, RealmModel adminstrationRealm, RealmModel appRealm) {
appRealm.setAutomaticRegistrationAfterSocialLogin(false);
}
});
loginPage.open();
loginPage.clickSocial("dummy");
driver.findElement(By.id("username")).sendKeys("dummy-user");
driver.findElement(By.id("submit")).click();
registerPage.isCurrent();
Assert.assertEquals("", registerPage.getFirstName());
Assert.assertEquals("", registerPage.getLastName());
Assert.assertEquals("dummy-user@dummy-social", registerPage.getEmail());
Assert.assertEquals("dummy-user", registerPage.getUsername());
registerPage.register("Dummy", "User", "dummy-user@dummy-social", "dummy-user", "password", "password");
Assert.assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
}
}