diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index 7737e41dc37..036675ba74e 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -12,5 +12,8 @@ jobs: with: artifact: go-test-results name: Go Tests - path: '*.xml' - reporter: java-junit \ No newline at end of file + path: '*report.xml' + reporter: java-junit + - name: Publish Test Report + uses: scacap/action-surefire-report@v1 + report_paths: '*testng-results.xml' \ No newline at end of file diff --git a/.github/workflows/test_docker_linux_installer.yml b/.github/workflows/test_docker_linux_installer.yml index 5dbe234a619..4f79669666b 100644 --- a/.github/workflows/test_docker_linux_installer.yml +++ b/.github/workflows/test_docker_linux_installer.yml @@ -80,8 +80,17 @@ jobs: go install github.com/jstemmer/go-junit-report/v2@latest go test -v 2>&1 ./... | go-junit-report > ${{ matrix.persistence-backends }}report.xml + + - uses: actions/upload-artifact@v2 # upload test results + id: upload-go-test-results + if: success() || failure() # run this step even if previous step failed + with: + name: go-test-results + path: ./terraform-provider-jans/${{ matrix.persistence-backends }}report.xml + - uses: actions/upload-artifact@v2 # upload test results + id: upload-java-test-results if: success() || failure() # run this step even if previous step failed with: name: go-test-results - path: ./terraform-provider-jans/${{ matrix.persistence-backends }}report.xml \ No newline at end of file + path: ./tmp/reports/*.xml \ No newline at end of file diff --git a/automation/startjanssenmonolithdemo.sh b/automation/startjanssenmonolithdemo.sh index 42680882fbd..51d7cd65ce8 100644 --- a/automation/startjanssenmonolithdemo.sh +++ b/automation/startjanssenmonolithdemo.sh @@ -17,6 +17,15 @@ if [[ -z $EXT_IP ]]; then EXT_IP=$(dig +short myip.opendns.com @resolver1.opendns.com) fi +wait_for_services() { + code=404 + while [[ "$code" != "200" ]]; do + echo "Waiting for https://${JANS_FQDN}/$1 to respond with 200" + code=$(curl -s -o /dev/null -w ''%{http_code}'' -k https://"${JANS_FQDN}"/"$1") + sleep 5 + done +} + sudo apt-get update # Install Docker and Docker compose plugin sudo apt-get remove docker docker-engine docker.io containerd runc -y || echo "Docker doesn't exist..installing.." @@ -41,7 +50,7 @@ rm -rf /tmp/jans || echo "/tmp/jans doesn't exist" git clone --filter blob:none --no-checkout https://github.com/janssenproject/jans /tmp/jans \ && cd /tmp/jans \ && git sparse-checkout init --cone \ - && git checkout main \ + && git checkout "$JANS_BUILD_COMMIT" \ && git sparse-checkout set docker-jans-monolith \ && cd "$WORKING_DIRECTORY" @@ -59,6 +68,7 @@ if [[ "$JANS_BUILD_COMMIT" ]]; then # and use the respective image instead of the default image python3 -c "from pathlib import Path ; import ruamel.yaml ; compose = Path('/tmp/jans/docker-jans-monolith/jans-mysql-compose.yml') ; yaml = ruamel.yaml.YAML() ; data = yaml.load(compose) ; data['services']['jans']['build'] = '.' ; del data['services']['jans']['image'] ; yaml.dump(data, compose)" python3 -c "from pathlib import Path ; import ruamel.yaml ; compose = Path('/tmp/jans/docker-jans-monolith/jans-postgres-compose.yml') ; yaml = ruamel.yaml.YAML() ; data = yaml.load(compose) ; data['services']['jans']['build'] = '.' ; del data['services']['jans']['image'] ; yaml.dump(data, compose)" + python3 -c "from pathlib import Path ; import ruamel.yaml ; compose = Path('/tmp/jans/docker-jans-monolith/jans-ldap-compose.yml') ; yaml = ruamel.yaml.YAML() ; data = yaml.load(compose) ; data['services']['jans']['build'] = '.' ; del data['services']['jans']['image'] ; yaml.dump(data, compose)" fi # -- if [[ $JANS_PERSISTENCE == "MYSQL" ]]; then @@ -88,8 +98,10 @@ if [ "$jans_status" == '"unhealthy"' ]; then docker logs docker-jans-monolith-jans-1 exit 1 fi -echo "Will be ready in exactly 3 mins" -sleep 180 +wait_for_services jans-config-api/api/v1/health/ready +wait_for_services jans-scim/sys/health-check +wait_for_services jans-fido2/sys/health-check + cat << EOF > testendpoints.sh echo -e "Testing openid-configuration endpoint.. \n" docker exec docker-jans-monolith-jans-1 curl -f -k https://localhost/.well-known/openid-configuration @@ -97,6 +109,21 @@ echo -e "Testing scim-configuration endpoint.. \n" docker exec docker-jans-monolith-jans-1 curl -f -k https://localhost/.well-known/scim-configuration echo -e "Testing fido2-configuration endpoint.. \n" docker exec docker-jans-monolith-jans-1 curl -f -k https://localhost/.well-known/fido2-configuration +mkdir -p /tmp/reports || echo "reports folder exists" +while ! docker exec docker-jans-monolith-jans-1 test -f "/tmp/httpd.crt"; do + echo "Waiting for the container to run java test preparations" + sleep 5 +done +echo -e "Running build.. \n" +docker exec -w /tmp/jans/jans-auth-server docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=true -fae clean compile install +echo -e "Running tests.. \n" +docker exec -w /tmp/jans/jans-auth-server docker-jans-monolith-jans-1 mvn -Dcfg="$JANS_FQDN" -Dmaven.test.skip=false test +echo -e "copying reports.. \n" +docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/client/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-client-testng-results.xml +docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/agama/model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-agama-model-testng-results.xml +docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/test-model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-test-model-testng-results.xml +docker cp docker-jans-monolith-jans-1:/tmp/jans/jans-auth-server/model/target/surefire-reports/testng-results.xml /tmp/reports/$JANS_PERSISTENCE-jans-auth-model-testng-results.xml + EOF sudo bash testendpoints.sh echo -e "You may re-execute bash testendpoints.sh to do a quick test to check the configuration endpoints." diff --git a/docker-jans-monolith/Dockerfile b/docker-jans-monolith/Dockerfile index f3ddb844767..6972e840859 100644 --- a/docker-jans-monolith/Dockerfile +++ b/docker-jans-monolith/Dockerfile @@ -16,7 +16,7 @@ RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker \ # Prevent prompt errors during package installation RUN DEBIAN_FRONTEND=noninteractive \ apt-get update \ - && apt-get install -y python3 tini curl ca-certificates dbus systemd iproute2 gpg python3-pip python3-dev libpq-dev gcc python3-psycopg2 python3-ldap3 \ + && apt-get install -y python3 tini curl ca-certificates dbus systemd iproute2 gpg python3-pip python3-dev libpq-dev gcc python3-psycopg2 python3-ldap3 git maven \ && apt-get clean \ # Cleaning up package lists && rm -rf /var/lib/apt/lists/* diff --git a/docker-jans-monolith/scripts/entrypoint.sh b/docker-jans-monolith/scripts/entrypoint.sh index 32007ee42ca..5a3ab3c8e8b 100644 --- a/docker-jans-monolith/scripts/entrypoint.sh +++ b/docker-jans-monolith/scripts/entrypoint.sh @@ -41,6 +41,7 @@ install_jans() { echo "test_client_id=${TEST_CLIENT_ID}"| tee -a setup.properties > /dev/null echo "test_client_pw=${TEST_CLIENT_SECRET}" | tee -a setup.properties > /dev/null1 echo "test_client_trusted=""$([[ ${TEST_CLIENT_TRUSTED} == true ]] && echo True || echo True)" | tee -a setup.properties > /dev/null + echo "loadTestData=True" | tee -a setup.properties > /dev/null if [[ "${CN_INSTALL_MYSQL}" == "true" ]] || [[ "${CN_INSTALL_PGSQL}" == "true" ]]; then echo "Installing with RDBMS" echo "rdbm_install=2" | tee -a setup.properties > /dev/null @@ -65,7 +66,7 @@ install_jans() { echo "***** PLEASE NOTE THAT THIS MAY TAKE A WHILE TO FINISH. PLEASE BE PATIENT!! *****" echo "Executing https://raw.githubusercontent.com/JanssenProject/jans/${JANS_SOURCE_VERSION}/jans-linux-setup/jans_setup/install.py > install.py" curl https://raw.githubusercontent.com/JanssenProject/jans/"${JANS_SOURCE_VERSION}"/jans-linux-setup/jans_setup/install.py > install.py - echo "Executing python3 install.py -yes --args=-f setup.properties -n -test-client-id=${TEST_CLIENT_ID} -test-client-secret=${TEST_CLIENT_SECRET} --test-client-trusted" + echo "Executing python3 install.py -yes --args=-f setup.properties -n" python3 install.py -yes --args="-f setup.properties -n" echo "***** Setup script completed!! *****" @@ -81,6 +82,49 @@ check_installed_jans() { fi } +prepare_auth_server_test() { + WORKING_DIRECTORY=$PWD + echo "***** cloning jans auth server folder!! *****" + rm -rf /tmp/jans || echo "Jans isn't cloned yet..Cloning"\ + && git clone --filter blob:none --no-checkout https://github.com/janssenproject/jans /tmp/jans \ + && cd /tmp/jans \ + && git sparse-checkout init --cone \ + && git checkout "${JANS_SOURCE_VERSION}" \ + && git sparse-checkout set jans-auth-server \ + && cd jans-auth-server \ + && echo "Copying auth server test profiles from ephemeral server" \ + && cp -R /opt/jans/jans-setup/output/test/jans-auth ./ \ + && echo "Creating auth server profile folders" \ + && mkdir -p ./client/profiles/"${CN_HOSTNAME}" \ + && mkdir -p ./server/profiles/"${CN_HOSTNAME}" \ + && echo "Copying auth server profile files" \ + && cp ./jans-auth/client/* ./client/profiles/"${CN_HOSTNAME}" \ + && cp ./jans-auth/server/* ./server/profiles"/${CN_HOSTNAME}" \ + && echo "Copying auth server keystores from default profile" \ + && cp -f ./client/profiles/default/client_keystore.p12 ./client/profiles/"${CN_HOSTNAME}" \ + && cp -f ./server/profiles/default/client_keystore.p12 ./server/profiles/"${CN_HOSTNAME}" \ + && echo "Removing test profile folder" \ + && rm -rf ./jans-auth \ + && cd agama \ + && cp /opt/jans/jans-setup/output/test/jans-auth/config-agama-test.properties . \ + && mkdir -p ./engine/profiles/"${CN_HOSTNAME}" \ + && mv config-agama-test.properties ./engine/profiles/"${CN_HOSTNAME}"/config-agama-test.properties \ + && cd .. \ + && echo "Checking if the compilation and install is ok without running the tests" \ + && echo "Installing the jans cert in local keystore" \ + && openssl s_client -connect "${CN_HOSTNAME}":443 2>&1 |sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/httpd.crt \ + && TrustStorePW=$(grep -Po '(?<=defaultTrustStorePW=)\S+' /opt/jans/jans-setup/setup.properties.last) \ + && keytool -import -trustcacerts -noprompt -storepass "${TrustStorePW}" -alias "${CN_HOSTNAME}" -keystore /usr/lib/jvm/java-11-openjdk-amd64/lib/security/cacerts -file /tmp/httpd.crt \ + && cd "$WORKING_DIRECTORY" +} + +prepare_java_tests() { + echo "***** Running Java tests!! *****" + echo "***** Running Auth server tests!! *****" + prepare_auth_server_test + echo "***** Java tests completed!! *****" +} + start_services() { /etc/init.d/apache2 start /opt/dist/scripts/jans-auth start @@ -91,6 +135,7 @@ start_services() { check_installed_jans start_services +prepare_java_tests || "Java test preparations failed!!" # use -F option to follow (and retry) logs tail -F /opt/jans/jetty/jans-auth/logs/*.log \