Merge branch '6.2.x'
This commit is contained in:
@@ -20,14 +20,10 @@ dependencies {
|
|||||||
implementation 'org.springframework.security:spring-security-cas'
|
implementation 'org.springframework.security:spring-security-cas'
|
||||||
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
|
||||||
|
|
||||||
testImplementation 'net.sourceforge.htmlunit:htmlunit'
|
|
||||||
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
testImplementation 'org.springframework.boot:spring-boot-starter-test'
|
||||||
testImplementation 'org.springframework.security:spring-security-test'
|
testImplementation 'org.springframework.security:spring-security-test'
|
||||||
testImplementation "org.testcontainers:junit-jupiter"
|
testImplementation "org.testcontainers:junit-jupiter"
|
||||||
testImplementation 'com.codeborne:selenide:7.0.2'
|
testImplementation 'com.microsoft.playwright:playwright:1.42.0'
|
||||||
testImplementation 'org.seleniumhq.selenium:selenium-chrome-driver'
|
|
||||||
testImplementation 'org.seleniumhq.selenium:selenium-java'
|
|
||||||
testImplementation 'io.github.bonigarcia:webdrivermanager:5.6.4'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(Test).configureEach {
|
tasks.withType(Test).configureEach {
|
||||||
|
|||||||
@@ -16,13 +16,12 @@
|
|||||||
|
|
||||||
package cas.example;
|
package cas.example;
|
||||||
|
|
||||||
import com.codeborne.selenide.Configuration;
|
import com.microsoft.playwright.Browser;
|
||||||
import com.codeborne.selenide.Selenide;
|
import com.microsoft.playwright.Page;
|
||||||
import io.github.bonigarcia.wdm.WebDriverManager;
|
import com.microsoft.playwright.Playwright;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.BeforeAll;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.openqa.selenium.By;
|
|
||||||
import org.testcontainers.containers.BindMode;
|
import org.testcontainers.containers.BindMode;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
import org.testcontainers.containers.wait.strategy.Wait;
|
import org.testcontainers.containers.wait.strategy.Wait;
|
||||||
@@ -60,6 +59,10 @@ class CasLoginApplicationTests {
|
|||||||
BindMode.READ_WRITE)
|
BindMode.READ_WRITE)
|
||||||
.waitingFor(Wait.forLogMessage(".*Ready to process requests.*", 1));
|
.waitingFor(Wait.forLogMessage(".*Ready to process requests.*", 1));
|
||||||
|
|
||||||
|
Playwright playwright;
|
||||||
|
|
||||||
|
Browser browser;
|
||||||
|
|
||||||
@DynamicPropertySource
|
@DynamicPropertySource
|
||||||
static void casProperties(DynamicPropertyRegistry registry) {
|
static void casProperties(DynamicPropertyRegistry registry) {
|
||||||
String casUrl = String.format("http://%s:%s/cas", casServer.getHost(), casServer.getMappedPort(8080));
|
String casUrl = String.format("http://%s:%s/cas", casServer.getHost(), casServer.getMappedPort(8080));
|
||||||
@@ -68,42 +71,42 @@ class CasLoginApplicationTests {
|
|||||||
registry.add("cas.logout.url", () -> casUrl + "/logout");
|
registry.add("cas.logout.url", () -> casUrl + "/logout");
|
||||||
}
|
}
|
||||||
|
|
||||||
@BeforeAll
|
@BeforeEach
|
||||||
static void setUp() {
|
void setUp() {
|
||||||
WebDriverManager.chromedriver()
|
this.playwright = Playwright.create();
|
||||||
.clearDriverCache()
|
this.browser = this.playwright.chromium().launch();
|
||||||
.clearResolutionCache()
|
|
||||||
.browserInDocker()
|
|
||||||
.browserVersion("114")
|
|
||||||
.setup();
|
|
||||||
Configuration.headless = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterEach
|
@AfterEach
|
||||||
void setup() {
|
void setup() {
|
||||||
Selenide.closeWindow();
|
this.browser.close();
|
||||||
|
this.playwright.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void login() {
|
void login() {
|
||||||
doLogin();
|
try (Page page = doLogin()) {
|
||||||
String lead = Selenide.$(By.className("lead")).text();
|
String lead = page.locator(".lead").textContent();
|
||||||
assertThat(lead).isEqualTo("You are successfully logged in as casuser");
|
assertThat(lead).isEqualTo("You are successfully logged in as casuser");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doLogin() {
|
|
||||||
Selenide.open("http://localhost:" + this.port);
|
|
||||||
Selenide.$(By.name("username")).setValue("casuser");
|
|
||||||
Selenide.$(By.name("password")).setValue("Mellon");
|
|
||||||
Selenide.$(By.name("submitBtn")).click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginAndLogout() {
|
void loginAndLogout() {
|
||||||
doLogin();
|
try (Page page = doLogin()) {
|
||||||
Selenide.$(By.id("rp_logout_button")).click();
|
page.click("#rp_logout_button");
|
||||||
String logoutMsg = Selenide.$(By.id("logout-msg")).text();
|
String logoutMsg = page.locator("#logout-msg").textContent();
|
||||||
assertThat(logoutMsg).isEqualTo("You are successfully logged out of the app, but not CAS");
|
assertThat(logoutMsg).isEqualTo("You are successfully logged out of the app, but not CAS");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Page doLogin() {
|
||||||
|
Page page = this.browser.newPage();
|
||||||
|
page.navigate("http://localhost:" + this.port);
|
||||||
|
page.fill("//input[@name='username']", "casuser");
|
||||||
|
page.fill("//input[@name='password']", "Mellon");
|
||||||
|
page.click("//button[@name='submitBtn']");
|
||||||
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
Reference in New Issue
Block a user