From 70891cd497cd14bc8dab7b988158049ea5f96a46 Mon Sep 17 00:00:00 2001 From: Marcus Da Coregio Date: Thu, 22 Sep 2022 15:55:47 -0300 Subject: [PATCH] Add more information for SAML2 tests failure --- .../example/Saml2JavaConfigurationITests.java | 14 +++++++++++++- .../example/Saml2LoginApplicationITests.java | 14 +++++++++++++- .../example/Saml2LoginApplicationITests.java | 17 ++++++++++++++++- .../integTest/java/example/Saml2XmlITests.java | 14 +++++++++++++- 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/servlet/java-configuration/saml2/login/src/integTest/java/example/Saml2JavaConfigurationITests.java b/servlet/java-configuration/saml2/login/src/integTest/java/example/Saml2JavaConfigurationITests.java index f22721a..1972fdf 100644 --- a/servlet/java-configuration/saml2/login/src/integTest/java/example/Saml2JavaConfigurationITests.java +++ b/servlet/java-configuration/saml2/login/src/integTest/java/example/Saml2JavaConfigurationITests.java @@ -82,7 +82,19 @@ public class Saml2JavaConfigurationITests { HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlPage loginPage = rpLogoutButton.click(); this.webClient.waitForBackgroundJavaScript(10000); - assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); + List urls = new ArrayList<>(); + urls.add(loginPage.getUrl().getFile()); + urls.add(((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).getUrl().getFile()); + assertThat(urls).withFailMessage(() -> { + // @formatter:off + String builder = loginPage.asXml() + + "\n\n\n" + + "Enclosing Page" + + "\n\n\n" + + ((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).asXml(); + // @formatter:on + return builder; + }).contains("/login?logout"); } private void performLogin() throws Exception { diff --git a/servlet/spring-boot/java/saml2/login-single-tenant/src/integTest/java/example/Saml2LoginApplicationITests.java b/servlet/spring-boot/java/saml2/login-single-tenant/src/integTest/java/example/Saml2LoginApplicationITests.java index 0ddf4d0..47b5fb2 100644 --- a/servlet/spring-boot/java/saml2/login-single-tenant/src/integTest/java/example/Saml2LoginApplicationITests.java +++ b/servlet/spring-boot/java/saml2/login-single-tenant/src/integTest/java/example/Saml2LoginApplicationITests.java @@ -63,7 +63,19 @@ public class Saml2LoginApplicationITests { HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlPage loginPage = rpLogoutButton.click(); this.webClient.waitForBackgroundJavaScript(10000); - assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); + List urls = new ArrayList<>(); + urls.add(loginPage.getUrl().getFile()); + urls.add(((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).getUrl().getFile()); + assertThat(urls).withFailMessage(() -> { + // @formatter:off + String builder = loginPage.asXml() + + "\n\n\n" + + "Enclosing Page" + + "\n\n\n" + + ((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).asXml(); + // @formatter:on + return builder; + }).contains("/login?logout"); } private void performLogin() throws Exception { diff --git a/servlet/spring-boot/java/saml2/login/src/integTest/java/example/Saml2LoginApplicationITests.java b/servlet/spring-boot/java/saml2/login/src/integTest/java/example/Saml2LoginApplicationITests.java index 0ddf4d0..adc26b2 100644 --- a/servlet/spring-boot/java/saml2/login/src/integTest/java/example/Saml2LoginApplicationITests.java +++ b/servlet/spring-boot/java/saml2/login/src/integTest/java/example/Saml2LoginApplicationITests.java @@ -16,6 +16,9 @@ package example; +import java.util.ArrayList; +import java.util.List; + import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.html.HtmlElement; @@ -63,7 +66,19 @@ public class Saml2LoginApplicationITests { HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlPage loginPage = rpLogoutButton.click(); this.webClient.waitForBackgroundJavaScript(10000); - assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); + List urls = new ArrayList<>(); + urls.add(loginPage.getUrl().getFile()); + urls.add(((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).getUrl().getFile()); + assertThat(urls).withFailMessage(() -> { + // @formatter:off + String builder = loginPage.asXml() + + "\n\n\n" + + "Enclosing Page" + + "\n\n\n" + + ((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).asXml(); + // @formatter:on + return builder; + }).contains("/login?logout"); } private void performLogin() throws Exception { diff --git a/servlet/xml/java/saml2/login-logout/src/integTest/java/example/Saml2XmlITests.java b/servlet/xml/java/saml2/login-logout/src/integTest/java/example/Saml2XmlITests.java index 3331f54..81f4878 100644 --- a/servlet/xml/java/saml2/login-logout/src/integTest/java/example/Saml2XmlITests.java +++ b/servlet/xml/java/saml2/login-logout/src/integTest/java/example/Saml2XmlITests.java @@ -80,7 +80,19 @@ public class Saml2XmlITests { HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlPage loginPage = rpLogoutButton.click(); this.webClient.waitForBackgroundJavaScript(10000); - assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); + List urls = new ArrayList<>(); + urls.add(loginPage.getUrl().getFile()); + urls.add(((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).getUrl().getFile()); + assertThat(urls).withFailMessage(() -> { + // @formatter:off + String builder = loginPage.asXml() + + "\n\n\n" + + "Enclosing Page" + + "\n\n\n" + + ((HtmlPage) this.webClient.getCurrentWindow().getEnclosedPage()).asXml(); + // @formatter:on + return builder; + }).contains("/login?logout"); } private void performLogin() throws Exception {