Skip to content

Commit

Permalink
feat(jans-auth): update htmlunit driver to htmlunit3 (#8373)
Browse files Browse the repository at this point in the history
Signed-off-by: Yuriy Movchan <Yuriy.Movchan@gmail.com>
  • Loading branch information
yurem committed Apr 24, 2024
1 parent c76a78c commit 724edb5
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
12 changes: 1 addition & 11 deletions jans-auth-server/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -250,29 +250,19 @@
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit-driver</artifactId>
<artifactId>htmlunit3-driver</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-auth-test-model</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ public void startSelenium() {
//driver = new InternetExplorerDriver();

driver = new HtmlUnitDriver(true);
driver.getWebClient().getOptions().setThrowExceptionOnScriptError(false);
}

public void stopSelenium() {
Expand Down Expand Up @@ -812,7 +813,7 @@ public AuthorizationResponse authorizationRequestAndDenyAccess(

final String previousURL = driver.getCurrentUrl();
doNotAllowButton.click();
WebDriverWait wait = new WebDriverWait(driver, 1);
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(1));
wait.until((WebDriver d) -> (d.getCurrentUrl() != previousURL));

String authorizationResponseStr = driver.getCurrentUrl();
Expand Down Expand Up @@ -871,7 +872,7 @@ public AuthorizationResponse authenticateResourceOwner(

navigateToAuhorizationUrl(driver, driver.getCurrentUrl());

new WebDriverWait(driver, PageConfig.WAIT_OPERATION_TIMEOUT)
new WebDriverWait(driver, Duration.ofSeconds(PageConfig.WAIT_OPERATION_TIMEOUT))
.until(webDriver -> !webDriver.getCurrentUrl().contains("/authorize"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.time.Duration;
import java.util.Set;

import static org.testng.Assert.fail;
Expand All @@ -35,7 +36,7 @@ public AbstractPage(PageConfig config) {

public static String waitForPageSwitch(WebDriver currentDriver, String previousURL) {
Holder<String> currentUrl = new Holder<>();
WebDriverWait wait = new WebDriverWait(currentDriver, PageConfig.WAIT_OPERATION_TIMEOUT);
WebDriverWait wait = new WebDriverWait(currentDriver, Duration.ofSeconds(PageConfig.WAIT_OPERATION_TIMEOUT));
wait.until((WebDriver d) -> {
currentUrl.setT(d.getCurrentUrl());
return !currentUrl.getT().equals(previousURL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;
import java.util.List;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -58,7 +59,7 @@ public LoginPage clickOnLoginAsAnotherUser() {

navigate(driver.getCurrentUrl());
if (BaseTest.ENABLE_REDIRECT_TO_LOGIN_PAGE) {
new WebDriverWait(driver, PageConfig.WAIT_OPERATION_TIMEOUT)
new WebDriverWait(driver, Duration.ofSeconds(PageConfig.WAIT_OPERATION_TIMEOUT))
.until((WebDriver d) -> !d.getCurrentUrl().contains("/authorize"));
}
return new LoginPage(config);
Expand Down
6 changes: 6 additions & 0 deletions jans-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,12 @@
<artifactId>sac</artifactId>
<version>1.3</version>
</dependency>

<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>htmlunit3-driver</artifactId>
<version>4.17.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 724edb5

Please sign in to comment.