use of org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude in project keycloak by keycloak.
the class AccountFormServiceTest method applicationsVisibilityNoScopesAndConsent.
@Test
@AuthServerContainerExclude(AuthServer.REMOTE)
public void applicationsVisibilityNoScopesAndConsent() throws Exception {
try (ClientAttributeUpdater cau = ClientAttributeUpdater.forClient(adminClient, REALM_NAME, ROOT_URL_CLIENT).setConsentRequired(true).setFullScopeAllowed(false).setDefaultClientScopes(Collections.EMPTY_LIST).setOptionalClientScopes(Collections.EMPTY_LIST).update()) {
applicationsPage.open();
loginPage.login("john-doh@localhost", "password");
applicationsPage.assertCurrent();
Map<String, AccountApplicationsPage.AppEntry> apps = applicationsPage.getApplications();
Assert.assertThat(apps.keySet(), containsInAnyOrder("root-url-client", "Account", "Account Console", "test-app", "test-app-scope", "third-party", "test-app-authz", "My Named Test App", "Test App Named - ${client_account}", "direct-grant", "custom-audience"));
}
}
use of org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude in project keycloak by keycloak.
the class SessionRestServiceTest method testGetSessions.
@Test
@AuthServerContainerExclude(AuthServer.REMOTE)
public void testGetSessions() throws Exception {
oauth.setDriver(secondBrowser);
codeGrant("public-client-0");
List<SessionRepresentation> sessions = getSessions();
assertEquals(2, sessions.size());
for (SessionRepresentation session : sessions) {
assertNotNull(session.getId());
assertThat(session.getIpAddress(), anyOf(equalTo("127.0.0.1"), equalTo("0:0:0:0:0:0:0:1")));
assertTrue(session.getLastAccess() > 0);
assertTrue(session.getExpires() > 0);
assertTrue(session.getStarted() > 0);
assertThat(session.getClients(), Matchers.hasItem(Matchers.hasProperty("clientId", anyOf(Matchers.is("direct-grant"), Matchers.is("public-client-0")))));
}
}
use of org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude in project keycloak by keycloak.
the class RegisterTest method registerUserSuccessWithEmailVerificationWithResend.
@Test
// GreenMailRule is not working atm
@AuthServerContainerExclude(AuthServer.REMOTE)
public void registerUserSuccessWithEmailVerificationWithResend() throws Exception {
try (RealmAttributeUpdater rau = setVerifyEmail(true).update()) {
loginPage.open();
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.register("firstName", "lastName", "registerUserSuccessWithEmailVerificationWithResend@email", "registerUserSuccessWithEmailVerificationWithResend", "password", "password");
verifyEmailPage.assertCurrent();
String userId = events.expectRegister("registerUserSuccessWithEmailVerificationWithResend", "registerUserSuccessWithEmailVerificationWithResend@email").assertEvent().getUserId();
{
assertTrue("Expecting verify email", greenMail.waitForIncomingEmail(1000, 1));
events.expect(EventType.SEND_VERIFY_EMAIL).detail(Details.EMAIL, "registerUserSuccessWithEmailVerificationWithResend@email".toLowerCase()).user(userId).assertEvent();
verifyEmailPage.clickResendEmail();
verifyEmailPage.assertCurrent();
assertTrue("Expecting second verify email", greenMail.waitForIncomingEmail(1000, 1));
events.expect(EventType.SEND_VERIFY_EMAIL).detail(Details.EMAIL, "registerUserSuccessWithEmailVerificationWithResend@email".toLowerCase()).user(userId).assertEvent();
MimeMessage message = greenMail.getLastReceivedMessage();
String link = MailUtils.getPasswordResetEmailLink(message);
driver.navigate().to(link);
}
events.expectRequiredAction(EventType.VERIFY_EMAIL).detail(Details.EMAIL, "registerUserSuccessWithEmailVerificationWithResend@email".toLowerCase()).user(userId).assertEvent();
assertUserRegistered(userId, "registerUserSuccessWithEmailVerificationWithResend", "registerUserSuccessWithEmailVerificationWithResend@email");
appPage.assertCurrent();
assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
// test that timestamp is current with 10s tollerance
// test user info is set from form
}
}
use of org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude in project keycloak by keycloak.
the class RegisterTest method registerUserSuccessWithEmailVerification.
@Test
// GreenMailRule is not working atm
@AuthServerContainerExclude(AuthServer.REMOTE)
public void registerUserSuccessWithEmailVerification() throws Exception {
try (RealmAttributeUpdater rau = setVerifyEmail(true).update()) {
loginPage.open();
loginPage.clickRegister();
registerPage.assertCurrent();
registerPage.register("firstName", "lastName", "registerUserSuccessWithEmailVerification@email", "registerUserSuccessWithEmailVerification", "password", "password");
verifyEmailPage.assertCurrent();
String userId = events.expectRegister("registerUserSuccessWithEmailVerification", "registerUserSuccessWithEmailVerification@email").assertEvent().getUserId();
{
assertTrue("Expecting verify email", greenMail.waitForIncomingEmail(1000, 1));
events.expect(EventType.SEND_VERIFY_EMAIL).detail(Details.EMAIL, "registerUserSuccessWithEmailVerification@email".toLowerCase()).user(userId).assertEvent();
MimeMessage message = greenMail.getLastReceivedMessage();
String link = MailUtils.getPasswordResetEmailLink(message);
driver.navigate().to(link);
}
events.expectRequiredAction(EventType.VERIFY_EMAIL).detail(Details.EMAIL, "registerUserSuccessWithEmailVerification@email".toLowerCase()).user(userId).assertEvent();
assertUserRegistered(userId, "registerUserSuccessWithEmailVerification", "registerUserSuccessWithEmailVerification@email");
appPage.assertCurrent();
assertEquals(RequestType.AUTH_RESPONSE, appPage.getRequestType());
// test that timestamp is current with 10s tollerance
// test user info is set from form
}
}
use of org.keycloak.testsuite.arquillian.annotation.AuthServerContainerExclude in project keycloak by keycloak.
the class BrowserFlowTest method testLoginMultiFactorWithWrongCredentialsMessage.
/**
* This test checks the error messages, when the credentials are invalid and UsernameForm and PasswordForm are separated.
*/
@Test
@AuthServerContainerExclude(REMOTE)
public void testLoginMultiFactorWithWrongCredentialsMessage() {
UserRepresentation user = testRealm().users().search("test-user@localhost").get(0);
Assert.assertNotNull(user);
MultiFactorAuthenticationTest.configureBrowserFlowWithAlternativeCredentials(testingClient);
try {
RealmRepresentation realm = testRealm().toRepresentation();
realm.setLoginWithEmailAllowed(false);
testRealm().update(realm);
loginUsernameOnlyPage.open();
loginUsernameOnlyPage.assertCurrent();
loginUsernameOnlyPage.login("non_existing_user");
Assert.assertEquals("Invalid username.", loginUsernameOnlyPage.getUsernameError());
Assert.assertEquals("Invalid username.", loginUsernameOnlyPage.getUsernameError());
realm.setLoginWithEmailAllowed(true);
testRealm().update(realm);
loginUsernameOnlyPage.login("non_existing_user");
Assert.assertEquals("Invalid username or email.", loginUsernameOnlyPage.getUsernameError());
Assert.assertEquals("Invalid username or email.", loginUsernameOnlyPage.getUsernameError());
loginUsernameOnlyPage.login(user.getUsername());
passwordPage.assertCurrent();
passwordPage.login("wrong_password");
Assert.assertEquals("Invalid password.", passwordPage.getPasswordError());
Assert.assertEquals("Invalid password.", passwordPage.getPasswordError());
passwordPage.assertCurrent();
events.clear();
passwordPage.login("password");
Assert.assertFalse(loginUsernameOnlyPage.isCurrent());
Assert.assertFalse(passwordPage.isCurrent());
events.expectLogin().user(user).detail(Details.USERNAME, "test-user@localhost").assertEvent();
} finally {
revertFlows("browser - alternative");
}
}
Aggregations