use of org.jboss.arquillian.graphene.page.Page in project keycloak by keycloak.
the class BrowserFlowTest method testAlternativeNonInteractiveExecutorInSubflow.
@Test
@AuthServerContainerExclude(REMOTE)
// TODO remove this (KEYCLOAK-16228)
@DisableFeature(value = Profile.Feature.ACCOUNT2, skipRestart = true)
public void testAlternativeNonInteractiveExecutorInSubflow() {
final String newFlowAlias = "browser - alternative non-interactive executor";
testingClient.server("test").run(session -> FlowUtil.inCurrentRealm(session).copyBrowserFlow(newFlowAlias));
testingClient.server("test").run(session -> FlowUtil.inCurrentRealm(session).selectFlow(newFlowAlias).inForms(forms -> forms.clear().addAuthenticatorExecution(AuthenticationExecutionModel.Requirement.REQUIRED, UsernameFormFactory.PROVIDER_ID).addSubFlowExecution(Requirement.REQUIRED, reqSubFlow -> reqSubFlow.addAuthenticatorExecution(Requirement.ALTERNATIVE, PassThroughAuthenticator.PROVIDER_ID))).defineAsBrowserFlow());
try {
// provides username
loginUsernameOnlyPage.open();
loginUsernameOnlyPage.login("test-user@localhost");
// Check that Keycloak is redirecting us to the Keycloak account management page
WebElement aHref = driver.findElement(By.tagName("a"));
driver.get(aHref.getAttribute("href"));
assertThat(driver.getTitle(), containsString("Account Management"));
} finally {
revertFlows("browser - alternative non-interactive executor");
}
}
use of org.jboss.arquillian.graphene.page.Page in project keycloak by keycloak.
the class AbstractX509AuthenticationTest method replaceDefaultWebDriver.
public void replaceDefaultWebDriver(WebDriver driver) {
this.driver = driver;
DroneUtils.addWebDriver(driver);
List<Field> allFields = new ArrayList<>();
// Add all fields of this class and superclasses
Class<?> testClass = this.getClass();
while (AbstractX509AuthenticationTest.class.isAssignableFrom(testClass)) {
allFields.addAll(Arrays.asList(testClass.getDeclaredFields()));
allFields.addAll(Arrays.asList(testClass.getFields()));
testClass = testClass.getSuperclass();
}
for (Field f : allFields) {
if (f.getAnnotation(Page.class) != null) {
try {
AbstractPage page = (AbstractPage) f.get(this);
page.setDriver(driver);
} catch (IllegalAccessException e) {
throw new IllegalStateException("Could not replace the driver in " + f, e);
}
}
}
}
use of org.jboss.arquillian.graphene.page.Page in project keycloak by keycloak.
the class BrowserFlowTest method testSwitchExecutionNotAllowedWithRequiredPasswordAndAlternativeOTP.
@Test
@AuthServerContainerExclude(REMOTE)
public void testSwitchExecutionNotAllowedWithRequiredPasswordAndAlternativeOTP() {
String newFlowAlias = "browser - copy 1";
configureBrowserFlowWithRequiredPasswordFormAndAlternativeOTP(newFlowAlias);
try {
loginUsernameOnlyPage.open();
loginUsernameOnlyPage.assertCurrent();
loginUsernameOnlyPage.login("user-with-one-configured-otp");
// Assert on password page now
passwordPage.assertCurrent();
String otpAuthenticatorExecutionId = realmsResouce().realm("test").flows().getExecutions(newFlowAlias).stream().filter(execution -> OTPFormAuthenticatorFactory.PROVIDER_ID.equals(execution.getProviderId())).findFirst().get().getId();
// Manually run request to switch execution to OTP. It shouldn't be allowed and error should be thrown
String actionURL = ActionURIUtils.getActionURIFromPageSource(driver.getPageSource());
String formParameters = Constants.AUTHENTICATION_EXECUTION + "=" + otpAuthenticatorExecutionId + "&" + Constants.CREDENTIAL_ID + "=";
URLUtils.sendPOSTRequestWithWebDriver(actionURL, formParameters);
errorPage.assertCurrent();
} finally {
revertFlows("browser - copy 1");
}
}
Aggregations