You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2023/02/24 10:42:03 UTC

[syncope] 03/03: More flexible assertions for SRA IT cases

This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git

commit 45b7ca129493efc99b0db6be614b0f9e38510e38
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Feb 24 11:41:52 2023 +0100

    More flexible assertions for SRA IT cases
---
 .../src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java | 6 ++++--
 .../src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java     | 6 +++++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java
index 6fc4f7248a..0b7beafbff 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/AbstractSRAITCase.java
@@ -19,6 +19,9 @@
 package org.apache.syncope.fit.sra;
 
 import static org.awaitility.Awaitility.await;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.oneOf;
 import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -258,8 +261,7 @@ public abstract class AbstractSRAITCase extends AbstractITCase {
 
         ObjectNode headers = (ObjectNode) json.get("headers");
         assertEquals(MediaType.TEXT_HTML, headers.get(HttpHeaders.ACCEPT).asText());
-        assertEquals(EN_LANGUAGE, headers.get(HttpHeaders.ACCEPT_LANGUAGE).asText());
-        assertEquals("localhost:" + PORT, headers.get("X-Forwarded-Host").asText());
+        assertThat(headers.get("X-Forwarded-Host").asText(), is(oneOf("localhost:" + PORT, "127.0.0.1:" + PORT)));
 
         assertEquals(
                 StringUtils.substringBefore(originalRequestURI, "?"),
diff --git a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
index d4b92faf55..fb27f5ef09 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/OIDCSRAITCase.java
@@ -18,6 +18,10 @@
  */
 package org.apache.syncope.fit.sra;
 
+import static org.apache.syncope.fit.sra.AbstractSRAITCase.PORT;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.oneOf;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -271,7 +275,7 @@ public class OIDCSRAITCase extends AbstractSRAITCase {
         ObjectNode headers = (ObjectNode) json.get("headers");
         assertEquals(MediaType.APPLICATION_JSON, headers.get(HttpHeaders.ACCEPT).asText());
         assertEquals(MediaType.APPLICATION_JSON, headers.get(HttpHeaders.CONTENT_TYPE).asText());
-        assertEquals("localhost:" + PORT, headers.get("X-Forwarded-Host").asText());
+        assertThat(headers.get("X-Forwarded-Host").asText(), is(oneOf("localhost:" + PORT, "127.0.0.1:" + PORT)));
 
         assertEquals(client.getBaseURI().toASCIIString().replace("/protected", ""), json.get("url").asText());
     }