diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73ff028ec8..2fc3ba71e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -301,8 +301,8 @@ jobs: - testSuite: AppContext04TestSuite compose-profile: with-transform-core-aio - testSuite: AppContext05TestSuite - compose-profile: default - mvn-options: '"-Didentity-service.auth-server-url=http://${HOST_IP}:8999/auth"' + compose-profile: with-sso + mvn-options: '"-Didentity-service.auth-server-url=http://localhost:8999/auth"' - testSuite: AppContext06TestSuite compose-profile: with-transform-core-aio - testSuite: AppContextExtraTestSuite @@ -321,11 +321,7 @@ jobs: - name: "Set transformers tag" run: echo "TRANSFORMERS_TAG=$(mvn help:evaluate -Dexpression=dependency.alfresco-transform-core.version -q -DforceStdout)" >> $GITHUB_ENV - name: "Set up the environment" - run: | - if [ -e ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh ]; then - bash ./scripts/ci/tests/${{ matrix.testSuite }}-setup.sh - fi - docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d + run: docker-compose -f ./scripts/ci/docker-compose/docker-compose.yaml --profile ${{ matrix.compose-profile }} up -d - name: "Run tests" run: mvn -B test -pl repository -am -Dtest=${{ matrix.testSuite }} -DfailIfNoTests=false -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco ${{ matrix.mvn-options }} - name: "Clean Maven cache" diff --git a/repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java b/repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java index d669812d0b..054414530e 100644 --- a/repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java +++ b/repository/src/test/java/org/alfresco/repo/security/authentication/identityservice/IdentityServiceRemoteUserMapperTest.java @@ -2,7 +2,7 @@ * #%L * Alfresco Repository * %% - * Copyright (C) 2005 - 2016 Alfresco Software Limited + * Copyright (C) 2005 - 2024 Alfresco Software Limited * %% * This file is part of the Alfresco software. * If the software was purchased under a paid Alfresco license, the terms of @@ -29,26 +29,18 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import javax.servlet.http.HttpServletRequest; import java.io.ByteArrayInputStream; -import java.net.InetAddress; -import java.net.NetworkInterface; -import java.net.SocketException; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.PublicKey; -import java.util.Enumeration; import java.util.Map; import java.util.Vector; -import java.util.regex.Pattern; - -import javax.servlet.http.HttpServletRequest; import org.alfresco.repo.management.subsystems.AbstractChainedSubsystemTest; import org.alfresco.repo.management.subsystems.ChildApplicationContextFactory; import org.alfresco.repo.management.subsystems.DefaultChildApplicationContextManager; -import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.external.RemoteUserMapper; -import org.alfresco.repo.security.authentication.identityservice.IdentityServiceConfig; import org.alfresco.util.ApplicationContextHelper; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; @@ -128,31 +120,8 @@ public class IdentityServiceRemoteUserMapperTest extends AbstractChainedSubsyste public void testKeycloakConfig() throws Exception { - //Get the host of the IDS test server - String ip = "localhost"; - try { - Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); - while (interfaces.hasMoreElements()) { - NetworkInterface iface = interfaces.nextElement(); - // filters out 127.0.0.1 and inactive interfaces - if (iface.isLoopback() || !iface.isUp()) - continue; - - Enumeration addresses = iface.getInetAddresses(); - while(addresses.hasMoreElements()) { - InetAddress addr = addresses.nextElement(); - if(Pattern.matches("([0-9]{1,3}\\.){3}[0-9]{1,3}", addr.getHostAddress())){ - ip = addr.getHostAddress(); - break; - } - } - } - } catch (SocketException e) { - throw new RuntimeException(e); - } - // check string overrides - assertEquals("identity-service.auth-server-url", "http://"+ip+":8999/auth", + assertEquals("identity-service.auth-server-url", "http://localhost:8999/auth", this.identityServiceConfig.getAuthServerUrl()); assertEquals("identity-service.realm", "alfresco", diff --git a/scripts/ci/docker-compose/docker-compose.yaml b/scripts/ci/docker-compose/docker-compose.yaml index c14fc91734..43f44f7de9 100644 --- a/scripts/ci/docker-compose/docker-compose.yaml +++ b/scripts/ci/docker-compose/docker-compose.yaml @@ -10,7 +10,7 @@ services: - "8090:8090" postgres: image: postgres:14.4 - profiles: ["default", "with-transform-core-aio", "postgres"] + profiles: ["default", "with-transform-core-aio", "postgres", "with-sso"] environment: - POSTGRES_PASSWORD=alfresco - POSTGRES_USER=alfresco @@ -19,8 +19,20 @@ services: ports: - "5433:5432" activemq: - profiles: ["default", "with-transform-core-aio", "activemq"] + profiles: ["default", "with-transform-core-aio", "activemq", "with-sso"] image: alfresco/alfresco-activemq:5.17.1-jre11-rockylinux8 ports: - "5672:5672" # AMQP - - "61616:61616" # OpenWire \ No newline at end of file + - "61616:61616" # OpenWire + keycloak: + profiles: ["with-sso"] + image: quay.io/keycloak/keycloak:24.0.2 + environment: + - KEYCLOAK_ADMIN=admin + - KEYCLOAK_ADMIN_PASSWORD=admin + - KC_DB=dev-mem + command: ["start-dev", "--import-realm", "--http-relative-path=/auth", "--hostname=localhost", "--http-enabled=true"] + volumes: + - ../../../repository/src/test/resources/realms/alfresco-realm.json:/opt/keycloak/data/import/alfresco-realm.json + ports: + - 8999:8080 \ No newline at end of file diff --git a/scripts/ci/tests/AppContext05TestSuite-setup.sh b/scripts/ci/tests/AppContext05TestSuite-setup.sh deleted file mode 100644 index c8458de3c8..0000000000 --- a/scripts/ci/tests/AppContext05TestSuite-setup.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -echo "=========================== Starting AppContext05TestSuite setup ===========================" -PS4="\[\e[35m\]+ \[\e[m\]" -set -vex -pushd "$(dirname "${BASH_SOURCE[0]}")/../../../" - -mkdir -p "${HOME}/tmp" -cp repository/src/test/resources/realms/alfresco-realm.json "${HOME}/tmp" -echo "HOST_IP=$(hostname -I | cut -f1 -d' ')" >> $GITHUB_ENV -docker run -d -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -e DB_VENDOR=h2 -p 8999:8080 -e KEYCLOAK_IMPORT=/tmp/alfresco-realm.json -v $HOME/tmp/alfresco-realm.json:/tmp/alfresco-realm.json alfresco/alfresco-identity-service:1.2 - -popd -set +vex -echo "=========================== Finishing AppContext05TestSuite setup ==========================" \ No newline at end of file