use of io.jans.as.client.page.LoginPage in project jans by JanssenProject.
the class SelectAccountHttpTest method selectAccount.
private AuthorizationResponse selectAccount(final String userId, final String userSecret, final String redirectUri, List<ResponseType> responseTypes, List<String> scopes, String clientId, String nonce) {
String state = UUID.randomUUID().toString();
AuthorizationRequest authorizationRequest = new AuthorizationRequest(responseTypes, clientId, scopes, redirectUri, nonce);
authorizationRequest.setState(state);
authorizationRequest.setPrompts(Lists.newArrayList(Prompt.SELECT_ACCOUNT));
String authorizationRequestUrl = authorizationEndpoint + "?" + authorizationRequest.getQueryString();
final SelectPage selectPage = SelectPage.navigate(pageConfig, authorizationRequestUrl);
final String currentUrl = driver.getCurrentUrl();
final LoginPage loginPage = selectPage.clickOnLoginAsAnotherUser();
loginPage.enterUsername(userId);
loginPage.enterPassword(userSecret);
loginPage.getLoginButton().click();
if (ENABLE_REDIRECT_TO_LOGIN_PAGE) {
loginPage.waitForPageSwitch(currentUrl);
}
String authorizationResponseStr = acceptAuthorization(driver, authorizationRequest.getRedirectUri());
AuthorizationResponse authorizationResponse = buildAuthorizationResponse(authorizationRequest, driver, authorizationResponseStr);
assertAuthorizationResponse(authorizationResponse, true);
return authorizationResponse;
}
use of io.jans.as.client.page.LoginPage in project jans by JanssenProject.
the class DeviceAuthzFlowHttpTest method processDeviceAuthzDenyAccess.
private AuthorizationResponse processDeviceAuthzDenyAccess(String userId, String userSecret, String userCode, WebDriver currentDriver, boolean complete, final PageConfig pageConfig) {
String deviceAuthzPageUrl = deviceAuthzEndpoint.replace("/restv1/device_authorization", "/device_authorization.htm") + (complete ? "?user_code=" + userCode : "");
output("Device authz flow: page to navigate to put user_code:" + deviceAuthzPageUrl);
navigateToAuhorizationUrl(currentDriver, deviceAuthzPageUrl);
DeviceAuthzPage deviceAuthzPage = new DeviceAuthzPage(pageConfig);
if (!complete) {
deviceAuthzPage.fillUserCode(userCode);
}
deviceAuthzPage.clickContinueButton();
Wait<WebDriver> wait = new FluentWait<WebDriver>(currentDriver).withTimeout(Duration.ofSeconds(PageConfig.WAIT_OPERATION_TIMEOUT)).pollingEvery(Duration.ofMillis(500)).ignoring(NoSuchElementException.class);
if (userSecret != null) {
final String previousUrl = currentDriver.getCurrentUrl();
WebElement loginButton = wait.until(d -> currentDriver.findElement(By.id(loginFormLoginButton)));
LoginPage loginPage = new LoginPage(pageConfig);
loginPage.enterUsername(userId);
loginPage.enterPassword(userSecret);
loginButton.click();
if (ENABLE_REDIRECT_TO_LOGIN_PAGE) {
waitForPageSwitch(currentDriver, previousUrl);
}
}
denyAuthorization(currentDriver);
String deviceAuthzResponseStr = currentDriver.getCurrentUrl();
stopWebDriver(false, currentDriver);
output("Device authz redirection response url: " + deviceAuthzResponseStr);
return new AuthorizationResponse(deviceAuthzResponseStr);
}
Aggregations