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

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


The following commit(s) were added to refs/heads/3_0_X by this push:
     new 188695d7ab Attempt to make FIT WA tests more stable
188695d7ab is described below

commit 188695d7ab32d834650336c3b208b44248e6f3c5
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Tue May 2 12:02:49 2023 +0200

    Attempt to make FIT WA tests more stable
---
 .github/dependabot.yml                             | 22 ----------------------
 .../org/apache/syncope/fit/AbstractITCase.java     | 22 ++++++++++++++++++++--
 .../apache/syncope/fit/sra/AbstractSRAITCase.java  | 18 +++++++++---------
 .../org/apache/syncope/fit/sra/CASSRAITCase.java   |  2 +-
 .../org/apache/syncope/fit/sra/OIDCSRAITCase.java  |  9 +++++++--
 .../src/test/resources/sra-saml2.properties        |  2 +-
 6 files changed, 38 insertions(+), 37 deletions(-)

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index 779056e11b..0000000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,22 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License
-version: 2
-updates:
-  - package-ecosystem: "github-actions"
-    directory: "/"
-    schedule:
-      interval: "weekly"
diff --git 
a/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java 
b/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
index 2369d59485..aa34fd3d7f 100644
--- a/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
+++ b/fit/wa-reference/src/test/java/org/apache/syncope/fit/AbstractITCase.java
@@ -22,7 +22,10 @@ import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
+import com.nimbusds.jose.util.IOUtils;
 import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
@@ -111,10 +114,25 @@ public abstract class AbstractITCase {
     public static void waitForWARefresh() {
         SAML2IdPEntityService samlIdPEntityService = 
ADMIN_CLIENT.getService(SAML2IdPEntityService.class);
 
-        await().atMost(50, TimeUnit.SECONDS).pollInterval(1, 
TimeUnit.SECONDS).until(() -> {
+        await().atMost(50, TimeUnit.SECONDS).pollInterval(5, 
TimeUnit.SECONDS).until(() -> {
             boolean refreshed = false;
             try {
-                WebClient.create(WA_ADDRESS + "/idp/metadata").get();
+                String metadata = IOUtils.readInputStreamToString(
+                        (InputStream) WebClient.create(
+                                WA_ADDRESS + 
"/idp/metadata").get().getEntity(),
+                        StandardCharsets.UTF_8);
+                if (metadata.contains("localhost:8080")) {
+                    
WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.conf, List.of());
+                    throw new IllegalStateException();
+                }
+                metadata = IOUtils.readInputStreamToString(
+                        (InputStream) WebClient.create(
+                                WA_ADDRESS + 
"/oidc/.well-known/openid-configuration").get().getEntity(),
+                        StandardCharsets.UTF_8);
+                if (metadata.contains("localhost:8080")) {
+                    
WA_CONFIG_SERVICE.pushToWA(WAConfigService.PushSubject.conf, List.of());
+                    throw new IllegalStateException();
+                }
 
                 samlIdPEntityService.get(SAML2IdPEntityService.DEFAULT_OWNER);
                 refreshed = true;
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 f4eec00fe4..877ebcb9b0 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;
@@ -66,9 +69,7 @@ public abstract class AbstractSRAITCase extends 
AbstractITCase {
 
     protected static final JsonMapper MAPPER = 
JsonMapper.builder().findAndAddModules().build();
 
-    protected static final int PORT = 8080;
-
-    protected static final String SRA_ADDRESS = "http://localhost:"; + PORT;
+    protected static final String SRA_ADDRESS = "http://127.0.0.1:8080";;
 
     protected static final String QUERY_STRING =
             
"key1=value1&key2=value2&key2=value3&key3=an%20url%20encoded%20value%3A%20this%21";
@@ -193,7 +194,7 @@ public abstract class AbstractSRAITCase extends 
AbstractITCase {
         await().atMost(120, TimeUnit.SECONDS).pollInterval(3, 
TimeUnit.SECONDS).until(() -> {
             boolean connected = false;
             try (Socket socket = new Socket()) {
-                socket.connect(new InetSocketAddress("0.0.0.0", PORT));
+                socket.connect(new InetSocketAddress("0.0.0.0", 8080));
                 connected = socket.isConnected();
             } catch (ConnectException e) {
                 // ignore
@@ -291,12 +292,11 @@ 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:8080", "127.0.0.1:8080")));
 
-        assertEquals(
-                StringUtils.substringBefore(originalRequestURI, "?"),
-                StringUtils.substringBefore(json.get("url").asText(), "?"));
+        String withHost = StringUtils.substringBefore(originalRequestURI, "?");
+        String withIP = withHost.replace("localhost", "127.0.0.1");
+        assertThat(StringUtils.substringBefore(json.get("url").asText(), "?"), 
is(oneOf(withHost, withIP)));
 
         return headers;
     }
diff --git 
a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java 
b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java
index 0d53dfbd78..cfa3cf3321 100644
--- 
a/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java
+++ 
b/fit/wa-reference/src/test/java/org/apache/syncope/fit/sra/CASSRAITCase.java
@@ -72,7 +72,7 @@ public class CASSRAITCase extends AbstractSRAITCase {
                     CASSPClientAppTO app = new CASSPClientAppTO();
                     app.setName(appName);
                     app.setClientAppId(4L);
-                    app.setServiceId("http://localhost:8080/.*";);
+                    app.setServiceId("http://127.0.0.1:8080/.*";);
 
                     Response response = 
CLIENT_APP_SERVICE.create(ClientAppType.CASSP, app);
                     if (response.getStatusInfo().getStatusCode() != 
Response.Status.CREATED.getStatusCode()) {
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 864de52504..9736e3b070 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,9 @@
  */
 package org.apache.syncope.fit.sra;
 
+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;
@@ -273,8 +276,10 @@ 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:8080", "127.0.0.1:8080")));
 
-        assertEquals(client.getBaseURI().toASCIIString().replace("/protected", 
""), json.get("url").asText());
+        String withHost = 
client.getBaseURI().toASCIIString().replace("/protected", "");
+        String withIP = withHost.replace("localhost", "127.0.0.1");
+        assertThat(json.get("url").asText(), is(oneOf(withHost, withIP)));
     }
 }
diff --git a/fit/wa-reference/src/test/resources/sra-saml2.properties 
b/fit/wa-reference/src/test/resources/sra-saml2.properties
index eb68049407..b4af1d4fc8 100644
--- a/fit/wa-reference/src/test/resources/sra-saml2.properties
+++ b/fit/wa-reference/src/test/resources/sra-saml2.properties
@@ -22,7 +22,7 @@ sra.am-type=SAML2
 sra.saml2.authn-request-binding=POST
 sra.saml2.logout-request-binding=POST
 sra.saml2.logout-response-binding=REDIRECT
-sra.saml2.entityId=http://localhost:8080
+sra.saml2.entityId=http://127.0.0.1:8080
 sra.saml2.skew=300
 sra.saml2.sp-metadata-file-path=/tmp/saml2-sp-metadata.xml
 sra.saml2.idp-metadata=https://localhost:9443/syncope-wa/idp/metadata

Reply via email to