Add more information for SAML2 tests failure

This commit is contained in:
Marcus Da Coregio 2022-09-22 15:55:47 -03:00
parent 738463be8c
commit 70891cd497
4 changed files with 55 additions and 4 deletions

View File

@ -82,7 +82,19 @@ public class Saml2JavaConfigurationITests {
HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button");
HtmlPage loginPage = rpLogoutButton.click(); HtmlPage loginPage = rpLogoutButton.click();
this.webClient.waitForBackgroundJavaScript(10000); this.webClient.waitForBackgroundJavaScript(10000);
assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); List<String> 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 { private void performLogin() throws Exception {

View File

@ -63,7 +63,19 @@ public class Saml2LoginApplicationITests {
HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button");
HtmlPage loginPage = rpLogoutButton.click(); HtmlPage loginPage = rpLogoutButton.click();
this.webClient.waitForBackgroundJavaScript(10000); this.webClient.waitForBackgroundJavaScript(10000);
assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); List<String> 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 { private void performLogin() throws Exception {

View File

@ -16,6 +16,9 @@
package example; package example;
import java.util.ArrayList;
import java.util.List;
import com.gargoylesoftware.htmlunit.ElementNotFoundException; import com.gargoylesoftware.htmlunit.ElementNotFoundException;
import com.gargoylesoftware.htmlunit.WebClient; import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlElement; import com.gargoylesoftware.htmlunit.html.HtmlElement;
@ -63,7 +66,19 @@ public class Saml2LoginApplicationITests {
HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button");
HtmlPage loginPage = rpLogoutButton.click(); HtmlPage loginPage = rpLogoutButton.click();
this.webClient.waitForBackgroundJavaScript(10000); this.webClient.waitForBackgroundJavaScript(10000);
assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); List<String> 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 { private void performLogin() throws Exception {

View File

@ -80,7 +80,19 @@ public class Saml2XmlITests {
HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button"); HtmlElement rpLogoutButton = home.getHtmlElementById("rp_logout_button");
HtmlPage loginPage = rpLogoutButton.click(); HtmlPage loginPage = rpLogoutButton.click();
this.webClient.waitForBackgroundJavaScript(10000); this.webClient.waitForBackgroundJavaScript(10000);
assertThat(loginPage.getUrl().getFile()).isEqualTo("/login?logout"); List<String> 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 { private void performLogin() throws Exception {