From 58c8a31277ef6f651faf48829b7afc7e826c3e50 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Tue, 25 Sep 2018 16:35:30 +0200 Subject: [PATCH 01/73] Fix build scripts --- midpoint/README.md | 2 +- midpoint/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/midpoint/README.md b/midpoint/README.md index 511f0a6..bd1cfd4 100644 --- a/midpoint/README.md +++ b/midpoint/README.md @@ -3,7 +3,7 @@ This is a midPoint dockerization for TIER environment. It is a work in progress. # Building and execution ``` $ ./build.sh -$ docker-compose up +$ docker-compose up --build ``` Please see a detailed description [here](https://spaces.at.internet2.edu/display/MID/Dockerized+midPoint). diff --git a/midpoint/build.sh b/midpoint/build.sh index 760eea6..0463d37 100755 --- a/midpoint/build.sh +++ b/midpoint/build.sh @@ -26,7 +26,7 @@ echo "" echo "(for standalone execution)" echo "" echo "$ cd" `pwd` -echo "$ docker-compose up" +echo "$ docker-compose up --build" echo "" echo "(for complex demo)" echo "" From 8f5f3059debd75dd06a2e923e9156d61c3804103 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Tue, 25 Sep 2018 17:18:29 +0200 Subject: [PATCH 02/73] Add Docker health check Note: it does not work with Shibboleth authentication yet. --- midpoint/midpoint-server/Dockerfile | 5 ++++- .../container_files/usr-local-bin/healthcheck.sh | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100755 midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh diff --git a/midpoint/midpoint-server/Dockerfile b/midpoint/midpoint-server/Dockerfile index e1be60b..090c4f6 100644 --- a/midpoint/midpoint-server/Dockerfile +++ b/midpoint/midpoint-server/Dockerfile @@ -31,7 +31,8 @@ RUN chmod 755 /opt/tier/setenv.sh \ && chmod 755 /usr/local/bin/setup-cron.sh \ && chmod 755 /usr/local/bin/start-midpoint.sh \ && chmod 755 /usr/local/bin/start-httpd.sh \ - && chmod 755 /usr/local/bin/startup.sh + && chmod 755 /usr/local/bin/startup.sh \ + && chmod 755 /usr/local/bin/healthcheck.sh RUN cp /dev/null /etc/httpd/conf.d/ssl.conf \ && sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' /etc/httpd/conf/httpd.conf \ @@ -105,4 +106,6 @@ RUN rm /etc/localtime \ RUN /opt/tier/setenv.sh +HEALTHCHECK --interval=1m --timeout=30s --start-period=2m CMD /usr/local/bin/healthcheck.sh + CMD ["/usr/local/bin/startup.sh"] diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh b/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh new file mode 100755 index 0000000..e25c16f --- /dev/null +++ b/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +(set -o pipefail ; curl -k -f http://localhost:443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"") || exit 1 From a084cfca1a0b45ed632a77540f43e22da45c07cc Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Tue, 25 Sep 2018 17:24:41 +0200 Subject: [PATCH 03/73] Fix healthcheck mistake --- .../container_files/usr-local-bin/healthcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh b/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh index e25c16f..99f8963 100755 --- a/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh +++ b/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh @@ -1,3 +1,3 @@ #!/bin/bash -(set -o pipefail ; curl -k -f http://localhost:443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"") || exit 1 +(set -o pipefail ; curl -k -f https://localhost:443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"") || exit 1 From bed5f729f423932641b7e1ece320d6a4cbefaf84 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Sep 2018 10:01:09 +0200 Subject: [PATCH 04/73] Remove non-UTC timezone from containers This was for testing the logging requirement concerning UTC timestamps. --- demo/complex/grouper-daemon/Dockerfile | 5 ----- demo/complex/grouper-data/Dockerfile | 5 ----- demo/complex/grouper-ui/Dockerfile | 5 ----- demo/complex/idp/Dockerfile | 5 ----- midpoint/midpoint-server/Dockerfile | 5 ----- 5 files changed, 25 deletions(-) diff --git a/demo/complex/grouper-daemon/Dockerfile b/demo/complex/grouper-daemon/Dockerfile index 04016b9..f620350 100644 --- a/demo/complex/grouper-daemon/Dockerfile +++ b/demo/complex/grouper-daemon/Dockerfile @@ -2,9 +2,4 @@ FROM tier/grouper:latest LABEL author="tier-packaging@internet2.edu " -# JUST FOR TESTING - REMOVE BEFORE RELEASE -RUN rm /etc/localtime \ - && ln -s /usr/share/zoneinfo/US/Central /etc/localtime \ - && date - CMD ["daemon"] diff --git a/demo/complex/grouper-data/Dockerfile b/demo/complex/grouper-data/Dockerfile index 9ceedec..5ca6a12 100644 --- a/demo/complex/grouper-data/Dockerfile +++ b/demo/complex/grouper-data/Dockerfile @@ -37,9 +37,4 @@ RUN (mysqld_safe & ) \ EXPOSE 3306 -# JUST FOR TESTING - REMOVE BEFORE RELEASE -RUN rm /etc/localtime \ - && ln -s /usr/share/zoneinfo/US/Central /etc/localtime \ - && date - CMD mysqld_safe diff --git a/demo/complex/grouper-ui/Dockerfile b/demo/complex/grouper-ui/Dockerfile index 965cd6f..8fec2ae 100644 --- a/demo/complex/grouper-ui/Dockerfile +++ b/demo/complex/grouper-ui/Dockerfile @@ -4,9 +4,4 @@ LABEL author="tier-packaging@internet2.edu " #COPY in custom css, images, etc -# JUST FOR TESTING - REMOVE BEFORE RELEASE -RUN rm /etc/localtime \ - && ln -s /usr/share/zoneinfo/US/Central /etc/localtime \ - && date - CMD ["ui"] diff --git a/demo/complex/idp/Dockerfile b/demo/complex/idp/Dockerfile index 35eb456..7d0b512 100644 --- a/demo/complex/idp/Dockerfile +++ b/demo/complex/idp/Dockerfile @@ -2,9 +2,4 @@ FROM unicon/shibboleth-idp:latest LABEL author="tier-packaging@internet2.edu " -# JUST FOR TESTING - REMOVE BEFORE RELEASE -RUN rm /etc/localtime \ - && ln -s /usr/share/zoneinfo/US/Central /etc/localtime \ - && date - COPY shibboleth-idp/ /opt/shibboleth-idp/ diff --git a/midpoint/midpoint-server/Dockerfile b/midpoint/midpoint-server/Dockerfile index 090c4f6..4119876 100644 --- a/midpoint/midpoint-server/Dockerfile +++ b/midpoint/midpoint-server/Dockerfile @@ -99,11 +99,6 @@ ENV TIER_MAINTAINER=tier # requires MP_VERSION and TIER_xyz variables so we have to execute it here -# JUST FOR TESTING - REMOVE BEFORE RELEASE -RUN rm /etc/localtime \ - && ln -s /usr/share/zoneinfo/US/Central /etc/localtime \ - && date - RUN /opt/tier/setenv.sh HEALTHCHECK --interval=1m --timeout=30s --start-period=2m CMD /usr/local/bin/healthcheck.sh From 91fd1bdfcfc44a1919f57b4b82529efd1fe435d0 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Sep 2018 11:07:58 +0200 Subject: [PATCH 05/73] Use standard tier/mariadb instead of custom one It was not easy to build two Docker images in TIER Jenkinsfile (using docker/util). It seems that tier/mariadb:mariadb10 is OK to be used with midPoint without any customizations, so we use it. --- Jenkinsfile | 23 +++--------- README.md | 11 +++--- common.bash | 1 - demo/complex/.env | 4 +-- .../application/database_password.txt | 2 +- demo/complex/docker-compose.yml | 2 +- midpoint/.env | 4 +-- midpoint/build.sh | 6 +--- .../application/database_password.txt | 2 +- midpoint/docker-compose.yml | 6 +--- midpoint/midpoint-data/Dockerfile | 35 ------------------- midpoint/midpoint-data/conf/mariadb.repo | 6 ---- midpoint/midpoint-data/database_password.txt | 1 - midpoint/midpoint-data/readme.txt | 1 - 14 files changed, 17 insertions(+), 87 deletions(-) delete mode 100644 midpoint/midpoint-data/Dockerfile delete mode 100644 midpoint/midpoint-data/conf/mariadb.repo delete mode 100644 midpoint/midpoint-data/database_password.txt delete mode 100644 midpoint/midpoint-data/readme.txt diff --git a/Jenkinsfile b/Jenkinsfile index 2def24c..9a52a9d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -3,7 +3,6 @@ pipeline { environment { maintainer = "t" imagename = 'm' - imagename_data = 'md' tag = 'l' } stages { @@ -12,14 +11,13 @@ pipeline { script { maintainer = maintain() imagename = imagename() - imagename_data = imagename_data() if(env.BRANCH_NAME == "master") { tag = "latest" } else { tag = env.BRANCH_NAME } - if(!imagename || !imagename_data){ - echo "You must define imagename and imagename_data in common.bash" + if(!imagename){ + echo "You must define imagename in common.bash" currentBuild.result = 'FAILURE' } sh 'mkdir -p bin' @@ -58,21 +56,13 @@ pipeline { // sh 'cd test-compose && docker-compose down' baseImg.push("$tag") } - docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { - def baseImg = docker.build("$maintainer/$imagename_data", "--no-cache midpoint/midpoint-data") - // test the environment - // sh 'cd test-compose && ./compose.sh' - // bring down after testing - // sh 'cd test-compose && docker-compose down' - baseImg.push("$tag") - } } } } stage('Notify') { steps { echo "$maintainer" - slackSend color: 'good', message: "$maintainer/$imagename:$tag and $maintainer/$imagename_data:$tag pushed to DockerHub" + slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" } } } @@ -82,7 +72,7 @@ pipeline { } failure { // slackSend color: 'good', message: "Build failed" - handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag} or ${maintainer}/${imagename_data}:${tag}.") + handleError("BUILD ERROR: There was a problem building ${maintainer}/${imagename}:${tag}.") } } } @@ -98,11 +88,6 @@ def imagename() { matcher ? matcher[0][1] : null } -def imagename_data() { - def matcher = readFile('common.bash') =~ 'imagename_data="(.+)"' - matcher ? matcher[0][1] : null -} - def handleError(String message){ echo "${message}" currentBuild.setResult("FAILED") diff --git a/README.md b/README.md index 503d12d..e3bd121 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,15 @@ [![Build Status](https://jenkins.testbed.tier.internet2.edu/job/docker/job/midPoint_container/job/master/badge/icon)](https://jenkins.testbed.tier.internet2.edu/job/docker/job/midPoint_container/job/master/) -This repository contains sources for TIER-supported images related to [Evolveum midPoint](http://midpoint.evolveum.com). +This repository contains sources for TIER-supported [midPoint](http://midpoint.evolveum.com) image. -# Images -- `midpoint` contains the midPoint application along with some TIER-specific components: Apache reverse proxy with optional Shibboleth filter and TIER Beacon. -- `midpoint-mariadb` hosts the default MariaDB database tailored to meet midPoint needs. It can be exchanged for another repository implementation. +The image contains the midPoint application along with some TIER-specific components: Apache reverse proxy with optional Shibboleth filter and TIER Beacon. # Supported tags -These tags apply to both containers: - latest - midPoint version-specific tags, e.g. 3.9, 3.9.1, 4.0, etc. # Content -- `midpoint` directory contains build instructions for both containers (`midpoint` and `midpoint-mariadb`), +- `midpoint` directory contains build instructions for the `midpoint` image along with `docker-compose.yml` showing its basic use, - `demo` directory contains three demonstration scenarios: - `shibboleth` to show integration with Shibboleth IdP, - `postgresql` to show how to change the repository implementation, @@ -22,7 +19,7 @@ These tags apply to both containers: Please see specific subdirectories: [midpoint](midpoint) and [demo/complex](demo/complex). # Documentation -- For the `midpoint` and `midpoint-mariadb` containers themselves please see [Dockerized midPoint](https://spaces.at.internet2.edu/display/MID/Dockerized+midPoint) wiki page. +- For the `midpoint` image and container themselves please see [Dockerized midPoint](https://spaces.at.internet2.edu/display/MID/Dockerized+midPoint) wiki page. - For the complex demo please see [midPoint - Grouper integration demo](https://spaces.at.internet2.edu/display/MID/midPoint+-+Grouper+integration+demo) wiki page. This is a work in progress. For its current status please see [Status of the work](https://spaces.at.internet2.edu/display/MID/Status+of+the+work). diff --git a/common.bash b/common.bash index 5f9b7b0..45039e1 100644 --- a/common.bash +++ b/common.bash @@ -1,3 +1,2 @@ maintainer="tier" imagename="midpoint" -imagename_data="midpoint-mariadb" diff --git a/demo/complex/.env b/demo/complex/.env index 03f48af..ce20478 100644 --- a/demo/complex/.env +++ b/demo/complex/.env @@ -5,8 +5,8 @@ REPO_DATABASE_TYPE=mariadb REPO_JDBC_URL=default REPO_HOST=midpoint-data REPO_PORT=default -REPO_DATABASE=midpoint -REPO_USER=root +REPO_DATABASE=registry +REPO_USER=registry_user REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt KEYSTORE_PASSWORD_FILE=/run/secrets/m_keystore_password.txt MEM=2048m diff --git a/demo/complex/configs-and-secrets/midpoint/application/database_password.txt b/demo/complex/configs-and-secrets/midpoint/application/database_password.txt index 11bac01..11bff19 100644 --- a/demo/complex/configs-and-secrets/midpoint/application/database_password.txt +++ b/demo/complex/configs-and-secrets/midpoint/application/database_password.txt @@ -1 +1 @@ -456654 +WJzesbe3poNZ91qIbmR7 diff --git a/demo/complex/docker-compose.yml b/demo/complex/docker-compose.yml index c691377..8e16c92 100644 --- a/demo/complex/docker-compose.yml +++ b/demo/complex/docker-compose.yml @@ -190,7 +190,7 @@ services: - target_data:/var/lib/mysql midpoint-data: - image: tier/midpoint-mariadb:latest + image: tier/mariadb:mariadb10 ports: - "33306:3306" networks: diff --git a/midpoint/.env b/midpoint/.env index 03f48af..ce20478 100644 --- a/midpoint/.env +++ b/midpoint/.env @@ -5,8 +5,8 @@ REPO_DATABASE_TYPE=mariadb REPO_JDBC_URL=default REPO_HOST=midpoint-data REPO_PORT=default -REPO_DATABASE=midpoint -REPO_USER=root +REPO_DATABASE=registry +REPO_USER=registry_user REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt KEYSTORE_PASSWORD_FILE=/run/secrets/m_keystore_password.txt MEM=2048m diff --git a/midpoint/build.sh b/midpoint/build.sh index 0463d37..4b53a25 100755 --- a/midpoint/build.sh +++ b/midpoint/build.sh @@ -15,11 +15,7 @@ function normalize_path() cd "$(dirname "$0")" ./download-midpoint -cd midpoint-data -docker build --tag tier/midpoint-mariadb:latest . -cd ../midpoint-server -docker build --tag tier/midpoint:latest . -cd .. +docker build --tag tier/midpoint:latest midpoint-server echo "---------------------------------------------------------------------------------------" echo "The midPoint containers were successfully built. To start them, execute the following:" echo "" diff --git a/midpoint/configs-and-secrets/midpoint/application/database_password.txt b/midpoint/configs-and-secrets/midpoint/application/database_password.txt index 11bac01..11bff19 100644 --- a/midpoint/configs-and-secrets/midpoint/application/database_password.txt +++ b/midpoint/configs-and-secrets/midpoint/application/database_password.txt @@ -1 +1 @@ -456654 +WJzesbe3poNZ91qIbmR7 diff --git a/midpoint/docker-compose.yml b/midpoint/docker-compose.yml index 6605429..191414d 100644 --- a/midpoint/docker-compose.yml +++ b/midpoint/docker-compose.yml @@ -9,9 +9,7 @@ version: "3.3" services: midpoint-data: - build: ./midpoint-data/ - expose: - - 3306 + image: tier/mariadb:mariadb10 ports: - 3306:3306 networks: @@ -21,8 +19,6 @@ services: midpoint-server: build: ./midpoint-server/ - expose: - - 443 ports: - 8443:443 environment: diff --git a/midpoint/midpoint-data/Dockerfile b/midpoint/midpoint-data/Dockerfile deleted file mode 100644 index 3249b23..0000000 --- a/midpoint/midpoint-data/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -FROM centos:centos7 - -LABEL author="tier-packaging@internet2.edu " - -COPY ./conf/mariadb.repo /etc/yum.repos.d/ - -RUN yum install -y epel-release \ - && yum update -y \ - && yum install -y mariadb-server mariadb \ - && yum clean all \ - && rm -rf /var/cache/yum - -COPY database_password.txt /tmp/ - -RUN mysql_install_db \ - && chown -R mysql:mysql /var/lib/mysql/ \ - && sed -i 's/^\(bind-address\s.*\)/# \1/' /etc/my.cnf \ - && sed -i 's/^\(log_error\s.*\)/# \1/' /etc/my.cnf \ - && sed -i 's/\[mysqld\]/\[mysqld\]\ncharacter_set_server = utf8/' /etc/my.cnf \ - && sed -i 's/\[mysqld\]/\[mysqld\]\ncollation_server = utf8_bin/' /etc/my.cnf \ - && sed -i 's/\[mysqld\]/\[mysqld\]\nport = 3306/' /etc/my.cnf \ - && cat /etc/my.cnf \ - && echo "/usr/bin/mysqld_safe &" > /tmp/config \ - && echo "mysqladmin --silent --wait=30 ping || exit 1" >> /tmp/config \ - && echo "mysql -e \"CREATE USER 'root'@'%' IDENTIFIED BY '`cat /tmp/database_password.txt`';\"" >> /tmp/config \ - && echo "mysql -e 'GRANT ALL PRIVILEGES ON *.* TO \"root\"@\"%\" WITH GRANT OPTION;'" >> /tmp/config \ - && echo "mysql -e 'CREATE DATABASE midpoint CHARACTER SET utf8 COLLATE utf8_bin;'" >> /tmp/config \ - && echo "mysql -e \"SET PASSWORD FOR 'root'@'localhost' = PASSWORD('`cat /tmp/database_password.txt`');\"" >> /tmp/config \ - && cat /tmp/config \ - && bash /tmp/config \ - && rm -f /tmp/config /tmp/database_password.txt - -EXPOSE 3306 - -CMD mysqld_safe diff --git a/midpoint/midpoint-data/conf/mariadb.repo b/midpoint/midpoint-data/conf/mariadb.repo deleted file mode 100644 index e24b3a0..0000000 --- a/midpoint/midpoint-data/conf/mariadb.repo +++ /dev/null @@ -1,6 +0,0 @@ -[mariadb] -name = MariaDB -baseurl = http://yum.mariadb.org/10.1/centos7-amd64 -gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB -gpgcheck=1 - diff --git a/midpoint/midpoint-data/database_password.txt b/midpoint/midpoint-data/database_password.txt deleted file mode 100644 index 11bac01..0000000 --- a/midpoint/midpoint-data/database_password.txt +++ /dev/null @@ -1 +0,0 @@ -456654 diff --git a/midpoint/midpoint-data/readme.txt b/midpoint/midpoint-data/readme.txt deleted file mode 100644 index e0affb1..0000000 --- a/midpoint/midpoint-data/readme.txt +++ /dev/null @@ -1 +0,0 @@ -database_password.txt should be synchronized with ../configs-and-secrets/midpoint/database_password.txt From 8a2e11cfa521700ff94544ebc9dd722bcaf1b8e3 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Sep 2018 13:50:37 +0200 Subject: [PATCH 06/73] Do first attempt at testing midPoint container --- Jenkinsfile | 7 ++----- midpoint/test.sh | 22 ++++++++++++++++++++++ midpoint/test/wait-for-start.sh | 16 ++++++++++++++++ test.sh | 10 ++++++++++ test/common.sh | 18 ++++++++++++++++++ 5 files changed, 68 insertions(+), 5 deletions(-) create mode 100755 midpoint/test.sh create mode 100755 midpoint/test/wait-for-start.sh create mode 100755 test.sh create mode 100755 test/common.sh diff --git a/Jenkinsfile b/Jenkinsfile index 9a52a9d..d646d1a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,12 +48,9 @@ pipeline { steps { script { sh 'midpoint/download-midpoint' - docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { + docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server") - // test the environment - // sh 'cd test-compose && ./compose.sh' - // bring down after testing - // sh 'cd test-compose && docker-compose down' + sh './test.sh' baseImg.push("$tag") } } diff --git a/midpoint/test.sh b/midpoint/test.sh new file mode 100755 index 0000000..96071d9 --- /dev/null +++ b/midpoint/test.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +trap 'exitcode=$? ; echo "Exiting midpoint/test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR + +cd "$(dirname "$0")" +. ../test/common.sh + +yellow "*** Composing midPoint..." +docker-compose up --no-start +green "==> midPoint composed OK" +echo +yellow "*** Starting midPoint..." +docker-compose start +green "==> midPoint started OK" +echo +yellow "*** Waiting for midPoint to start..." +test/wait-for-start.sh +green "==> midPoint started" +echo +yellow "*** Checking health via HTTP..." +(set -o pipefail ; curl -k -f https://localhost:8443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"") +green "==> Health is OK" diff --git a/midpoint/test/wait-for-start.sh b/midpoint/test/wait-for-start.sh new file mode 100755 index 0000000..ddb7a92 --- /dev/null +++ b/midpoint/test/wait-for-start.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +ATTEMPT=0 +MAX_ATTEMPTS=20 +DELAY=10 + +until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do + ATTEMPT=$((ATTEMPT+1)) + echo "Waiting $DELAY seconds for midPoint to start (attempt $ATTEMPT) ..." + sleep $DELAY + docker ps + ( docker logs midpoint_midpoint-server_1 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && exit 0 +done + +echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds +exit 1 diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..3c34e42 --- /dev/null +++ b/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +. test/common.sh + +trap 'exitcode=$? ; red "Exiting test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR +echo "**************************************************************************************" +echo "*** Testing midPoint image ***" +echo "**************************************************************************************" +echo +midpoint/test.sh diff --git a/test/common.sh b/test/common.sh new file mode 100755 index 0000000..68c5327 --- /dev/null +++ b/test/common.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +RED='\033[1;31m' +YELLOW='\033[1;33m' +GREEN='\033[1;32m' +NC='\033[0m' + +function red () { + echo -e ${RED}$*${NC} +} + +function yellow () { + echo -e ${YELLOW}$*${NC} +} + +function green () { + echo -e ${GREEN}$*${NC} +} From 95d4fababc519d4d0313c4c4e3dbaee42ce0bed7 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Sep 2018 18:19:49 +0200 Subject: [PATCH 07/73] Add a couple of tests Added - 110: get administrator - 120: add+get user - 200: stop+start containers (failing, but ignoring that) - 300: repository preservation (disabled) --- Jenkinsfile | 2 +- midpoint/test.sh | 46 +++++++++++---- ...it-for-start.sh => t010-wait-for-start.sh} | 0 midpoint/test/t100-check-health.sh | 3 + midpoint/test/t110-get-administrator.sh | 5 ++ midpoint/test/t120-add-get-user.sh | 28 +++++++++ midpoint/test/t200-stop-start.sh | 21 +++++++ midpoint/test/t300-repository-preservation.sh | 53 +++++++++++++++++ test.sh | 12 ++-- test/common.sh | 58 ++++++++++++++++--- 10 files changed, 205 insertions(+), 23 deletions(-) rename midpoint/test/{wait-for-start.sh => t010-wait-for-start.sh} (100%) create mode 100755 midpoint/test/t100-check-health.sh create mode 100755 midpoint/test/t110-get-administrator.sh create mode 100755 midpoint/test/t120-add-get-user.sh create mode 100755 midpoint/test/t200-stop-start.sh create mode 100755 midpoint/test/t300-repository-preservation.sh diff --git a/Jenkinsfile b/Jenkinsfile index d646d1a..9cb326b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,7 +50,7 @@ pipeline { sh 'midpoint/download-midpoint' docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server") - sh './test.sh' + sh 'env NOCOLOR=true ./test.sh' baseImg.push("$tag") } } diff --git a/midpoint/test.sh b/midpoint/test.sh index 96071d9..c1cf894 100755 --- a/midpoint/test.sh +++ b/midpoint/test.sh @@ -1,22 +1,46 @@ #!/bin/bash -trap 'exitcode=$? ; echo "Exiting midpoint/test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR +trap 'exitcode=$? ; error "Exiting midpoint/test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR cd "$(dirname "$0")" . ../test/common.sh -yellow "*** Composing midPoint..." +heading "Composing midPoint..." docker-compose up --no-start -green "==> midPoint composed OK" +ok "midPoint composed OK" echo -yellow "*** Starting midPoint..." + +heading "Starting midPoint..." docker-compose start -green "==> midPoint started OK" +ok "midPoint started OK" +echo + +heading "Test 010: Waiting for midPoint to start..." +test/t010-wait-for-start.sh +ok "midPoint started" echo -yellow "*** Waiting for midPoint to start..." -test/wait-for-start.sh -green "==> midPoint started" + +heading "Test 100: Checking health via HTTP..." +test/t100-check-health.sh +ok "Health check passed" +echo + +heading "Test 110: Getting user 'administrator'..." +test/t110-get-administrator.sh +ok "User 'administrator' retrieved and checked" echo -yellow "*** Checking health via HTTP..." -(set -o pipefail ; curl -k -f https://localhost:8443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"") -green "==> Health is OK" + +heading "Test 120: Adding and getting a user..." +test/t120-add-get-user.sh +ok "OK" +echo + +heading "Test 200: Stop/start cycle..." +test/t200-stop-start.sh +ok "OK" +echo + +#heading "Test 300: Checking repository preservation across compose down/up..." +#test/t300-repository-preservation.sh +#ok "OK" +#echo diff --git a/midpoint/test/wait-for-start.sh b/midpoint/test/t010-wait-for-start.sh similarity index 100% rename from midpoint/test/wait-for-start.sh rename to midpoint/test/t010-wait-for-start.sh diff --git a/midpoint/test/t100-check-health.sh b/midpoint/test/t100-check-health.sh new file mode 100755 index 0000000..c6e864c --- /dev/null +++ b/midpoint/test/t100-check-health.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +set -o pipefail ; curl -k -f https://localhost:8443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"" diff --git a/midpoint/test/t110-get-administrator.sh b/midpoint/test/t110-get-administrator.sh new file mode 100755 index 0000000..43b8af9 --- /dev/null +++ b/midpoint/test/t110-get-administrator.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/users/00000000-0000-0000-0000-000000000002" >/tmp/admin.xml +grep -q "administrator" + test120 + +EOF +echo "OK" + +echo "Searching for user 'test120'..." +curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users/search" -d @- << EOF >/tmp/test120.xml + + + + name + test120 + + + +EOF +echo "OK" + +grep -q "test120" &1 | grep "ERROR Shibboleth.Listener : failed socket call (bind), result (98): Address already in use") && yellow "=== Address already in use! ===" && docker-compose down && docker-compose up --no-start && docker-compose start + +echo +echo "Getting user 'administrator'..." +test/t110-get-administrator.sh diff --git a/midpoint/test/t300-repository-preservation.sh b/midpoint/test/t300-repository-preservation.sh new file mode 100755 index 0000000..92403d8 --- /dev/null +++ b/midpoint/test/t300-repository-preservation.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +USER=test300 +trap 'exitcode=$? ; error "Exiting because of an error ($exitcode) occurred" ; exit $exitcode' ERR +. ../test/common.sh + +echo "Adding user '${USER}'..." +curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users" -d @- << EOF + + ${USER} + +EOF +echo "OK" + +echo "Searching for user '${USER}'..." +curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users/search" -d @- << EOF >/tmp/${USER}.xml + + + + name + ${USER} + + + +EOF +echo "OK" + +grep -q "${USER}" /tmp/${USER}.xml + + + + name + ${USER} + + + +EOF +echo "OK" + +grep -q "${USER}" $*" +} + +function error () { + lred "$*" +} + From 2c7854a9e2ac2095e54f2d822a7b19b11a558857 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Sep 2018 19:21:39 +0200 Subject: [PATCH 08/73] Fix "database is destroyed on down/up cycle" However, it requires PR #7 from docker/mariadb repo to be accepted in order to function. --- midpoint/docker-compose.yml | 13 +++++-------- midpoint/midpoint-server/Dockerfile | 4 ++-- midpoint/test.sh | 14 +++++++------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/midpoint/docker-compose.yml b/midpoint/docker-compose.yml index 191414d..32d8ee1 100644 --- a/midpoint/docker-compose.yml +++ b/midpoint/docker-compose.yml @@ -1,10 +1,3 @@ -# -# Building: -# - docker-compose up --build -# -# It assumes that midpoint-3.9-SNAPSHOT-dist.tar.gz is present in the 'midpoint-server' directory. (TODO: eliminate this!) -# - version: "3.3" services: @@ -15,7 +8,10 @@ services: networks: - back volumes: - - midpoint_data:/var/lib/mysql + - midpoint_mysql:/var/lib/mysql + - midpoint_data:/var/lib/mysqlmounted + environment: + - CREATE_NEW_DATABASE=if_needed midpoint-server: build: ./midpoint-server/ @@ -77,5 +73,6 @@ secrets: file: ./configs-and-secrets/midpoint/application/keystore_password.txt volumes: + midpoint_mysql: midpoint_data: midpoint_home: diff --git a/midpoint/midpoint-server/Dockerfile b/midpoint/midpoint-server/Dockerfile index 4119876..27b026b 100644 --- a/midpoint/midpoint-server/Dockerfile +++ b/midpoint/midpoint-server/Dockerfile @@ -86,8 +86,8 @@ ENV LOGOUT_URL https://localhost:8443/Shibboleth.sso/Logout ENV KEYSTORE_PASSWORD_FILE /run/secrets/m_keystore_password.txt ENV MEM 2048m -ENV TIER_RELEASE=not-released-yet -ENV TIER_MAINTAINER=tier +ENV TIER_RELEASE not-released-yet +ENV TIER_MAINTAINER tier # TIER Beacon Opt-out # Completely uncomment the following ENV line to prevent the containers from sending analytics information to Internet2. diff --git a/midpoint/test.sh b/midpoint/test.sh index c1cf894..93533d3 100755 --- a/midpoint/test.sh +++ b/midpoint/test.sh @@ -35,12 +35,12 @@ test/t120-add-get-user.sh ok "OK" echo -heading "Test 200: Stop/start cycle..." -test/t200-stop-start.sh -ok "OK" -echo - -#heading "Test 300: Checking repository preservation across compose down/up..." -#test/t300-repository-preservation.sh +#heading "Test 200: Stop/start cycle..." +#test/t200-stop-start.sh #ok "OK" #echo + +heading "Test 300: Checking repository preservation across compose down/up..." +test/t300-repository-preservation.sh +ok "OK" +echo From 9162ece3463cd7bc9844e1ed97a4d28e607a726a Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 26 Sep 2018 20:07:43 +0200 Subject: [PATCH 09/73] Fix Jenkinsfile and tests 1) There's now a cleanup step before and after running the tests 2) Tests check their results more thoroughly 3) Until MariaDB is changed, a temporary solution for down-up issue is present --- Jenkinsfile | 6 +++++- cleanup.sh | 3 +++ midpoint/cleanup.sh | 6 ++++++ midpoint/docker-compose.yml | 4 ++-- midpoint/test.sh | 5 +++++ midpoint/test/t110-get-administrator.sh | 3 +++ midpoint/test/t120-add-get-user.sh | 2 +- midpoint/test/t200-stop-start.sh | 2 +- midpoint/test/t300-repository-preservation.sh | 2 +- 9 files changed, 27 insertions(+), 6 deletions(-) create mode 100755 cleanup.sh create mode 100755 midpoint/cleanup.sh diff --git a/Jenkinsfile b/Jenkinsfile index 9cb326b..66cc578 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,7 +50,11 @@ pipeline { sh 'midpoint/download-midpoint' docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server") - sh 'env NOCOLOR=true ./test.sh' + try { + sh 'env NOCOLOR=true ./test.sh' + } finally { + sh './cleanup.sh' + } baseImg.push("$tag") } } diff --git a/cleanup.sh b/cleanup.sh new file mode 100755 index 0000000..649bafd --- /dev/null +++ b/cleanup.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +midpoint/cleanup.sh diff --git a/midpoint/cleanup.sh b/midpoint/cleanup.sh new file mode 100755 index 0000000..b9fe089 --- /dev/null +++ b/midpoint/cleanup.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd "$(dirname "$0")" +echo "Cleaning up containers and images in `pwd`" + +docker-compose down -v diff --git a/midpoint/docker-compose.yml b/midpoint/docker-compose.yml index 32d8ee1..338a67f 100644 --- a/midpoint/docker-compose.yml +++ b/midpoint/docker-compose.yml @@ -10,8 +10,8 @@ services: volumes: - midpoint_mysql:/var/lib/mysql - midpoint_data:/var/lib/mysqlmounted - environment: - - CREATE_NEW_DATABASE=if_needed +# environment: +# - CREATE_NEW_DATABASE=if_needed midpoint-server: build: ./midpoint-server/ diff --git a/midpoint/test.sh b/midpoint/test.sh index 93533d3..2570c4b 100755 --- a/midpoint/test.sh +++ b/midpoint/test.sh @@ -5,6 +5,11 @@ trap 'exitcode=$? ; error "Exiting midpoint/test.sh because of an error ($exitco cd "$(dirname "$0")" . ../test/common.sh +heading "Cleaning up containers and volumes if they exist" +docker-compose down -v || true +ok "Done" +echo + heading "Composing midPoint..." docker-compose up --no-start ok "midPoint composed OK" diff --git a/midpoint/test/t110-get-administrator.sh b/midpoint/test/t110-get-administrator.sh index 43b8af9..55d5a4f 100755 --- a/midpoint/test/t110-get-administrator.sh +++ b/midpoint/test/t110-get-administrator.sh @@ -1,5 +1,8 @@ #!/bin/bash +trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR +. ../test/common.sh + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/users/00000000-0000-0000-0000-000000000002" >/tmp/admin.xml grep -q "administrator" Date: Wed, 26 Sep 2018 19:55:18 +0000 Subject: [PATCH 10/73] seting UTC timezone and fixed grouper version --- demo/complex/grouper-daemon/Dockerfile | 2 +- demo/complex/grouper-data/Dockerfile | 2 +- demo/complex/grouper-ui/Dockerfile | 2 +- demo/complex/grouper-ws/Dockerfile | 9 - .../grouper-ws/container_files/server.xml | 180 ------------------ .../container_files/tomcat-users.xml | 46 ----- .../grouper-ws/container_files/web.xml | 128 ------------- demo/complex/gsh/Dockerfile | 5 - midpoint/midpoint-server/Dockerfile | 3 + 9 files changed, 6 insertions(+), 371 deletions(-) delete mode 100644 demo/complex/grouper-ws/Dockerfile delete mode 100644 demo/complex/grouper-ws/container_files/server.xml delete mode 100644 demo/complex/grouper-ws/container_files/tomcat-users.xml delete mode 100644 demo/complex/grouper-ws/container_files/web.xml delete mode 100644 demo/complex/gsh/Dockerfile diff --git a/demo/complex/grouper-daemon/Dockerfile b/demo/complex/grouper-daemon/Dockerfile index f620350..55151f3 100644 --- a/demo/complex/grouper-daemon/Dockerfile +++ b/demo/complex/grouper-daemon/Dockerfile @@ -1,4 +1,4 @@ -FROM tier/grouper:latest +FROM tier/grouper:2.3.0-a109-u47-w12-p21 LABEL author="tier-packaging@internet2.edu " diff --git a/demo/complex/grouper-data/Dockerfile b/demo/complex/grouper-data/Dockerfile index 5ca6a12..dda3442 100644 --- a/demo/complex/grouper-data/Dockerfile +++ b/demo/complex/grouper-data/Dockerfile @@ -1,4 +1,4 @@ -FROM tier/grouper:latest +FROM tier/grouper:2.3.0-a109-u47-w12-p21 LABEL author="tier-packaging@internet2.edu " diff --git a/demo/complex/grouper-ui/Dockerfile b/demo/complex/grouper-ui/Dockerfile index 8fec2ae..bfec7b9 100644 --- a/demo/complex/grouper-ui/Dockerfile +++ b/demo/complex/grouper-ui/Dockerfile @@ -1,4 +1,4 @@ -FROM tier/grouper:latest +FROM tier/grouper:2.3.0-a109-u47-w12-p21 LABEL author="tier-packaging@internet2.edu " diff --git a/demo/complex/grouper-ws/Dockerfile b/demo/complex/grouper-ws/Dockerfile deleted file mode 100644 index f5c06b9..0000000 --- a/demo/complex/grouper-ws/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM tier/grouper:latest - -LABEL author="tier-packaging@internet2.edu " - -COPY container_files/web.xml /opt/grouper/grouper.ws/WEB-INF/ -COPY container_files/tomcat-users.xml /opt/tomcat/conf/ -COPY container_files/server.xml /opt/tomcat/conf/ - -CMD ["ws"] diff --git a/demo/complex/grouper-ws/container_files/server.xml b/demo/complex/grouper-ws/container_files/server.xml deleted file mode 100644 index 20edd02..0000000 --- a/demo/complex/grouper-ws/container_files/server.xml +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demo/complex/grouper-ws/container_files/tomcat-users.xml b/demo/complex/grouper-ws/container_files/tomcat-users.xml deleted file mode 100644 index f5d6945..0000000 --- a/demo/complex/grouper-ws/container_files/tomcat-users.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/demo/complex/grouper-ws/container_files/web.xml b/demo/complex/grouper-ws/container_files/web.xml deleted file mode 100644 index 03d3deb..0000000 --- a/demo/complex/grouper-ws/container_files/web.xml +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - Grouper service filter - edu.internet2.middleware.grouper.ws.GrouperServiceJ2ee - - - - - Grouper logging filter - edu.internet2.middleware.grouper.ws.j2ee.ServletFilterLogger - - - - - - Grouper service filter - /services/* - - - Grouper service filter - /servicesRest/* - - - AxisServlet - Apache-Axis Servlet - edu.internet2.middleware.grouper.ws.GrouperServiceAxisServlet - 1 - - - - - RestServlet - WS REST Servlet - edu.internet2.middleware.grouper.ws.rest.GrouperRestServlet - 1 - - - StatusServlet - Status Servlet - edu.internet2.middleware.grouper.j2ee.status.GrouperStatusServlet - 1 - - - StatusServlet - /status - - - AxisServlet - /services/* - - - RestServlet - /servicesRest/* - - - - - Web services - /services/* - - - * - - - - - - Web services - /servicesRest/* - - - - * - - - - - - BASIC - Grouper Application - - - - - - The role that is required to log in to web service - - * - - - - 1 - - - diff --git a/demo/complex/gsh/Dockerfile b/demo/complex/gsh/Dockerfile deleted file mode 100644 index 3302328..0000000 --- a/demo/complex/gsh/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM tier/grouper:latest - -MAINTAINER tier-packaging@internet2.edu - -CMD ["gsh"] diff --git a/midpoint/midpoint-server/Dockerfile b/midpoint/midpoint-server/Dockerfile index 27b026b..8bfb7e3 100644 --- a/midpoint/midpoint-server/Dockerfile +++ b/midpoint/midpoint-server/Dockerfile @@ -6,6 +6,9 @@ FROM tier/shibboleth_sp MAINTAINER info@evolveum.com +ENV TZ=UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone + RUN rpm --import http://repos.azulsystems.com/RPM-GPG-KEY-azulsystems RUN curl -o /etc/yum.repos.d/zulu.repo http://repos.azulsystems.com/rhel/zulu.repo RUN yum -y update From c335e2cdd7a45639a29137f15406f639835bfdd7 Mon Sep 17 00:00:00 2001 From: skublik Date: Thu, 27 Sep 2018 10:24:59 +0000 Subject: [PATCH 11/73] adding of urls without security to apache configuration --- .../httpd/conf/midpoint.conf.auth.shibboleth | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.shibboleth b/midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.shibboleth index e827b9f..faef9ae 100644 --- a/midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.shibboleth +++ b/midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.shibboleth @@ -5,7 +5,6 @@ ProxyBadHeader Ignore ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 - AuthType shibboleth ShibRequestSetting requireSession 1 @@ -13,3 +12,10 @@ ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 ShibUseHeaders On require shibboleth + + + Satisfy Any + Allow from all + AuthType None + Require all granted + From 5bf79230ca6c3f4afcc8d8cc575d45575f108058 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Sep 2018 12:59:45 +0200 Subject: [PATCH 12/73] Remove timezone setting from containers --- midpoint/midpoint-server/Dockerfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/midpoint/midpoint-server/Dockerfile b/midpoint/midpoint-server/Dockerfile index 8bfb7e3..27b026b 100644 --- a/midpoint/midpoint-server/Dockerfile +++ b/midpoint/midpoint-server/Dockerfile @@ -6,9 +6,6 @@ FROM tier/shibboleth_sp MAINTAINER info@evolveum.com -ENV TZ=UTC -RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone - RUN rpm --import http://repos.azulsystems.com/RPM-GPG-KEY-azulsystems RUN curl -o /etc/yum.repos.d/zulu.repo http://repos.azulsystems.com/rhel/zulu.repo RUN yum -y update From edf915485203765925dad3cd0d48b5f3ace26e67 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Sep 2018 16:36:19 +0200 Subject: [PATCH 13/73] Avoid re-creation of mP repository By setting CREATE_NEW_DATABASE to "if_needed" we avoid re-running of database initialization code in midpoint-data container on re-creation of that container. (Although almost harmless it could cause problems in some situations.) --- midpoint/docker-compose.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/midpoint/docker-compose.yml b/midpoint/docker-compose.yml index 338a67f..32d8ee1 100644 --- a/midpoint/docker-compose.yml +++ b/midpoint/docker-compose.yml @@ -10,8 +10,8 @@ services: volumes: - midpoint_mysql:/var/lib/mysql - midpoint_data:/var/lib/mysqlmounted -# environment: -# - CREATE_NEW_DATABASE=if_needed + environment: + - CREATE_NEW_DATABASE=if_needed midpoint-server: build: ./midpoint-server/ From f0d5c3a44102ea52a2a80c8d3dfc111d55672a81 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Sep 2018 17:16:51 +0200 Subject: [PATCH 14/73] Add a couple of Shibboleth composition tests --- Jenkinsfile | 1 + demo/shibboleth/test.sh | 33 +++++++++++++++++++++++++++++++++ test.sh | 1 + 3 files changed, 35 insertions(+) create mode 100755 demo/shibboleth/test.sh diff --git a/Jenkinsfile b/Jenkinsfile index 66cc578..d9e9865 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,6 +51,7 @@ pipeline { docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server") try { + sh 'docker pull tier/mariadb:mariadb10' // temporary sh 'env NOCOLOR=true ./test.sh' } finally { sh './cleanup.sh' diff --git a/demo/shibboleth/test.sh b/demo/shibboleth/test.sh new file mode 100755 index 0000000..c23693b --- /dev/null +++ b/demo/shibboleth/test.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR + +cd "$(dirname "$0")" +. ../../test/common.sh + +heading "Cleaning up containers and volumes if they exist" +docker-compose down -v || true +ok "Done" +echo + +heading "Composing and starting Shibboleth..." +docker-compose up --build -d +ok "OK" +echo + +# TODO wait for Shib to start + +heading "Composing and starting midPoint..." +pushd ../../midpoint +MPDIR=`pwd` +docker-compose down -v || true +env AUTHENTICATION=shibboleth docker-compose up --build -d +popd +$MPDIR/test/t010-wait-for-start.sh +ok "OK" +echo + +heading "Test 100: Checking health via HTTP..." +$MPDIR/test/t100-check-health.sh +ok "Health check passed" +echo diff --git a/test.sh b/test.sh index f42c8b9..65527cf 100755 --- a/test.sh +++ b/test.sh @@ -8,6 +8,7 @@ yellow "*** Testing midPoint image yellow "**************************************************************************************" echo midpoint/test.sh +demo/shibboleth/test.sh echo lgreen "**************************************************************************************" lgreen "*** All tests passed ***" From b5a8c329c7981bf7776f69932ef6b0ee6d0ace0e Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Sep 2018 17:35:27 +0200 Subject: [PATCH 15/73] Add some diagnostics for failing t300 --- midpoint/test/t300-repository-preservation.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/midpoint/test/t300-repository-preservation.sh b/midpoint/test/t300-repository-preservation.sh index 1fd3f72..4fa95da 100755 --- a/midpoint/test/t300-repository-preservation.sh +++ b/midpoint/test/t300-repository-preservation.sh @@ -4,6 +4,11 @@ USER=test300 trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR . ../test/common.sh +docker ps +echo Checking health before action +test/t100-check-health.sh +docker ps + echo "Adding user '${USER}'..." curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users" -d @- << EOF From ce27088da207104b396cbee87422145293941b90 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 27 Sep 2018 23:42:44 +0200 Subject: [PATCH 16/73] Introduce bats testing (only a dummy test for now) --- Jenkinsfile | 97 ++++++++++++++++++++++++++++------------ midpoint/tests/main.bats | 17 +++++++ 2 files changed, 85 insertions(+), 29 deletions(-) create mode 100755 midpoint/tests/main.bats diff --git a/Jenkinsfile b/Jenkinsfile index d9e9865..4a4986a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -11,7 +11,7 @@ pipeline { script { maintainer = maintain() imagename = imagename() - if(env.BRANCH_NAME == "master") { + if(env.BRANCH_NAME == "master" || env.BRANCH_NAME == "bats") { // temporary tag = "latest" } else { tag = env.BRANCH_NAME @@ -22,7 +22,7 @@ pipeline { } sh 'mkdir -p bin' sh 'mkdir -p tmp' - dir('tmp'){ + dir('tmp') { git([ url: "https://github.internet2.edu/docker/util.git", credentialsId: "jenkins-github-access-token" ]) sh 'ls' sh 'mv bin/* ../bin/.' @@ -30,38 +30,78 @@ pipeline { } } } - stage('Clean') { + stage ('Clean') { steps { script { - try{ - sh 'bin/destroy.sh >> debug' - } catch(error) { - def error_details = readFile('./debug'); - def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}" - sh "rm -f ./debug" - handleError(message) - } + try { + sh 'bin/destroy.sh >> debug' + } catch (error) { + def error_details = readFile('./debug'); + def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } } } } - stage('Build') { + stage ('Build') { steps { script { - sh 'midpoint/download-midpoint' - docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { - def baseImg = docker.build("$maintainer/$imagename", "--no-cache midpoint/midpoint-server") + try { + sh '(set -e ; cd midpoint ; ./download-midpoint ; ../bin/build.sh) &> debug' + } catch (error) { + def error_details = readFile('./debug') + def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } + } + } + } + stage ('Test') { + steps { + script { + try { + sh 'bats midpoint/tests &> debug' + } catch (error) { + def error_details = readFile('./debug') + def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } + } + } + } + stage ('Test2') { + steps { + script { + try { try { sh 'docker pull tier/mariadb:mariadb10' // temporary sh 'env NOCOLOR=true ./test.sh' } finally { sh './cleanup.sh' } - baseImg.push("$tag") - } - } + } catch (error) { + def error_details = readFile('./debug') + def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + sh "rm -f ./debug" + handleError(message) + } + } + } + } + stage ('Push') { + steps { + script { + docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { + def baseImg = docker.build("$maintainer/$imagename") + baseImg.push("$tag") + } + } } } - stage('Notify') { + stage ('Notify') { steps { echo "$maintainer" slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" @@ -81,19 +121,18 @@ pipeline { def maintain() { - def matcher = readFile('common.bash') =~ 'maintainer="(.+)"' - matcher ? matcher[0][1] : 'tier' + def matcher = readFile('common.bash') =~ 'maintainer="(.+)"' + matcher ? matcher[0][1] : 'tier' } def imagename() { - def matcher = readFile('common.bash') =~ 'imagename="(.+)"' - matcher ? matcher[0][1] : null + def matcher = readFile('common.bash') =~ 'imagename="(.+)"' + matcher ? matcher[0][1] : null } -def handleError(String message){ - echo "${message}" - currentBuild.setResult("FAILED") - slackSend color: 'danger', message: "${message}" - //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'chubing@internet2.edu', sendToIndividuals: true]) - sh 'exit 1' +def handleError(String message) { + echo "${message}" + currentBuild.setResult("FAILED") + slackSend color: 'danger', message: "${message}" + sh 'exit 1' } diff --git a/midpoint/tests/main.bats b/midpoint/tests/main.bats new file mode 100755 index 0000000..9ccb357 --- /dev/null +++ b/midpoint/tests/main.bats @@ -0,0 +1,17 @@ +#!/usr/bin/env bats + +load ../../common + +@test "Dummy test 1" { + [ "a" = "a" ] +} + +#@test "MariaDB service available" { +# docker run -i $maintainer/$imagename find /usr/lib/systemd/system/mariadb.service +#} +# +#@test "MariaDB first run consumes tmpfile" { +##2 result="$(docker run -i $maintainer/$imagename find /tmp/firsttimerunning)" +# [ "$result" != '' ] +#} + From 55fcd70f1d9c48cfa9e61bb996da5acd97bdd933 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 00:05:52 +0200 Subject: [PATCH 17/73] Adapt directory structure to docker/util The container is now built directly from the root directory. Even the simplest composition was moved to demo/plain. --- .../midpoint-server/Dockerfile => Dockerfile | 0 Jenkinsfile | 43 +++++++------------ .../httpd/conf/midpoint.conf.auth.internal | 0 .../httpd/conf/midpoint.conf.auth.shibboleth | 0 .../httpd/conf/ssl-enable.conf | 0 .../mp-dir/active-spring-profiles | 0 .../mp-dir/repository-url | 0 .../opt-tier/setenv.sh | 0 .../shibboleth/attribute-map.xml | 0 .../shibboleth/native.logger | 0 .../shibboleth/shibd.logger | 0 .../supervisor/supervisord.conf | 0 .../usr-local-bin/healthcheck.sh | 0 .../usr-local-bin/sendtierbeacon.sh | 0 .../usr-local-bin/setup-cron.sh | 0 .../usr-local-bin/start-httpd.sh | 0 .../usr-local-bin/start-midpoint.sh | 0 .../usr-local-bin/startup.sh | 0 {midpoint => demo/plain}/.env | 0 .../application/database_password.txt | 0 .../application/keystore_password.txt | 0 .../midpoint/httpd/host-cert.pem | 0 .../midpoint/httpd/host-key.pem | 0 .../midpoint/shibboleth/idp-metadata.xml | 0 .../midpoint/shibboleth/shibboleth2.xml | 0 .../midpoint/shibboleth/sp-cert.pem | 0 .../midpoint/shibboleth/sp-key.pem | 0 {midpoint => demo/plain}/docker-compose.yml | 2 +- .../download-midpoint => download-midpoint | 4 +- {midpoint => midpoint-obsolete}/README.md | 0 {midpoint => midpoint-obsolete}/build.sh | 0 {midpoint => midpoint-obsolete}/cleanup.sh | 0 {midpoint => midpoint-obsolete}/test.sh | 0 .../test/t010-wait-for-start.sh | 0 .../test/t100-check-health.sh | 0 .../test/t110-get-administrator.sh | 0 .../test/t120-add-get-user.sh | 0 .../test/t200-stop-start.sh | 0 .../test/t300-repository-preservation.sh | 0 {midpoint/tests => tests}/main.bats | 0 40 files changed, 19 insertions(+), 30 deletions(-) rename midpoint/midpoint-server/Dockerfile => Dockerfile (100%) rename {midpoint/midpoint-server/container_files => container_files}/httpd/conf/midpoint.conf.auth.internal (100%) rename {midpoint/midpoint-server/container_files => container_files}/httpd/conf/midpoint.conf.auth.shibboleth (100%) rename {midpoint/midpoint-server/container_files => container_files}/httpd/conf/ssl-enable.conf (100%) rename {midpoint/midpoint-server/container_files => container_files}/mp-dir/active-spring-profiles (100%) rename {midpoint/midpoint-server/container_files => container_files}/mp-dir/repository-url (100%) rename {midpoint/midpoint-server/container_files => container_files}/opt-tier/setenv.sh (100%) rename {midpoint/midpoint-server/container_files => container_files}/shibboleth/attribute-map.xml (100%) rename {midpoint/midpoint-server/container_files => container_files}/shibboleth/native.logger (100%) rename {midpoint/midpoint-server/container_files => container_files}/shibboleth/shibd.logger (100%) rename {midpoint/midpoint-server/container_files => container_files}/supervisor/supervisord.conf (100%) rename {midpoint/midpoint-server/container_files => container_files}/usr-local-bin/healthcheck.sh (100%) rename {midpoint/midpoint-server/container_files => container_files}/usr-local-bin/sendtierbeacon.sh (100%) rename {midpoint/midpoint-server/container_files => container_files}/usr-local-bin/setup-cron.sh (100%) rename {midpoint/midpoint-server/container_files => container_files}/usr-local-bin/start-httpd.sh (100%) rename {midpoint/midpoint-server/container_files => container_files}/usr-local-bin/start-midpoint.sh (100%) rename {midpoint/midpoint-server/container_files => container_files}/usr-local-bin/startup.sh (100%) rename {midpoint => demo/plain}/.env (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/application/database_password.txt (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/application/keystore_password.txt (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/httpd/host-cert.pem (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/httpd/host-key.pem (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/shibboleth/sp-cert.pem (100%) rename {midpoint => demo/plain}/configs-and-secrets/midpoint/shibboleth/sp-key.pem (100%) rename {midpoint => demo/plain}/docker-compose.yml (98%) rename midpoint/download-midpoint => download-midpoint (53%) rename {midpoint => midpoint-obsolete}/README.md (100%) rename {midpoint => midpoint-obsolete}/build.sh (100%) rename {midpoint => midpoint-obsolete}/cleanup.sh (100%) rename {midpoint => midpoint-obsolete}/test.sh (100%) rename {midpoint => midpoint-obsolete}/test/t010-wait-for-start.sh (100%) rename {midpoint => midpoint-obsolete}/test/t100-check-health.sh (100%) rename {midpoint => midpoint-obsolete}/test/t110-get-administrator.sh (100%) rename {midpoint => midpoint-obsolete}/test/t120-add-get-user.sh (100%) rename {midpoint => midpoint-obsolete}/test/t200-stop-start.sh (100%) rename {midpoint => midpoint-obsolete}/test/t300-repository-preservation.sh (100%) rename {midpoint/tests => tests}/main.bats (100%) diff --git a/midpoint/midpoint-server/Dockerfile b/Dockerfile similarity index 100% rename from midpoint/midpoint-server/Dockerfile rename to Dockerfile diff --git a/Jenkinsfile b/Jenkinsfile index 4a4986a..eb06066 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -6,49 +6,36 @@ pipeline { tag = 'l' } stages { - stage('Setting build context') { + stage ('Setting build context') { steps { script { maintainer = maintain() imagename = imagename() - if(env.BRANCH_NAME == "master" || env.BRANCH_NAME == "bats") { // temporary + if (env.BRANCH_NAME == "master" || env.BRANCH_NAME == "bats") { // temporary tag = "latest" } else { tag = env.BRANCH_NAME } - if(!imagename){ + if (!imagename) { echo "You must define imagename in common.bash" currentBuild.result = 'FAILURE' - } + } sh 'mkdir -p bin' sh 'mkdir -p tmp' - dir('tmp') { - git([ url: "https://github.internet2.edu/docker/util.git", credentialsId: "jenkins-github-access-token" ]) - sh 'ls' - sh 'mv bin/* ../bin/.' + dir ('tmp') { + git([ url: "https://github.internet2.edu/docker/util.git", credentialsId: "jenkins-github-access-token" ]) + sh 'ls' + sh 'mv bin/* ../bin/.' } } - } - } - stage ('Clean') { - steps { - script { - try { - sh 'bin/destroy.sh >> debug' - } catch (error) { - def error_details = readFile('./debug'); - def message = "BUILD ERROR: There was a problem building the Base Image. \n\n ${error_details}" - sh "rm -f ./debug" - handleError(message) - } - } } - } + } stage ('Build') { steps { script { try { - sh '(set -e ; cd midpoint ; ./download-midpoint ; ../bin/build.sh) &> debug' + sh './download-midpoint &> debug' + sh 'bin/rebuild.sh &>> debug' } catch (error) { def error_details = readFile('./debug') def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" @@ -62,16 +49,17 @@ pipeline { steps { script { try { - sh 'bats midpoint/tests &> debug' + sh 'bin/test.sh &> debug' } catch (error) { def error_details = readFile('./debug') - def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" + def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}" sh "rm -f ./debug" handleError(message) } } } } +/* stage ('Test2') { steps { script { @@ -91,10 +79,11 @@ pipeline { } } } +*/ stage ('Push') { steps { script { - docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { + docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { def baseImg = docker.build("$maintainer/$imagename") baseImg.push("$tag") } diff --git a/midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.internal b/container_files/httpd/conf/midpoint.conf.auth.internal similarity index 100% rename from midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.internal rename to container_files/httpd/conf/midpoint.conf.auth.internal diff --git a/midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.shibboleth b/container_files/httpd/conf/midpoint.conf.auth.shibboleth similarity index 100% rename from midpoint/midpoint-server/container_files/httpd/conf/midpoint.conf.auth.shibboleth rename to container_files/httpd/conf/midpoint.conf.auth.shibboleth diff --git a/midpoint/midpoint-server/container_files/httpd/conf/ssl-enable.conf b/container_files/httpd/conf/ssl-enable.conf similarity index 100% rename from midpoint/midpoint-server/container_files/httpd/conf/ssl-enable.conf rename to container_files/httpd/conf/ssl-enable.conf diff --git a/midpoint/midpoint-server/container_files/mp-dir/active-spring-profiles b/container_files/mp-dir/active-spring-profiles similarity index 100% rename from midpoint/midpoint-server/container_files/mp-dir/active-spring-profiles rename to container_files/mp-dir/active-spring-profiles diff --git a/midpoint/midpoint-server/container_files/mp-dir/repository-url b/container_files/mp-dir/repository-url similarity index 100% rename from midpoint/midpoint-server/container_files/mp-dir/repository-url rename to container_files/mp-dir/repository-url diff --git a/midpoint/midpoint-server/container_files/opt-tier/setenv.sh b/container_files/opt-tier/setenv.sh similarity index 100% rename from midpoint/midpoint-server/container_files/opt-tier/setenv.sh rename to container_files/opt-tier/setenv.sh diff --git a/midpoint/midpoint-server/container_files/shibboleth/attribute-map.xml b/container_files/shibboleth/attribute-map.xml similarity index 100% rename from midpoint/midpoint-server/container_files/shibboleth/attribute-map.xml rename to container_files/shibboleth/attribute-map.xml diff --git a/midpoint/midpoint-server/container_files/shibboleth/native.logger b/container_files/shibboleth/native.logger similarity index 100% rename from midpoint/midpoint-server/container_files/shibboleth/native.logger rename to container_files/shibboleth/native.logger diff --git a/midpoint/midpoint-server/container_files/shibboleth/shibd.logger b/container_files/shibboleth/shibd.logger similarity index 100% rename from midpoint/midpoint-server/container_files/shibboleth/shibd.logger rename to container_files/shibboleth/shibd.logger diff --git a/midpoint/midpoint-server/container_files/supervisor/supervisord.conf b/container_files/supervisor/supervisord.conf similarity index 100% rename from midpoint/midpoint-server/container_files/supervisor/supervisord.conf rename to container_files/supervisor/supervisord.conf diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh b/container_files/usr-local-bin/healthcheck.sh similarity index 100% rename from midpoint/midpoint-server/container_files/usr-local-bin/healthcheck.sh rename to container_files/usr-local-bin/healthcheck.sh diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/sendtierbeacon.sh b/container_files/usr-local-bin/sendtierbeacon.sh similarity index 100% rename from midpoint/midpoint-server/container_files/usr-local-bin/sendtierbeacon.sh rename to container_files/usr-local-bin/sendtierbeacon.sh diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/setup-cron.sh b/container_files/usr-local-bin/setup-cron.sh similarity index 100% rename from midpoint/midpoint-server/container_files/usr-local-bin/setup-cron.sh rename to container_files/usr-local-bin/setup-cron.sh diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/start-httpd.sh b/container_files/usr-local-bin/start-httpd.sh similarity index 100% rename from midpoint/midpoint-server/container_files/usr-local-bin/start-httpd.sh rename to container_files/usr-local-bin/start-httpd.sh diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/start-midpoint.sh b/container_files/usr-local-bin/start-midpoint.sh similarity index 100% rename from midpoint/midpoint-server/container_files/usr-local-bin/start-midpoint.sh rename to container_files/usr-local-bin/start-midpoint.sh diff --git a/midpoint/midpoint-server/container_files/usr-local-bin/startup.sh b/container_files/usr-local-bin/startup.sh similarity index 100% rename from midpoint/midpoint-server/container_files/usr-local-bin/startup.sh rename to container_files/usr-local-bin/startup.sh diff --git a/midpoint/.env b/demo/plain/.env similarity index 100% rename from midpoint/.env rename to demo/plain/.env diff --git a/midpoint/configs-and-secrets/midpoint/application/database_password.txt b/demo/plain/configs-and-secrets/midpoint/application/database_password.txt similarity index 100% rename from midpoint/configs-and-secrets/midpoint/application/database_password.txt rename to demo/plain/configs-and-secrets/midpoint/application/database_password.txt diff --git a/midpoint/configs-and-secrets/midpoint/application/keystore_password.txt b/demo/plain/configs-and-secrets/midpoint/application/keystore_password.txt similarity index 100% rename from midpoint/configs-and-secrets/midpoint/application/keystore_password.txt rename to demo/plain/configs-and-secrets/midpoint/application/keystore_password.txt diff --git a/midpoint/configs-and-secrets/midpoint/httpd/host-cert.pem b/demo/plain/configs-and-secrets/midpoint/httpd/host-cert.pem similarity index 100% rename from midpoint/configs-and-secrets/midpoint/httpd/host-cert.pem rename to demo/plain/configs-and-secrets/midpoint/httpd/host-cert.pem diff --git a/midpoint/configs-and-secrets/midpoint/httpd/host-key.pem b/demo/plain/configs-and-secrets/midpoint/httpd/host-key.pem similarity index 100% rename from midpoint/configs-and-secrets/midpoint/httpd/host-key.pem rename to demo/plain/configs-and-secrets/midpoint/httpd/host-key.pem diff --git a/midpoint/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml b/demo/plain/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml similarity index 100% rename from midpoint/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml rename to demo/plain/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml diff --git a/midpoint/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml b/demo/plain/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml similarity index 100% rename from midpoint/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml rename to demo/plain/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml diff --git a/midpoint/configs-and-secrets/midpoint/shibboleth/sp-cert.pem b/demo/plain/configs-and-secrets/midpoint/shibboleth/sp-cert.pem similarity index 100% rename from midpoint/configs-and-secrets/midpoint/shibboleth/sp-cert.pem rename to demo/plain/configs-and-secrets/midpoint/shibboleth/sp-cert.pem diff --git a/midpoint/configs-and-secrets/midpoint/shibboleth/sp-key.pem b/demo/plain/configs-and-secrets/midpoint/shibboleth/sp-key.pem similarity index 100% rename from midpoint/configs-and-secrets/midpoint/shibboleth/sp-key.pem rename to demo/plain/configs-and-secrets/midpoint/shibboleth/sp-key.pem diff --git a/midpoint/docker-compose.yml b/demo/plain/docker-compose.yml similarity index 98% rename from midpoint/docker-compose.yml rename to demo/plain/docker-compose.yml index 32d8ee1..0c850bd 100644 --- a/midpoint/docker-compose.yml +++ b/demo/plain/docker-compose.yml @@ -14,7 +14,7 @@ services: - CREATE_NEW_DATABASE=if_needed midpoint-server: - build: ./midpoint-server/ + image: tier/midpoint:latest ports: - 8443:443 environment: diff --git a/midpoint/download-midpoint b/download-midpoint similarity index 53% rename from midpoint/download-midpoint rename to download-midpoint index 50a2b2a..a6cf1a0 100755 --- a/midpoint/download-midpoint +++ b/download-midpoint @@ -3,10 +3,10 @@ dir=`dirname "$0"` echo "Downloading midPoint 3.9-SNAPSHOT" echo "-----------------------------------------" -curl --output $dir/midpoint-server/midpoint-3.9-SNAPSHOT-dist.tar.gz "https://evolveum.com/downloads/midpoint-tier/midpoint-3.9-SNAPSHOT-dist.tar.gz" +curl --output $dir/midpoint-3.9-SNAPSHOT-dist.tar.gz "https://evolveum.com/downloads/midpoint-tier/midpoint-3.9-SNAPSHOT-dist.tar.gz" echo "-----------------------------------------" echo "Checking the download..." -if tar -tf $dir/midpoint-server/midpoint-3.9-SNAPSHOT-dist.tar.gz >/dev/null; then +if tar -tf $dir/midpoint-3.9-SNAPSHOT-dist.tar.gz >/dev/null; then echo "OK" else echo "The file was not downloaded correctly" diff --git a/midpoint/README.md b/midpoint-obsolete/README.md similarity index 100% rename from midpoint/README.md rename to midpoint-obsolete/README.md diff --git a/midpoint/build.sh b/midpoint-obsolete/build.sh similarity index 100% rename from midpoint/build.sh rename to midpoint-obsolete/build.sh diff --git a/midpoint/cleanup.sh b/midpoint-obsolete/cleanup.sh similarity index 100% rename from midpoint/cleanup.sh rename to midpoint-obsolete/cleanup.sh diff --git a/midpoint/test.sh b/midpoint-obsolete/test.sh similarity index 100% rename from midpoint/test.sh rename to midpoint-obsolete/test.sh diff --git a/midpoint/test/t010-wait-for-start.sh b/midpoint-obsolete/test/t010-wait-for-start.sh similarity index 100% rename from midpoint/test/t010-wait-for-start.sh rename to midpoint-obsolete/test/t010-wait-for-start.sh diff --git a/midpoint/test/t100-check-health.sh b/midpoint-obsolete/test/t100-check-health.sh similarity index 100% rename from midpoint/test/t100-check-health.sh rename to midpoint-obsolete/test/t100-check-health.sh diff --git a/midpoint/test/t110-get-administrator.sh b/midpoint-obsolete/test/t110-get-administrator.sh similarity index 100% rename from midpoint/test/t110-get-administrator.sh rename to midpoint-obsolete/test/t110-get-administrator.sh diff --git a/midpoint/test/t120-add-get-user.sh b/midpoint-obsolete/test/t120-add-get-user.sh similarity index 100% rename from midpoint/test/t120-add-get-user.sh rename to midpoint-obsolete/test/t120-add-get-user.sh diff --git a/midpoint/test/t200-stop-start.sh b/midpoint-obsolete/test/t200-stop-start.sh similarity index 100% rename from midpoint/test/t200-stop-start.sh rename to midpoint-obsolete/test/t200-stop-start.sh diff --git a/midpoint/test/t300-repository-preservation.sh b/midpoint-obsolete/test/t300-repository-preservation.sh similarity index 100% rename from midpoint/test/t300-repository-preservation.sh rename to midpoint-obsolete/test/t300-repository-preservation.sh diff --git a/midpoint/tests/main.bats b/tests/main.bats similarity index 100% rename from midpoint/tests/main.bats rename to tests/main.bats From ee9c5acae900dad670248094fad6f64dec9f2f2c Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 00:09:09 +0200 Subject: [PATCH 18/73] Fix path in main.bats --- tests/main.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/main.bats b/tests/main.bats index 9ccb357..9b19d4e 100755 --- a/tests/main.bats +++ b/tests/main.bats @@ -1,6 +1,6 @@ #!/usr/bin/env bats -load ../../common +load ../common @test "Dummy test 1" { [ "a" = "a" ] From 882c8c9beed5c1dd805178d69b96eb222f1c85bb Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 00:19:42 +0200 Subject: [PATCH 19/73] Do a minor cleanup 1. demo/plain -> demo/simple 2. updated README.MD --- Jenkinsfile | 1 + README.md | 10 +++++-- build.sh | 30 +++++++++++++++++++ cleanup.sh | 3 -- demo/{plain => simple}/.env | 0 .../application/database_password.txt | 0 .../application/keystore_password.txt | 0 .../midpoint/httpd/host-cert.pem | 0 .../midpoint/httpd/host-key.pem | 0 .../midpoint/shibboleth/idp-metadata.xml | 0 .../midpoint/shibboleth/shibboleth2.xml | 0 .../midpoint/shibboleth/sp-cert.pem | 0 .../midpoint/shibboleth/sp-key.pem | 0 demo/{plain => simple}/docker-compose.yml | 0 test.sh => midpoint-obsolete/test-root.sh | 0 {test => midpoint-obsolete/test}/common.sh | 0 16 files changed, 38 insertions(+), 6 deletions(-) create mode 100755 build.sh delete mode 100755 cleanup.sh rename demo/{plain => simple}/.env (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/application/database_password.txt (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/application/keystore_password.txt (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/httpd/host-cert.pem (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/httpd/host-key.pem (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/shibboleth/sp-cert.pem (100%) rename demo/{plain => simple}/configs-and-secrets/midpoint/shibboleth/sp-key.pem (100%) rename demo/{plain => simple}/docker-compose.yml (100%) rename test.sh => midpoint-obsolete/test-root.sh (100%) rename {test => midpoint-obsolete/test}/common.sh (100%) diff --git a/Jenkinsfile b/Jenkinsfile index eb06066..801552a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,6 +50,7 @@ pipeline { script { try { sh 'bin/test.sh &> debug' + sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}" diff --git a/README.md b/README.md index e3bd121..a1813e9 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,18 @@ The image contains the midPoint application along with some TIER-specific compon - midPoint version-specific tags, e.g. 3.9, 3.9.1, 4.0, etc. # Content -- `midpoint` directory contains build instructions for the `midpoint` image along with `docker-compose.yml` showing its basic use, -- `demo` directory contains three demonstration scenarios: +- the root directory contains build instructions for the `midpoint` image +- `demo` directory contains a couple of demonstration scenarios: + - `simple` to show simple composition of midPoint with the repository, - `shibboleth` to show integration with Shibboleth IdP, - `postgresql` to show how to change the repository implementation, - `complex` to demonstrate more complex deployment of midPoint in a sample university environment, featuring midPoint along with Grouper, LDAP directory, RabbitMQ, Shibboleth IdP, source and target systems. # Build instructions -Please see specific subdirectories: [midpoint](midpoint) and [demo/complex](demo/complex). +``` +$ ./build.sh +``` +You can then continue with one of demo composition, e.g. simple or complex one. # Documentation - For the `midpoint` image and container themselves please see [Dockerized midPoint](https://spaces.at.internet2.edu/display/MID/Dockerized+midPoint) wiki page. diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..37397bc --- /dev/null +++ b/build.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +function normalize_path() +{ + # Remove all /./ sequences. + local path=${1//\/.\//\/} + + # Remove dir/.. sequences. + while [[ $path =~ ([^/][^/]*/\.\./) ]] + do + path=${path/${BASH_REMATCH[0]}/} + done + echo $path +} + +cd "$(dirname "$0")" +./download-midpoint +docker build --tag tier/midpoint:latest midpoint-server +echo "---------------------------------------------------------------------------------------" +echo "The midPoint containers were successfully built. To start them, execute the following:" +echo "" +echo "(for simple demo)" +echo "" +echo "$ cd" $(normalize_path `pwd`/../demo/simple) +echo "$ docker-compose up --build" +echo "" +echo "(for complex demo)" +echo "" +echo "$ cd" $(normalize_path `pwd`/../demo/complex) +echo "$ docker-compose up --build" diff --git a/cleanup.sh b/cleanup.sh deleted file mode 100755 index 649bafd..0000000 --- a/cleanup.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -midpoint/cleanup.sh diff --git a/demo/plain/.env b/demo/simple/.env similarity index 100% rename from demo/plain/.env rename to demo/simple/.env diff --git a/demo/plain/configs-and-secrets/midpoint/application/database_password.txt b/demo/simple/configs-and-secrets/midpoint/application/database_password.txt similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/application/database_password.txt rename to demo/simple/configs-and-secrets/midpoint/application/database_password.txt diff --git a/demo/plain/configs-and-secrets/midpoint/application/keystore_password.txt b/demo/simple/configs-and-secrets/midpoint/application/keystore_password.txt similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/application/keystore_password.txt rename to demo/simple/configs-and-secrets/midpoint/application/keystore_password.txt diff --git a/demo/plain/configs-and-secrets/midpoint/httpd/host-cert.pem b/demo/simple/configs-and-secrets/midpoint/httpd/host-cert.pem similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/httpd/host-cert.pem rename to demo/simple/configs-and-secrets/midpoint/httpd/host-cert.pem diff --git a/demo/plain/configs-and-secrets/midpoint/httpd/host-key.pem b/demo/simple/configs-and-secrets/midpoint/httpd/host-key.pem similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/httpd/host-key.pem rename to demo/simple/configs-and-secrets/midpoint/httpd/host-key.pem diff --git a/demo/plain/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml b/demo/simple/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml rename to demo/simple/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml diff --git a/demo/plain/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml b/demo/simple/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml rename to demo/simple/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml diff --git a/demo/plain/configs-and-secrets/midpoint/shibboleth/sp-cert.pem b/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-cert.pem similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/shibboleth/sp-cert.pem rename to demo/simple/configs-and-secrets/midpoint/shibboleth/sp-cert.pem diff --git a/demo/plain/configs-and-secrets/midpoint/shibboleth/sp-key.pem b/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-key.pem similarity index 100% rename from demo/plain/configs-and-secrets/midpoint/shibboleth/sp-key.pem rename to demo/simple/configs-and-secrets/midpoint/shibboleth/sp-key.pem diff --git a/demo/plain/docker-compose.yml b/demo/simple/docker-compose.yml similarity index 100% rename from demo/plain/docker-compose.yml rename to demo/simple/docker-compose.yml diff --git a/test.sh b/midpoint-obsolete/test-root.sh similarity index 100% rename from test.sh rename to midpoint-obsolete/test-root.sh diff --git a/test/common.sh b/midpoint-obsolete/test/common.sh similarity index 100% rename from test/common.sh rename to midpoint-obsolete/test/common.sh From 86b58f91285381fa3f4ed68ba4d413964b285247 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 00:35:33 +0200 Subject: [PATCH 20/73] Add some very basic tests --- tests/main.bats | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/main.bats b/tests/main.bats index 9b19d4e..0856ec5 100755 --- a/tests/main.bats +++ b/tests/main.bats @@ -2,16 +2,18 @@ load ../common -@test "Dummy test 1" { - [ "a" = "a" ] +@test "010 Image is present" { + docker image inspect tier/midpoint:latest } -#@test "MariaDB service available" { -# docker run -i $maintainer/$imagename find /usr/lib/systemd/system/mariadb.service -#} -# -#@test "MariaDB first run consumes tmpfile" { -##2 result="$(docker run -i $maintainer/$imagename find /tmp/firsttimerunning)" -# [ "$result" != '' ] -#} +@test "020 Check basic components" { + docker run -i $maintainer/$imagename \ + find \ + /usr/local/bin/startup.sh \ + /opt/midpoint/var/ \ + /etc/shibboleth/ \ + /etc/httpd/ +} +# not much more to check here, as we cannot start midpoint container without having a repository +# so continuing with tests in demo/plain directory From 87f255c5a123013c6539c2b923df0b8b204c6caf Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 01:17:58 +0200 Subject: [PATCH 21/73] Add first real demo/simple test --- Jenkinsfile | 2 ++ demo/simple/tests/main.bats | 14 ++++++++++++++ library.bash | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 demo/simple/tests/main.bats create mode 100644 library.bash diff --git a/Jenkinsfile b/Jenkinsfile index 801552a..f39c25c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -36,6 +36,7 @@ pipeline { try { sh './download-midpoint &> debug' sh 'bin/rebuild.sh &>> debug' + sh 'echo Build output ; cat debug' } catch (error) { def error_details = readFile('./debug') def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" @@ -50,6 +51,7 @@ pipeline { script { try { sh 'bin/test.sh &> debug' + sh '(cd demo/simple ; bats tests ) &>> debug' sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats new file mode 100755 index 0000000..eec4945 --- /dev/null +++ b/demo/simple/tests/main.bats @@ -0,0 +1,14 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../../library + +@test "000 Initialize and start midPoint" { + run docker-compose down -v + docker-compose up -d + wait_for_midpoint_start simple_midpoint-server_1 +} + +@test "999 Clean up" { + docker-compose down -v +} diff --git a/library.bash b/library.bash new file mode 100644 index 0000000..1cfbdaf --- /dev/null +++ b/library.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +function wait_for_midpoint_start () { + ATTEMPT=0 + MAX_ATTEMPTS=20 + DELAY=10 + + until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do + ATTEMPT=$((ATTEMPT+1)) + echo "Waiting $DELAY seconds for midPoint to start (attempt $ATTEMPT) ..." + sleep $DELAY + docker ps + ( docker logs $1 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && return 0 + done + + echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds + return 1 +} From 8b9b0ede8b1c60d8b87f05941b8294c8190ba7fc Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 10:17:49 +0200 Subject: [PATCH 22/73] Add more Bats tests Also with other minor enhancements. --- .dockerignore | 3 ++ Jenkinsfile | 34 +++--------- build.sh | 12 ++++- demo/simple/.env | 5 +- demo/simple/docker-compose.yml | 4 -- demo/simple/tests/main.bats | 38 +++++++++++++ library.bash | 97 +++++++++++++++++++++++++++++++++- 7 files changed, 154 insertions(+), 39 deletions(-) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3cf5f0e --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +demo +.git +tests diff --git a/Jenkinsfile b/Jenkinsfile index f39c25c..9d177f9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,9 +34,10 @@ pipeline { steps { script { try { - sh './download-midpoint &> debug' - sh 'bin/rebuild.sh &>> debug' - sh 'echo Build output ; cat debug' + sh '(docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary + sh './download-midpoint 2>&1 | tee -a debug' + sh 'bin/rebuild.sh 2>&1 | tee -a debug' + //sh 'echo Build output ; cat debug' } catch (error) { def error_details = readFile('./debug') def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" @@ -50,9 +51,9 @@ pipeline { steps { script { try { - sh 'bin/test.sh &> debug' - sh '(cd demo/simple ; bats tests ) &>> debug' - sh 'echo Test output ; cat debug' + sh 'bin/test.sh 2>&1 | tee debug' + sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug' + // sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') def message = "BUILD ERROR: There was a problem testing ${imagename}:${tag}. \n\n ${error_details}" @@ -62,27 +63,6 @@ pipeline { } } } -/* - stage ('Test2') { - steps { - script { - try { - try { - sh 'docker pull tier/mariadb:mariadb10' // temporary - sh 'env NOCOLOR=true ./test.sh' - } finally { - sh './cleanup.sh' - } - } catch (error) { - def error_details = readFile('./debug') - def message = "BUILD ERROR: There was a problem building ${imagename}:${tag}. \n\n ${error_details}" - sh "rm -f ./debug" - handleError(message) - } - } - } - } -*/ stage ('Push') { steps { script { diff --git a/build.sh b/build.sh index 37397bc..b59e4ed 100755 --- a/build.sh +++ b/build.sh @@ -14,8 +14,16 @@ function normalize_path() } cd "$(dirname "$0")" -./download-midpoint -docker build --tag tier/midpoint:latest midpoint-server +SKIP_DOWNLOAD=0 +while getopts "nh?" opt; do + case $opt in + n) SKIP_DOWNLOAD=1 ;; + h | ?) echo "Options: -n skip download" ; exit 0 ;; + *) echo "Unknown option: $opt" ; exit 1 ;; + esac +done +if [ "$SKIP_DOWNLOAD" = "0" ]; then ./download-midpoint; fi +docker build --tag tier/midpoint:latest . echo "---------------------------------------------------------------------------------------" echo "The midPoint containers were successfully built. To start them, execute the following:" echo "" diff --git a/demo/simple/.env b/demo/simple/.env index ce20478..2c8a3e3 100644 --- a/demo/simple/.env +++ b/demo/simple/.env @@ -1,3 +1,4 @@ +# These parameters can be overridden by setting environment variables before calling docker-compose up AUTHENTICATION=internal ENV=demo USERTOKEN= @@ -7,8 +8,4 @@ REPO_HOST=midpoint-data REPO_PORT=default REPO_DATABASE=registry REPO_USER=registry_user -REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt -KEYSTORE_PASSWORD_FILE=/run/secrets/m_keystore_password.txt MEM=2048m -LOGOUT_URL=https://localhost:8443/Shibboleth.sso/Logout -SSO_HEADER=uid diff --git a/demo/simple/docker-compose.yml b/demo/simple/docker-compose.yml index 0c850bd..924f2e2 100644 --- a/demo/simple/docker-compose.yml +++ b/demo/simple/docker-compose.yml @@ -27,11 +27,7 @@ services: - REPO_PORT - REPO_DATABASE - REPO_USER - - REPO_PASSWORD_FILE - - KEYSTORE_PASSWORD_FILE - MEM - - SSO_HEADER - - LOGOUT_URL - TIER_BEACON_OPT_OUT networks: - back diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats index eec4945..530c53e 100755 --- a/demo/simple/tests/main.bats +++ b/demo/simple/tests/main.bats @@ -9,6 +9,44 @@ load ../../../library wait_for_midpoint_start simple_midpoint-server_1 } +@test "010 Check health" { + check_health +} + +@test "100 Get 'administrator'" { + check_health + get_and_check_object users 00000000-0000-0000-0000-000000000002 administrator +} + +@test "110 And and get 'test110'" { + check_health + echo "test110" >/tmp/test110.xml + add_object users /tmp/test110.xml + rm /tmp/test110.xml + search_and_check_object users test110 +} + +@test "300 Check repository preserved between restarts" { + check_health + + echo "Creating user test300 and checking its existence" + echo "test300" >/tmp/test300.xml + add_object users /tmp/test300.xml + rm /tmp/test300.xml + search_and_check_object users test300 + + echo "Bringing the containers down" + docker-compose down + + echo "Re-creating the containers" + docker-compose up --no-start + docker-compose start + wait_for_midpoint_start simple_midpoint-server_1 + + echo "Searching for the user again" + search_and_check_object users test300 +} + @test "999 Clean up" { docker-compose down -v } diff --git a/library.bash b/library.bash index 1cfbdaf..e605ab5 100644 --- a/library.bash +++ b/library.bash @@ -1,6 +1,12 @@ #!/bin/bash +# +# Contains common functions usable for midPoint system tests +# + +# Waits until midPoint starts function wait_for_midpoint_start () { + CONTAINER_NAME=$1 ATTEMPT=0 MAX_ATTEMPTS=20 DELAY=10 @@ -10,9 +16,96 @@ function wait_for_midpoint_start () { echo "Waiting $DELAY seconds for midPoint to start (attempt $ATTEMPT) ..." sleep $DELAY docker ps - ( docker logs $1 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && return 0 + ( docker logs $CONTAINER_NAME 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && return 0 done - echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds + echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME return 1 } + +# Checks the health of midPoint server +function check_health () { + echo Checking health... + (set -o pipefail ; curl -k -f https://localhost:8443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"") + status=$? + if [ $status -ne 0 ]; then + echo Error: $status + docker ps + return 1 + else + echo OK + return 0 + fi +} + +# Retrieves XML object and checks if the name matches +function get_and_check_object () { + TYPE=$1 + OID=$2 + NAME=$3 + TMPFILE=$(mktemp /tmp/get.XXXXXX) + echo tmp file is $TMPFILE + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$TMPFILE || (rm $TMPFILE ; return 1) + if (grep -q "$NAME" <$TMPFILE); then + echo "Object $TYPE/$OID '$NAME' is OK" + rm $TMPFILE + return 0 + else + echo "Object $TYPE/$OID '$NAME' was not found or not retrieved correctly:" + cat $TMPFILE + rm $TMPFILE + return 1 + fi +} + +# Adds object from a given file +# TODO Returns the OID in OID variable +# it can be found in the following HTTP reader returned: Location: "https://localhost:8443/midpoint/ws/rest/users/85e62669-d36b-41ce-b4f1-1ffdd9f66262" +function add_object () { + TYPE=$1 + FILE=$2 + echo "Adding to $TYPE from $FILE..." + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE || return 1 + #TODO check the returned XML + return 0 +} + +# Tries to find an object with a given name +# Results of the search are in the $SEARCH_RESULT_FILE +# TODO check if the result is valid (i.e. not an error) - return 1 if invalid, otherwise return 0 ("no objects" is considered OK here) +function search_objects_by_name () { + TYPE=$1 + NAME=$2 + TMPFILE=$(mktemp /tmp/search.XXXXXX) + + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE/search" -d @- << EOF >$TMPFILE || (rm $TMPFILE ; return 1) + + + + name + $NAME + + + +EOF + SEARCH_RESULT_FILE=$TMPFILE + # TODO check validity of the file + return 0 +} + +# Searches for object with a given name and verifies it was found +function search_and_check_object () { + TYPE=$1 + NAME=$2 + search_objects_by_name $TYPE $NAME || return 1 + if (grep -q "$NAME" <$SEARCH_RESULT_FILE); then + echo "Object $TYPE/'$NAME' is OK" + rm $SEARCH_RESULT_FILE + return 0 + else + echo "Object $TYPE/'$NAME' was not found or not retrieved correctly:" + cat $SEARCH_RESULT_FILE + rm $SEARCH_RESULT_FILE + return 1 + fi +} From 33aaa5413589e31290f180f2a7729302507dffa6 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 10:33:49 +0200 Subject: [PATCH 23/73] Refactor postgresql demo directories (in progress) --- demo/postgresql-full/.env | 5 + .../application/database_password.txt | 1 + .../application/keystore_password.txt | 1 + .../midpoint/httpd/host-cert.pem | 22 ++ .../midpoint/httpd/host-key.pem | 28 +++ .../midpoint/shibboleth/idp-metadata.xml | 207 ++++++++++++++++++ .../midpoint/shibboleth/shibboleth2.xml | 136 ++++++++++++ .../midpoint/shibboleth/sp-cert.pem | 22 ++ .../midpoint/shibboleth/sp-key.pem | 28 +++ demo/postgresql-full/docker-compose.yml | 70 ++++++ .../postgresql-to-be-removed}/Dockerfile | 0 .../container_files/init-user-db.sh | 0 .../docker-compose.yml | 0 .../midpoint-additions-for-standalone-run.yml | 0 .../midpoint-additions.yml | 0 .../postgresql/Dockerfile | 3 + .../container_files/init-user-db.sh | 12 + 17 files changed, 535 insertions(+) create mode 100644 demo/postgresql-full/.env create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/application/database_password.txt create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/application/keystore_password.txt create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-cert.pem create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-key.pem create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem create mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem create mode 100644 demo/postgresql-full/docker-compose.yml rename demo/{postgresql/postgresql => postgresql-full/postgresql-to-be-removed}/Dockerfile (100%) rename demo/{postgresql/postgresql => postgresql-full/postgresql-to-be-removed}/container_files/init-user-db.sh (100%) rename demo/{postgresql => postgresql-increment}/docker-compose.yml (100%) rename demo/{postgresql => postgresql-increment}/midpoint-additions-for-standalone-run.yml (100%) rename demo/{postgresql => postgresql-increment}/midpoint-additions.yml (100%) create mode 100644 demo/postgresql-increment/postgresql/Dockerfile create mode 100755 demo/postgresql-increment/postgresql/container_files/init-user-db.sh diff --git a/demo/postgresql-full/.env b/demo/postgresql-full/.env new file mode 100644 index 0000000..0ab53eb --- /dev/null +++ b/demo/postgresql-full/.env @@ -0,0 +1,5 @@ +# These parameters can be overridden by setting environment variables before calling docker-compose up +AUTHENTICATION=internal +ENV=demo +USERTOKEN= +MEM=2048m diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/application/database_password.txt b/demo/postgresql-full/configs-and-secrets/midpoint/application/database_password.txt new file mode 100644 index 0000000..11bff19 --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/application/database_password.txt @@ -0,0 +1 @@ +WJzesbe3poNZ91qIbmR7 diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/application/keystore_password.txt b/demo/postgresql-full/configs-and-secrets/midpoint/application/keystore_password.txt new file mode 100644 index 0000000..1d40192 --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/application/keystore_password.txt @@ -0,0 +1 @@ +changeit diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-cert.pem b/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-cert.pem new file mode 100644 index 0000000..9b1021b --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAMOSkn4oS2aAMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJNSTESMBAGA1UEBwwJQW5uIEFyYm9yMRcwFQYDVQQK +DA5JbnRlcm5ldDIvVElFUjEgMB4GA1UEAwwXbWlkcG9pbnQuc3AuZXhhbXBsZS5v +cmcwHhcNMTgwOTE0MDU1OTQ1WhcNMTkwOTE0MDU1OTQ1WjBpMQswCQYDVQQGEwJV +UzELMAkGA1UECAwCTUkxEjAQBgNVBAcMCUFubiBBcmJvcjEXMBUGA1UECgwOSW50 +ZXJuZXQyL1RJRVIxIDAeBgNVBAMMF21pZHBvaW50LnNwLmV4YW1wbGUub3JnMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApj/b7MEUSfu3oXMfNgRwTse7 +a5UV7Jswf1M/ZN/ZZkAkIxNBevZgozjesvLPWrmsTgONi7XigJUJvCjdjmlW9eDM +lri/rkD8HuOR1DQCVKL9nvoS2c3D7sq5Emda3V8Tlj82VqfEmePd3sajx7mcTfbH +8jwAL9NhkC+WMib5IpjLGpG0FEAC0ha7Lxb+7jIiqHVJaqLXJGCyGN4mh6c1Q9S1 +f8RVTiW2a8x22G+9wnZYbkiA2Kxls177imHlhSz8EdvV4IpGw1amrEWhhuDEum7B +vZ1xQDLatgRqh4qAKLIVYeRnJ8H1FelMa90qB4G08MIPifmTsQwqJyBYaEdgWQID +AQABo1MwUTAdBgNVHQ4EFgQUqb9BteODF6wv5R57aEON/wGXMiowHwYDVR0jBBgw +FoAUqb9BteODF6wv5R57aEON/wGXMiowDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG +9w0BAQsFAAOCAQEAAcKhxI+tSItrXmqC0PSmgWyAYpqbkz6W/cefTutXqhIgY09f +h0LSv7ogTahoGpyiZk9vy6u3OE9bYwxapEfa4KBjO6HxBMIVBBb3RegVjoPzjElN +BDwAx0VGFcZTXwMxDWycWdG8ql7rCZBvS50w04uTaIgnGmqXAdWWmBgfJ9cRbxW+ +JwO/mOl1QM1lR/5142NpvuUVWlmZSKEGydE5A1qPz2wpDbBR1ym1BQNS4NEqw6Kp +GSB8jKyCS1Ve0v2wVze2038Wukz02dq9uKPTIO3T+B+ibZmxn6Op/kFCc1/kK5NS +Q6JdO1B6KquGAYdGmKAcQ19mv+jqGktqWEEf0g== +-----END CERTIFICATE----- diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-key.pem b/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-key.pem new file mode 100644 index 0000000..5746e59 --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCmP9vswRRJ+7eh +cx82BHBOx7trlRXsmzB/Uz9k39lmQCQjE0F69mCjON6y8s9auaxOA42LteKAlQm8 +KN2OaVb14MyWuL+uQPwe45HUNAJUov2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hC7 +5Psa78YQQBlMt2/g9TSsnuE+rYgF6mpKFiNm0Vasqeg47uzn2mdzqlUGTQKBgE04 +JutkTUY+h1pL5vYxWKpVDfy19z7H2tFxT1FowPrBneeLSyRI88Ac5I/yLdRlVeY9 +0LOmEr5Igwj3MsKgg7KVKfVLgdo/LrW3Jt2Kt3onKNXDkoBPoNUjwH0QC0Boiue+ +VK0gR0kVdm+bXccbxR+im+NwZNE0NLg6Qqu3RredAoGBALuVoqbPPmTCZXYG328H +bzOs2aiR7BzPSVByV+qG6jW7w03RAnFPJZp7HMU+ViI5VY0wabUscMSvz5163+gM +4KwY3v9ZjZzZGukIfLuudkdqtaiVOx/KeAC0n+nG21YU+wpZww8gkfHh1/sa2CME +CWYCgOnmiTHcj83UaTqEXtmv +-----END PRIVATE KEY----- diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml new file mode 100644 index 0000000..35914b7 --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml @@ -0,0 +1,207 @@ + + + + + + + + example.org + + + + + + + +MIIDEzCCAfugAwIBAgIUS9SuTXwsFVVG+LjOEAbLqqT/el0wDQYJKoZIhvcNAQEL +BQAwFTETMBEGA1UEAwwKaWRwdGVzdGJlZDAeFw0xNTEyMTEwMjIwMjZaFw0zNTEy +MTEwMjIwMjZaMBUxEzARBgNVBAMMCmlkcHRlc3RiZWQwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCMAoDHx8xCIfv/6QKqt9mcHYmEJ8y2dKprUbpdcOjH +YvNPIl/lHPsUyrb+Nc+q2CDeiWjVk1mWYq0UpIwpBMuw1H6+oOqr4VQRi65pin0M +SfE0MWIaFo5FPvpvoptkHD4gvREbm4swyXGMczcMRfqgalFXhUD2wz8W3XAM5Cq2 +03XeJbj6TwjvKatG5XPdeUe2FBGuOO2q54L1hcIGnLM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G +ifPkr9ORV6Cn3txq+9gMBePG41GrtZrUGIu+xrndL0Shh4Pq0eq/9MAsVlIIXEa8 +9WfH8J2kFcTOfoWtIc70b7TLZQsx4YnNcnrGLSUEcstFyPLX+Xtv5SNZF89OOIxX +VNjNvgE5DbJb9hMM4UAFqI+1bo9QqtxwThjc/sOvIxzNAgMBAAGjWzBZMB0GA1Ud +DgQWBBStTyogRPuAVG6q7yPyav1uvE+7pTA4BgNVHREEMTAvggppZHB0ZXN0YmVk +hiFodHRwczovL2lkcHRlc3RiZWQvaWRwL3NoaWJib2xldGgwDQYJKoZIhvcNAQEL +BQADggEBAFMfoOv+oISGjvamq7+Y4G7ep5vxlAPeK3RATYPYvAmyH946qZXh98ni +QXyuqZW5P5eEt86toY45IwDU5r09SKwHughEe99iiEkxh0mb2qo84qX9/qcg+kyN +jeLd/OSyolpUCEFNwOFcog7pj7Eer+6AHbwTn1Mjb5TBsKwtDMJsaxPvdj0u7M5r +xL/wHkFhn1rCo2QiojzjSlV3yLTh49iTyhE3cG+RxaNKDCxhp0jSSLX1BW/ZoPA8 ++PMJEA+Q0QbyRD8aJOHN5O8jGxCa/ZzcOnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H +p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + + + + + + + + + + + localhost + + + + + + +MIIDEzCCAfugAwIBAgIUS9SuTXwsFVVG+LjOEAbLqqT/el0wDQYJKoZIhvcNAQEL +BQAwFTETMBEGA1UEAwwKaWRwdGVzdGJlZDAeFw0xNTEyMTEwMjIwMjZaFw0zNTEy +MTEwMjIwMjZaMBUxEzARBgNVBAMMCmlkcHRlc3RiZWQwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCMAoDHx8xCIfv/6QKqt9mcHYmEJ8y2dKprUbpdcOjH +YvNPIl/lHPsUyrb+Nc+q2CDeiWjVk1mWY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VyEXPYQuRi7vfD +cO4a6d1kxiJLsaK0W88VNxjFQRr8PgDkWr28vwoH1rgk4pLsszLD48DBzD942peJ +l/S6FnsIJjmaHcBh4pbNhU4yowu63iKkvttrcZAEbpEro6Z8CziWEx8sywoaYEQG +ifPkr9ORV6Cn3txq+9gMBePG41GrtZrUGIu+xrndL0Shh4Pq0eq/9MAsVlIIXEa8 +9WfH8J2kFcTOfoWtIc70b7TLZQsx4YnNcnrGLSUEcstFyPLX+Xtv5SNZF89OOIxX +VNjNvgE5DbJb9hMM4UAFqI+1bo9QqtxwThjc/sOvIxzNAgMBAAGjWzBZMB0GA1Ud +DgQWBBStTyogRPuAVG6q7yPyav1uvE+7pTA4BgNVHREEMTAvggppZHB0ZXN0YmVk +hiFodHRwczovL2lkcHRlc3RiZWQvaWRwL3NoaWJib2xldGgwDQYJKoZIhvcNAQEL +BQADggEBAFMfoOv+oISGjvamq7+Y4G7ep5vxlAPeK3RATYPYvAmyH946qZXh98ni +QXyuqZW5P5eEt86toY45IwDU5r09SKwHughEe99iiEkxh0mb2qo84qX9/qcg+kyN +jeLd/OSyolpUCEFNwOFcog7pj7Eer+6AHbwTn1Mjb5TBsKwtDMJsaxPvdj0u7M5r +xL/wHkFhn1rCo2QiojzjSlV3yLTh49iTyhE3cG+RxaNKDCxhp0jSSLX1BW/ZoPA8 ++PMJEA+Q0QbyRD8aJOHN5O8jGxCa/ZzcOnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H +p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= + + + + + + + + + + + + + + diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml new file mode 100644 index 0000000..a644264 --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + SAML2 + + + + SAML2 Local + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem new file mode 100644 index 0000000..0f5474e --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAKUZrfriIt9cMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJNSTESMBAGA1UEBwwJQW5uIEFyYm9yMRcwFQYDVQQK +DA5JbnRlcm5ldDIvVElFUjEgMB4GA1UEAwwXZXZvbHZldW0uc3AuZXhhbXBsZS5v +cmcwHhcNMTgwOTE0MDU0NjU3WhcNMTkwOTE0MDU0NjU3WjBpMQswCQYDVQQGEwJV +UzELMAkGA1UECAwCTUkxEjAQBgNVBAcMCUFubiBBcmJvcjEXMBUGA1UECgwOSW50 +ZXJuZXQyL1RJRVIxIDAeBgNVBAMMF2V2b2x2ZXVtLnNwLmV4YW1wbGUub3JnMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw5v1zxlM94yaBssgNNbIUJwW +XxbGxgSs2AWBeg2aEi/VQd2UE5ivZakNJlqWSJyHo2xE4kxeSyBBxinjSyhmpNao +xIcqQsgW0gxo4SEHo3kUXWPo+of/pj6CslutsSJZWGTRV0dHITvaWX+NM8eXMfgu +mJFwy3RMdLaWQhY1Dyi2jNoO+DZnfNgPyPeEZcmORaoeEID9QdZfHtcgTf2QfSHq ++xsTwHB6Ro5t7YD2ma8Krb/XcDTfsq3qJemd7LhPj5lGmhYSMgDbgwEkZgZ1kBOP +lfsP2BvX5nipv7Vd1C5YXmv+NDR8V3yAWBC7ZAenxGmrnkaSVXnpUplUsGGm1QID +AQABo1MwUTAdBgNVHQ4EFgQUuxSZwW6V1P/b0tsTM32OU/v/n+UwHwYDVR0jBBgw +FoAUuxSZwW6V1P/b0tsTM32OU/v/n+UwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG +9w0BAQsFAAOCAQEAJWLXEfZkPeUyiGvsIUjczzdF3ptqXoP9aETS2pOV9sTri19R +TsQZW6XQRHGtuEOsqEGH8yiTdGR5hbGC+ynH/xTJnK+tBn/R3KrgxLKyMvoUzAPl +mhVq1dh+ZEtbsRpQRRubP6nm9kXNma0cXrkJSzuWM0W+l/xSOOYiSRRk3XWJfVjn +9jQlcJRh5SOkKN08oZHrCYKxToEuOfV8PtRj3T80DhsBTv2SHqhg4cBhzQPb0Kjm +9m4IkYOz8c5ZtuHDGnqMHw60Nyt+jyik4mMFP2frcOVP0W0sgwcfHllYzHoA/Khq +Yk3TBVs1BjPuNDJWHct8Eo68YP2/ZvzqfVM87Q== +-----END CERTIFICATE----- diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem new file mode 100644 index 0000000..b4c7a68 --- /dev/null +++ b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDm/XPGUz3jJoG +yyA01shQnBZfFsbGBKzYBYF6DZoSL9VB3ZQTmK9lqQ0mWpZInIejbETiTF5LIEHG +KeNLKGak1qjEhypCyBbSDGjhIQejeRRdY+j6h/+mPoKyW62xIllYZNFXR0chO9pZ +f40zx5cx+C6YkXDLdEx0tpZCFjUPKLaM2g74Nmd82A/I94RlyY5Fqh4QgP1B1l8e +1yBN/ZB9Ier7GxPAcHpGjm3tgPaZrwqtv9dwNN+yreol6Z3suE+PmUaaFhIyANuD +ASRmBnWQE4+V+w/YG9fmeKm/tV3ULlhea/40NHxXfIBYELtkB6fEaaueRpJVeelS +mVSwYabVAgMBAAECggEAeQx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U19c7xRTy +kfVzE6PI+E8ZZ6qEWMs2Xt3NQL4Bffh94QQCmQYX3AY7xVD1gAQgbLXx4lEDQdzu +i/kV4t+oeYwXSn1UEgOQj504qwR3gi4JZdfa0LbiMzhp9qyxofyk7Lre7Tc3Xmu1 +jyigTF7oAYoPBWk/mAthK1wO +-----END PRIVATE KEY----- diff --git a/demo/postgresql-full/docker-compose.yml b/demo/postgresql-full/docker-compose.yml new file mode 100644 index 0000000..74c3d8e --- /dev/null +++ b/demo/postgresql-full/docker-compose.yml @@ -0,0 +1,70 @@ +version: "3.3" + +services: + postgresql: + image: postgres:9.5 + environment: + - POSTGRES_PASSWORD=password + ports: + - 5432:5432 + networks: + - back + volumes: + - midpoint_data:/var/lib/postgresql/data + + midpoint-server: + image: tier/midpoint:latest + ports: + - 8443:443 + environment: + - AUTHENTICATION + - ENV + - USERTOKEN + - REPO_DATABASE_TYPE=postgresql + - REPO_HOST=postgresql + - REPO_DATABASE=midpoint + - REPO_USER=midpoint + - MEM + - TIER_BEACON_OPT_OUT + networks: + - back + secrets: + - m_database_password.txt + - m_keystore_password.txt + - m_sp-key.pem + - m_host-key.pem + volumes: + - midpoint_home:/opt/midpoint/var + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/shibboleth2.xml + target: /etc/shibboleth/shibboleth2.xml + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/idp-metadata.xml + target: /etc/shibboleth/idp-metadata.xml + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/sp-cert.pem + target: /etc/shibboleth/sp-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/host-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/cachain.pem + +networks: + back: + driver: bridge + +secrets: + m_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem + m_sp-key.pem: + file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem + m_database_password.txt: + file: ./configs-and-secrets/midpoint/application/database_password.txt + m_keystore_password.txt: + file: ./configs-and-secrets/midpoint/application/keystore_password.txt + +volumes: + midpoint_data: + midpoint_home: diff --git a/demo/postgresql/postgresql/Dockerfile b/demo/postgresql-full/postgresql-to-be-removed/Dockerfile similarity index 100% rename from demo/postgresql/postgresql/Dockerfile rename to demo/postgresql-full/postgresql-to-be-removed/Dockerfile diff --git a/demo/postgresql/postgresql/container_files/init-user-db.sh b/demo/postgresql-full/postgresql-to-be-removed/container_files/init-user-db.sh similarity index 100% rename from demo/postgresql/postgresql/container_files/init-user-db.sh rename to demo/postgresql-full/postgresql-to-be-removed/container_files/init-user-db.sh diff --git a/demo/postgresql/docker-compose.yml b/demo/postgresql-increment/docker-compose.yml similarity index 100% rename from demo/postgresql/docker-compose.yml rename to demo/postgresql-increment/docker-compose.yml diff --git a/demo/postgresql/midpoint-additions-for-standalone-run.yml b/demo/postgresql-increment/midpoint-additions-for-standalone-run.yml similarity index 100% rename from demo/postgresql/midpoint-additions-for-standalone-run.yml rename to demo/postgresql-increment/midpoint-additions-for-standalone-run.yml diff --git a/demo/postgresql/midpoint-additions.yml b/demo/postgresql-increment/midpoint-additions.yml similarity index 100% rename from demo/postgresql/midpoint-additions.yml rename to demo/postgresql-increment/midpoint-additions.yml diff --git a/demo/postgresql-increment/postgresql/Dockerfile b/demo/postgresql-increment/postgresql/Dockerfile new file mode 100644 index 0000000..dcaf4d6 --- /dev/null +++ b/demo/postgresql-increment/postgresql/Dockerfile @@ -0,0 +1,3 @@ +FROM postgres:9.5 + +COPY container_files/* /docker-entrypoint-initdb.d/ diff --git a/demo/postgresql-increment/postgresql/container_files/init-user-db.sh b/demo/postgresql-increment/postgresql/container_files/init-user-db.sh new file mode 100755 index 0000000..95df619 --- /dev/null +++ b/demo/postgresql-increment/postgresql/container_files/init-user-db.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +echo Creating midPoint user and database + +psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL + CREATE USER midpoint WITH PASSWORD '456654' LOGIN SUPERUSER; + CREATE DATABASE midpoint WITH OWNER = midpoint ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8' CONNECTION LIMIT = -1; +EOSQL + +echo midPoint user and database were created + From 27acbc616e18ee8ceed05259220f89376e362499 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 10:47:57 +0200 Subject: [PATCH 24/73] Add basic Shibboleth tests --- Jenkinsfile | 1 + demo/shibboleth/README.md | 3 +++ demo/shibboleth/tests/main.bats | 31 +++++++++++++++++++++++++++++++ demo/simple/tests/main.bats | 5 ++++- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 demo/shibboleth/README.md create mode 100755 demo/shibboleth/tests/main.bats diff --git a/Jenkinsfile b/Jenkinsfile index 9d177f9..e854504 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,6 +53,7 @@ pipeline { try { sh 'bin/test.sh 2>&1 | tee debug' sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug' + sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug' // sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') diff --git a/demo/shibboleth/README.md b/demo/shibboleth/README.md new file mode 100644 index 0000000..79a1bb8 --- /dev/null +++ b/demo/shibboleth/README.md @@ -0,0 +1,3 @@ +This container composition is to be used outside other midPoint compositions like `demo/simple` or `demo/postgresql-full`. + +Just start it along with the other midPoint composition. They should work together seamlessly. diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats new file mode 100755 index 0000000..778b35f --- /dev/null +++ b/demo/shibboleth/tests/main.bats @@ -0,0 +1,31 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../../library + +@test "000 Cleanup before running the tests" { + cd ../simple ; docker-compose down -v ; true + run docker-compose down -v +} + +@test "010 Initialize and start midPoint" { + cd ../simple ; docker-compose up -d + wait_for_midpoint_start simple_midpoint-server_1 +} + +@test "020 Initialize and start Shibboleth" { + docker-compose up -d + # TODO implement wait_for_shibboleth_start + sleep 20 +} + +@test "030 Check health" { + check_health +} + +# TODO check that e.g. accessing some URLs results in shibboleth redirection (check login page, some REST calls etc) + +@test "999 Clean up" { + cd ../simple ; docker-compose down -v ; true + run docker-compose down -v +} diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats index 530c53e..9b07272 100755 --- a/demo/simple/tests/main.bats +++ b/demo/simple/tests/main.bats @@ -3,8 +3,11 @@ load ../../../common load ../../../library -@test "000 Initialize and start midPoint" { +@test "000 Cleanup before running the tests" { run docker-compose down -v +} + +@test "010 Initialize and start midPoint" { docker-compose up -d wait_for_midpoint_start simple_midpoint-server_1 } From 7c3c892c6afc18b7dda4c433c63bd842ce38affb Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 11:42:15 +0200 Subject: [PATCH 25/73] Add initial demo/complex tests Might fail if xpath is not installed. --- Jenkinsfile | 4 ++- demo/complex/tests/main.bats | 60 ++++++++++++++++++++++++++++++++++++ library.bash | 27 +++++++++++++--- 3 files changed, 86 insertions(+), 5 deletions(-) create mode 100755 demo/complex/tests/main.bats diff --git a/Jenkinsfile b/Jenkinsfile index e854504..e200e2b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -34,7 +34,7 @@ pipeline { steps { script { try { - sh '(docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary + sh '(ls -l ; docker ps -a ; docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary sh './download-midpoint 2>&1 | tee -a debug' sh 'bin/rebuild.sh 2>&1 | tee -a debug' //sh 'echo Build output ; cat debug' @@ -54,6 +54,8 @@ pipeline { sh 'bin/test.sh 2>&1 | tee debug' sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug' sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug' + sh '(echo Checking if xpath is present ; xpath || true ) 2>&1 | tee -a debug' + sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug' // sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats new file mode 100755 index 0000000..3009bd5 --- /dev/null +++ b/demo/complex/tests/main.bats @@ -0,0 +1,60 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../../library + +@test "000 Cleanup before running the tests" { +# skip + run docker-compose down -v +} + +@test "010 Initialize and start the composition" { +# skip + docker-compose up -d + wait_for_midpoint_start complex_midpoint-server_1 +# TODO wait for shibboleth, grouper-ui, (also something other?) +} + +@test "010 Check midPoint health" { + check_health +} + +@test "020 Check Grouper health" { + skip TODO +} + +@test "100 Get 'administrator'" { + check_health + get_and_check_object users 00000000-0000-0000-0000-000000000002 administrator +} + +@test "110 And and get 'test110'" { + check_health + echo "test110" >/tmp/test110.xml + add_object users /tmp/test110.xml + rm /tmp/test110.xml + search_and_check_object users test110 +# TODO delete user after +} + +@test "200 Upload objects" { + check_health + pwd >&2 + ./upload-objects + search_and_check_object objectTemplates template-org-course + search_and_check_object objectTemplates template-org-department + search_and_check_object objectTemplates template-role-affiliation + search_and_check_object objectTemplates template-role-generic-group +# TODO check other objects that were uploaded +} + +@test "210 Test resource" { + test_resource 0a37121f-d515-4a23-9b6d-554c5ef61272 + test_resource 6dcb84f5-bf82-4931-9072-fbdf87f96442 + test_resource 13660d60-071b-4596-9aa1-5efcd1256c04 + test_resource 4d70a0da-02dd-41cf-b0a1-00e75d3eaa15 +} + +@test "999 Clean up" { + docker-compose down -v +} diff --git a/library.bash b/library.bash index e605ab5..3fa16cd 100644 --- a/library.bash +++ b/library.bash @@ -62,8 +62,8 @@ function get_and_check_object () { # TODO Returns the OID in OID variable # it can be found in the following HTTP reader returned: Location: "https://localhost:8443/midpoint/ws/rest/users/85e62669-d36b-41ce-b4f1-1ffdd9f66262" function add_object () { - TYPE=$1 - FILE=$2 + local TYPE=$1 + local FILE=$2 echo "Adding to $TYPE from $FILE..." curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE || return 1 #TODO check the returned XML @@ -95,8 +95,8 @@ EOF # Searches for object with a given name and verifies it was found function search_and_check_object () { - TYPE=$1 - NAME=$2 + local TYPE=$1 + local NAME=$2 search_objects_by_name $TYPE $NAME || return 1 if (grep -q "$NAME" <$SEARCH_RESULT_FILE); then echo "Object $TYPE/'$NAME' is OK" @@ -109,3 +109,22 @@ function search_and_check_object () { return 1 fi } + +# Tests a resource +function test_resource () { + local OID=$1 + local TMPFILE=$(mktemp /tmp/test.resource.XXXXXX) + local TMPFILE_ERR=$(mktemp /tmp/test.resource.err.XXXXXX) + + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE $TMPFILE_ERR ; return 1) + if [[ $(xpath -q -e "*/status/text()" < $TMPFILE) == "success" ]]; then + echo "Resource $OID test succeeded" + rm $TMPFILE + return 0 + else + echo "Resource $OID test failed" + cat $TMPFILE + rm $TMPFILE + return 1 + fi +} From 5f100318eee91c6cb8d0f2941b344b48c84ce3f3 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 12:20:40 +0200 Subject: [PATCH 26/73] Fix error detection in Jenkinsfile ...and added cleanup step as well --- Jenkinsfile | 17 ++++++++++------- download-midpoint | 2 ++ tests/main.bats | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e200e2b..c270952 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -35,8 +35,8 @@ pipeline { script { try { sh '(ls -l ; docker ps -a ; docker image ls ; echo Destroying ; bin/destroy.sh ; docker image ls) 2>&1 | tee debug' // temporary - sh './download-midpoint 2>&1 | tee -a debug' - sh 'bin/rebuild.sh 2>&1 | tee -a debug' + sh './download-midpoint 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh 'bin/rebuild.sh 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' //sh 'echo Build output ; cat debug' } catch (error) { def error_details = readFile('./debug') @@ -51,11 +51,14 @@ pipeline { steps { script { try { - sh 'bin/test.sh 2>&1 | tee debug' - sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug' - sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug' - sh '(echo Checking if xpath is present ; xpath || true ) 2>&1 | tee -a debug' - sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug' + sh 'echo Docker containers before root tests ; docker ps -a' // temporary + sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0' + sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary + + sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + // sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') diff --git a/download-midpoint b/download-midpoint index a6cf1a0..3cbea87 100755 --- a/download-midpoint +++ b/download-midpoint @@ -8,7 +8,9 @@ echo "-----------------------------------------" echo "Checking the download..." if tar -tf $dir/midpoint-3.9-SNAPSHOT-dist.tar.gz >/dev/null; then echo "OK" + exit 0 else echo "The file was not downloaded correctly" + exit 1 fi diff --git a/tests/main.bats b/tests/main.bats index 0856ec5..8b10b47 100755 --- a/tests/main.bats +++ b/tests/main.bats @@ -15,5 +15,20 @@ load ../common /etc/httpd/ } +@test "100 Cleanup before further tests - demo/simple" { + docker ps -a + cd demo/simple ; docker-compose down -v ; true +} + +@test "110 Cleanup before further tests - demo/shibboleth" { + docker ps -a + cd demo/shibboleth ; docker-compose down -v ; true +} + +@test "120 Cleanup before further tests - demo/complex" { + docker ps -a + cd demo/complex ; docker-compose down -v ; true +} + # not much more to check here, as we cannot start midpoint container without having a repository # so continuing with tests in demo/plain directory From ec257f5f8ad0b88cb8bc833f6cdd221d5e9365f1 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 12:35:56 +0200 Subject: [PATCH 27/73] Fix demo/complex tests (hopefully) 1. xpath -> xmllint 2. added some docker containers cleanup --- Jenkinsfile | 2 ++ demo/complex/tests/main.bats | 2 ++ demo/shibboleth/tests/main.bats | 4 ++-- library.bash | 6 +++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c270952..1dfc42b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,6 +55,8 @@ pipeline { sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0' sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary + sh 'xmllint &>> debug' // temporary + sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 3009bd5..b519b12 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -5,11 +5,13 @@ load ../../../library @test "000 Cleanup before running the tests" { # skip + cd ../shibboleth ; docker-compose down -v ; true run docker-compose down -v } @test "010 Initialize and start the composition" { # skip + docker ps -a docker-compose up -d wait_for_midpoint_start complex_midpoint-server_1 # TODO wait for shibboleth, grouper-ui, (also something other?) diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 778b35f..48a4f5a 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -16,7 +16,7 @@ load ../../../library @test "020 Initialize and start Shibboleth" { docker-compose up -d # TODO implement wait_for_shibboleth_start - sleep 20 + sleep 60 } @test "030 Check health" { @@ -27,5 +27,5 @@ load ../../../library @test "999 Clean up" { cd ../simple ; docker-compose down -v ; true - run docker-compose down -v + docker-compose down -v } diff --git a/library.bash b/library.bash index 3fa16cd..59c5fa3 100644 --- a/library.bash +++ b/library.bash @@ -117,7 +117,7 @@ function test_resource () { local TMPFILE_ERR=$(mktemp /tmp/test.resource.err.XXXXXX) curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE $TMPFILE_ERR ; return 1) - if [[ $(xpath -q -e "*/status/text()" < $TMPFILE) == "success" ]]; then + if [[ $(xmllint --xpath "*/status/text()" $TMPFILE) == "success" ]]; then echo "Resource $OID test succeeded" rm $TMPFILE return 0 @@ -128,3 +128,7 @@ function test_resource () { return 1 fi } + +function get_xpath () { + echo ok +} From 845e6a49325c4341c9de65f7cf082036979ee3ee Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 12:38:13 +0200 Subject: [PATCH 28/73] Fix exit status bug --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1dfc42b..c270952 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,8 +55,6 @@ pipeline { sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0' sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary - sh 'xmllint &>> debug' // temporary - sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' From dd8c8ae5aff0321fb40f779955103baea7728394 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 13:29:05 +0200 Subject: [PATCH 29/73] Disable tests temporarily --- Jenkinsfile | 6 +++--- demo/complex/tests/main.bats | 17 +++++++++++++---- library.bash | 5 ++++- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c270952..31c0a6c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,9 +55,9 @@ pipeline { sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0' sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary - sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + //sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + //sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + //sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // sh 'echo Test output ; cat debug' } catch (error) { diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index b519b12..1e70b44 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -4,33 +4,40 @@ load ../../../common load ../../../library @test "000 Cleanup before running the tests" { -# skip cd ../shibboleth ; docker-compose down -v ; true run docker-compose down -v } @test "010 Initialize and start the composition" { -# skip docker ps -a docker-compose up -d +} + +@test "020 Wait until components are started" { + touch $BATS_TMPDIR/not-started wait_for_midpoint_start complex_midpoint-server_1 + rm $BATS_TMPDIR/not-started # TODO wait for shibboleth, grouper-ui, (also something other?) } -@test "010 Check midPoint health" { +@test "050 Check midPoint health" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi check_health } -@test "020 Check Grouper health" { +@test "060 Check Grouper health" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi skip TODO } @test "100 Get 'administrator'" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi check_health get_and_check_object users 00000000-0000-0000-0000-000000000002 administrator } @test "110 And and get 'test110'" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi check_health echo "test110" >/tmp/test110.xml add_object users /tmp/test110.xml @@ -40,6 +47,7 @@ load ../../../library } @test "200 Upload objects" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi check_health pwd >&2 ./upload-objects @@ -51,6 +59,7 @@ load ../../../library } @test "210 Test resource" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi test_resource 0a37121f-d515-4a23-9b6d-554c5ef61272 test_resource 6dcb84f5-bf82-4931-9072-fbdf87f96442 test_resource 13660d60-071b-4596-9aa1-5efcd1256c04 diff --git a/library.bash b/library.bash index 59c5fa3..c8873cc 100644 --- a/library.bash +++ b/library.bash @@ -20,6 +20,9 @@ function wait_for_midpoint_start () { done echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME + echo "========== Container log ==========" + docker logs $CONTAINER_NAME 2>&1 + echo "========== End of the container log ==========" return 1 } @@ -124,7 +127,7 @@ function test_resource () { else echo "Resource $OID test failed" cat $TMPFILE - rm $TMPFILE +# rm $TMPFILE return 1 fi } From c80f7e41388670dade1870dd37fcec0e85801dd2 Mon Sep 17 00:00:00 2001 From: skublik Date: Fri, 28 Sep 2018 11:32:56 +0000 Subject: [PATCH 30/73] modifying of postgres service environment variables --- demo/postgresql-full/docker-compose.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/demo/postgresql-full/docker-compose.yml b/demo/postgresql-full/docker-compose.yml index 74c3d8e..a4a1ec6 100644 --- a/demo/postgresql-full/docker-compose.yml +++ b/demo/postgresql-full/docker-compose.yml @@ -4,11 +4,15 @@ services: postgresql: image: postgres:9.5 environment: - - POSTGRES_PASSWORD=password + - POSTGRES_PASSWORD_FILE=/run/secrets/m_database_password.txt + - POSTGRES_USER=midpoint + - POSTGRES_INITDB_ARGS=--lc-collate=en_US.utf8 --lc-ctype=en_US.utf8 ports: - 5432:5432 networks: - back + secrets: + - m_database_password.txt volumes: - midpoint_data:/var/lib/postgresql/data From cb2154a0eb261758e7d25d15dfd1c50db344c730 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 14:24:27 +0200 Subject: [PATCH 31/73] Try to make tests pass --- Jenkinsfile | 6 +++--- demo/complex/tests/main.bats | 10 +++++++--- library.bash | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 31c0a6c..c270952 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,9 +55,9 @@ pipeline { sh 'bin/test.sh 2>&1 | tee debug ; test ${PIPESTATUS[0]} -eq 0' sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary - //sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - //sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - //sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // sh 'echo Test output ; cat debug' } catch (error) { diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 1e70b44..89b08f4 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -4,8 +4,12 @@ load ../../../common load ../../../library @test "000 Cleanup before running the tests" { - cd ../shibboleth ; docker-compose down -v ; true - run docker-compose down -v + pwd > /tmp/log + echo a1 >> /tmp/log + (cd ../shibboleth ; docker-compose down -v ; sleep 60) || true + echo a2 >> /tmp/log + (docker-compose down -v ; sleep 60) || true + echo a3 >> /tmp/log } @test "010 Initialize and start the composition" { @@ -67,5 +71,5 @@ load ../../../library } @test "999 Clean up" { - docker-compose down -v +# docker-compose down -v } diff --git a/library.bash b/library.bash index c8873cc..9ed8046 100644 --- a/library.bash +++ b/library.bash @@ -120,14 +120,14 @@ function test_resource () { local TMPFILE_ERR=$(mktemp /tmp/test.resource.err.XXXXXX) curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE $TMPFILE_ERR ; return 1) - if [[ $(xmllint --xpath "*/status/text()" $TMPFILE) == "success" ]]; then + if [[ $(xmllint --xpath "/*/*[local-name()='status']/text()" $TMPFILE) == "success" ]]; then echo "Resource $OID test succeeded" rm $TMPFILE return 0 else echo "Resource $OID test failed" cat $TMPFILE -# rm $TMPFILE + rm $TMPFILE return 1 fi } From 80165ac1edcdb8c137a3e5f0152a6ecbcd880368 Mon Sep 17 00:00:00 2001 From: skublik Date: Fri, 28 Sep 2018 13:14:33 +0000 Subject: [PATCH 32/73] tests for shibboleth redirection --- demo/shibboleth/tests/main.bats | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 48a4f5a..4d98519 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -23,6 +23,37 @@ load ../../../library check_health } +@test "040 Check Shibboleth redirection (/midpoint)" { + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint)" + [ "$status" -eq 302 ] +} + +@test "041 Check Shibboleth redirection (/midpoint/)" { + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/)" + [ "$status" -eq 302 ] +} + +@test "042 Check Shibboleth redirection (/midpoint/login)" { + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/login)" + [ "$status" -eq 302 ] +} + +@test "043 Check Shibboleth redirection (/midpoint/something)" { + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/something)" + [ "$status" -eq 302 ] +} + +@test "044 Check SOAP without Shibboleth redirection (/midpoint/ws/)" { + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/ws/)" + [ "$status" -eq 200 ] +} + +@test "045 Check SOAP without Shibboleth redirection (/midpoint/model/)" { + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/model/)" + [ "$status" -eq 200 ] +} + + # TODO check that e.g. accessing some URLs results in shibboleth redirection (check login page, some REST calls etc) @test "999 Clean up" { From 57683c7a03fcd881547bd0828c33efae4a5fc4c8 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 15:55:26 +0200 Subject: [PATCH 33/73] Disable wait-to-retry for reverse proxy Health check running too early was causing test failures. --- container_files/httpd/conf/midpoint.conf.auth.internal | 2 +- container_files/httpd/conf/midpoint.conf.auth.shibboleth | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/container_files/httpd/conf/midpoint.conf.auth.internal b/container_files/httpd/conf/midpoint.conf.auth.internal index 690a4cd..2d63bda 100644 --- a/container_files/httpd/conf/midpoint.conf.auth.internal +++ b/container_files/httpd/conf/midpoint.conf.auth.internal @@ -3,4 +3,4 @@ Timeout 2400 ProxyTimeout 2400 ProxyBadHeader Ignore -ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 \ No newline at end of file +ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 retry=0 diff --git a/container_files/httpd/conf/midpoint.conf.auth.shibboleth b/container_files/httpd/conf/midpoint.conf.auth.shibboleth index faef9ae..ca38a30 100644 --- a/container_files/httpd/conf/midpoint.conf.auth.shibboleth +++ b/container_files/httpd/conf/midpoint.conf.auth.shibboleth @@ -3,7 +3,7 @@ Timeout 2400 ProxyTimeout 2400 ProxyBadHeader Ignore -ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 +ProxyPass /midpoint ajp://localhost:9090/midpoint timeout=2400 retry=0 AuthType shibboleth From 8de6c1c447f518ce87e2b92926dcdefa96948b66 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 16:01:24 +0200 Subject: [PATCH 34/73] Add some failing tests diagnostics --- demo/complex/tests/main.bats | 12 +++++++----- library.bash | 6 ++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 89b08f4..916cb0b 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -6,20 +6,22 @@ load ../../../library @test "000 Cleanup before running the tests" { pwd > /tmp/log echo a1 >> /tmp/log - (cd ../shibboleth ; docker-compose down -v ; sleep 60) || true + (cd ../shibboleth ; docker-compose down -v ; sleep 1) || true echo a2 >> /tmp/log - (docker-compose down -v ; sleep 60) || true + (docker-compose down -v ; sleep 1) || true echo a3 >> /tmp/log } @test "010 Initialize and start the composition" { - docker ps -a - docker-compose up -d + docker ps -a >> /tmp/log + docker ps + ! (docker ps | grep complex_midpoint-server_1) + docker-compose up -d --build } @test "020 Wait until components are started" { touch $BATS_TMPDIR/not-started - wait_for_midpoint_start complex_midpoint-server_1 + wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1 rm $BATS_TMPDIR/not-started # TODO wait for shibboleth, grouper-ui, (also something other?) } diff --git a/library.bash b/library.bash index 9ed8046..a042733 100644 --- a/library.bash +++ b/library.bash @@ -7,6 +7,7 @@ # Waits until midPoint starts function wait_for_midpoint_start () { CONTAINER_NAME=$1 + DATABASE_CONTAINER_NAME=$2 ATTEMPT=0 MAX_ATTEMPTS=20 DELAY=10 @@ -23,6 +24,11 @@ function wait_for_midpoint_start () { echo "========== Container log ==========" docker logs $CONTAINER_NAME 2>&1 echo "========== End of the container log ==========" + if [ -n "$DATABASE_CONTAINER_NAME" ]; then + echo "========== Container log ($DATABASE_CONTAINER_NAME) ==========" + docker logs $DATABASE_CONTAINER_NAME 2>&1 + echo "========== End of the container log ($DATABASE_CONTAINER_NAME) ==========" + fi return 1 } From e73ec49723d70a44fc0013956b03f9969d7f9e71 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 16:05:04 +0200 Subject: [PATCH 35/73] Do minor test fixes --- demo/complex/tests/main.bats | 2 +- demo/shibboleth/tests/main.bats | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 916cb0b..ec21f99 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -73,5 +73,5 @@ load ../../../library } @test "999 Clean up" { -# docker-compose down -v + docker-compose down -v } diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 4d98519..dfdd6c2 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -28,34 +28,31 @@ load ../../../library [ "$status" -eq 302 ] } -@test "041 Check Shibboleth redirection (/midpoint/)" { +@test "041 Check Shibboleth redirection (/midpoint/)" { status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/)" [ "$status" -eq 302 ] } -@test "042 Check Shibboleth redirection (/midpoint/login)" { +@test "042 Check Shibboleth redirection (/midpoint/login)" { status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/login)" [ "$status" -eq 302 ] } -@test "043 Check Shibboleth redirection (/midpoint/something)" { +@test "043 Check Shibboleth redirection (/midpoint/something)" { status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/something)" [ "$status" -eq 302 ] } -@test "044 Check SOAP without Shibboleth redirection (/midpoint/ws/)" { +@test "044 Check SOAP without Shibboleth redirection (/midpoint/ws/)" { status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/ws/)" [ "$status" -eq 200 ] } -@test "045 Check SOAP without Shibboleth redirection (/midpoint/model/)" { +@test "045 Check SOAP without Shibboleth redirection (/midpoint/model/)" { status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/model/)" [ "$status" -eq 200 ] } - -# TODO check that e.g. accessing some URLs results in shibboleth redirection (check login page, some REST calls etc) - @test "999 Clean up" { cd ../simple ; docker-compose down -v ; true docker-compose down -v From 0a126d922696c8b5cbb1b7a2c79ad62f3ad2aeb2 Mon Sep 17 00:00:00 2001 From: skublik Date: Fri, 28 Sep 2018 15:12:00 +0000 Subject: [PATCH 36/73] removing mistakes in shibboleth tests --- demo/shibboleth/tests/main.bats | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 4d98519..c81a96c 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -9,7 +9,7 @@ load ../../../library } @test "010 Initialize and start midPoint" { - cd ../simple ; docker-compose up -d + cd ../simple ; env AUTHENTICATION=shibboleth docker-compose up -d wait_for_midpoint_start simple_midpoint-server_1 } @@ -24,23 +24,19 @@ load ../../../library } @test "040 Check Shibboleth redirection (/midpoint)" { - status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint)" - [ "$status" -eq 302 ] + curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect' } @test "041 Check Shibboleth redirection (/midpoint/)" { - status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/)" - [ "$status" -eq 302 ] + curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/ | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect' } @test "042 Check Shibboleth redirection (/midpoint/login)" { - status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/login)" - [ "$status" -eq 302 ] + curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/login | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect' } @test "043 Check Shibboleth redirection (/midpoint/something)" { - status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:8443/midpoint/something)" - [ "$status" -eq 302 ] + curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/something | grep 'https:\/\/localhost:4443\/idp\/profile\/SAML2\/Redirect' } @test "044 Check SOAP without Shibboleth redirection (/midpoint/ws/)" { From d19dfc400d8805e619311b18e3c095a4e69b5876 Mon Sep 17 00:00:00 2001 From: skublik Date: Fri, 28 Sep 2018 15:13:48 +0000 Subject: [PATCH 37/73] removing TODO --- demo/shibboleth/tests/main.bats | 3 --- 1 file changed, 3 deletions(-) diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index c81a96c..9c044c6 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -49,9 +49,6 @@ load ../../../library [ "$status" -eq 200 ] } - -# TODO check that e.g. accessing some URLs results in shibboleth redirection (check login page, some REST calls etc) - @test "999 Clean up" { cd ../simple ; docker-compose down -v ; true docker-compose down -v From be4a7239f5c23f9067a96443069f458ee1696a90 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 28 Sep 2018 17:28:29 +0200 Subject: [PATCH 38/73] Add SIS_PERSONS -> midPoint test --- demo/complex/tests/main.bats | 34 ++++++++++++++---- demo/complex/tests/resources/sql/courses.sql | 31 ++++++++++++++++ demo/complex/tests/resources/sql/persons.sql | 38 ++++++++++++++++++++ library.bash | 21 +++++++---- 4 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 demo/complex/tests/resources/sql/courses.sql create mode 100644 demo/complex/tests/resources/sql/persons.sql diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index ec21f99..028ee65 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -4,18 +4,16 @@ load ../../../common load ../../../library @test "000 Cleanup before running the tests" { - pwd > /tmp/log - echo a1 >> /tmp/log - (cd ../shibboleth ; docker-compose down -v ; sleep 1) || true - echo a2 >> /tmp/log - (docker-compose down -v ; sleep 1) || true - echo a3 >> /tmp/log + (cd ../simple ; docker-compose down -v) + (cd ../shibboleth ; docker-compose down -v) + docker-compose down -v } @test "010 Initialize and start the composition" { docker ps -a >> /tmp/log docker ps - ! (docker ps | grep complex_midpoint-server_1) + ! (docker ps | grep -E "shibboleth_(idp|directory)_1|complex_(midpoint-server|midpoint-data)_1|simple_(midpoint-server|midpoint-data)_1") + cp tests/resources/sql/* sources/container_files/seed-data/ docker-compose up -d --build } @@ -72,6 +70,28 @@ load ../../../library test_resource 4d70a0da-02dd-41cf-b0a1-00e75d3eaa15 } +@test "220 Import SIS_PERSONS" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi + + add_object tasks midpoint-objects-manual/tasks/task-import-sis-persons.xml + search_and_check_object tasks "Import from SIS persons" + wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a79aeaaa + assert_task_success 22c2a3d0-0961-4255-9eec-c550a79aeaaa + + search_and_check_object users jsmith + search_and_check_object users banderson + search_and_check_object users kwhite + search_and_check_object users whenderson + search_and_check_object users ddavis + search_and_check_object users cmorrison + search_and_check_object users danderson + search_and_check_object users amorrison + search_and_check_object users wprice + search_and_check_object users mroberts + # TODO check in LDAP, check assignments etc +} + @test "999 Clean up" { +# skip TEMP docker-compose down -v } diff --git a/demo/complex/tests/resources/sql/courses.sql b/demo/complex/tests/resources/sql/courses.sql new file mode 100644 index 0000000..51d1a56 --- /dev/null +++ b/demo/complex/tests/resources/sql/courses.sql @@ -0,0 +1,31 @@ +CREATE TABLE SIS_COURSES ( + uid varchar(255) NOT NULL, + surname varchar(255) default NULL, + givenName varchar(255) default NULL, + courseId varchar(255) default NULL, + PRIMARY KEY (uid, courseId) +); + +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','CS252'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','ACCT201'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','SCI404'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('kwhite','White','Karl','MATH100'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('whenderson','Henderson','William','ACCT101'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('ddavis','Davis','David','CS251'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('ddavis','Davis','David','MATH100'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','ACCT101'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','CS251'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','MATH101'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('cmorrison','Morrison','Colin','ACCT201'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('danderson','Anderson','Donna','SCI123'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('danderson','Anderson','Donna','ACCT201'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('danderson','Anderson','Donna','MATH100'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('amorrison','Morrison','Ann','CS251'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('amorrison','Morrison','Ann','ACCT101'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('amorrison','Morrison','Ann','MATH101'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('wprice','Price','William','MATH100'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('wprice','Price','William','SCI404'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','SCI123'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','ACCT101'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','CS251'); +INSERT INTO SIS_COURSES (uid, surname, givenName, courseId) VALUES ('mroberts','Roberts','Marie','MATH101'); diff --git a/demo/complex/tests/resources/sql/persons.sql b/demo/complex/tests/resources/sql/persons.sql new file mode 100644 index 0000000..8eec175 --- /dev/null +++ b/demo/complex/tests/resources/sql/persons.sql @@ -0,0 +1,38 @@ +CREATE TABLE SIS_PERSONS ( + uid varchar(255) NOT NULL, + surname varchar(255) default NULL, + givenName varchar(255) default NULL, + fullName varchar(255) default NULL, + department varchar(255) default NULL, + mail varchar(255) default NULL, + PRIMARY KEY (uid) +); + +CREATE TABLE SIS_AFFILIATIONS ( + uid varchar(255) NOT NULL, + affiliation varchar(255) NOT NULL, + PRIMARY KEY (uid, affiliation) +); + +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('jsmith','Smith','Joe','John Smith',NULL,NULL); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('banderson','Anderson','Bob','Bob Anderson',NULL,NULL); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('kwhite','White','Karl','Karl White','Law','kwhite@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('kwhite','member'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('kwhite','student'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('whenderson','Henderson','William','William Henderson','Advising','whenderson@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('whenderson','community'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('ddavis','Davis','David','David Davis','Computer Science','ddavis@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('ddavis','staff'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('cmorrison','Morrison','Colin','Colin Morrison','Financial Aid','cmorrison@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('cmorrison','member'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('cmorrison','faculty'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('danderson','Anderson','Donna','Donna Anderson','Account Payable','danderson@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('danderson','member'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('amorrison','Morrison','Ann','Ann Morrison','Law','amorrison@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('amorrison','student'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('amorrison','alum'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('wprice','Price','William','William Price','Account Payable','wprice@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('wprice','community'); +INSERT INTO SIS_PERSONS (uid, surname, givenName, fullName, department, mail) VALUES ('mroberts','Roberts','Marie','Marie Roberts','Law','mroberts@example.edu'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('mroberts','student'); +INSERT INTO SIS_AFFILIATIONS (uid, affiliation) VALUES ('mroberts','community'); diff --git a/library.bash b/library.bash index a042733..01d60ad 100644 --- a/library.bash +++ b/library.bash @@ -84,7 +84,7 @@ function add_object () { # TODO check if the result is valid (i.e. not an error) - return 1 if invalid, otherwise return 0 ("no objects" is considered OK here) function search_objects_by_name () { TYPE=$1 - NAME=$2 + NAME="$2" TMPFILE=$(mktemp /tmp/search.XXXXXX) curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE/search" -d @- << EOF >$TMPFILE || (rm $TMPFILE ; return 1) @@ -105,8 +105,8 @@ EOF # Searches for object with a given name and verifies it was found function search_and_check_object () { local TYPE=$1 - local NAME=$2 - search_objects_by_name $TYPE $NAME || return 1 + local NAME="$2" + search_objects_by_name $TYPE "$NAME" || return 1 if (grep -q "$NAME" <$SEARCH_RESULT_FILE); then echo "Object $TYPE/'$NAME' is OK" rm $SEARCH_RESULT_FILE @@ -123,9 +123,8 @@ function search_and_check_object () { function test_resource () { local OID=$1 local TMPFILE=$(mktemp /tmp/test.resource.XXXXXX) - local TMPFILE_ERR=$(mktemp /tmp/test.resource.err.XXXXXX) - curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE $TMPFILE_ERR ; return 1) + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/resources/$OID/test" >$TMPFILE || (rm $TMPFILE ; return 1) if [[ $(xmllint --xpath "/*/*[local-name()='status']/text()" $TMPFILE) == "success" ]]; then echo "Resource $OID test succeeded" rm $TMPFILE @@ -138,6 +137,14 @@ function test_resource () { fi } -function get_xpath () { - echo ok +function assert_task_success () { + local OID=$1 + # TODO + return 0 +} + +function wait_for_task_completion () { + local OID=$1 + sleep 60 # TODO + return 0 } From baca108dd0c49160832a6cd9e7b6a4347f4be73a Mon Sep 17 00:00:00 2001 From: skublik Date: Fri, 28 Sep 2018 15:50:37 +0000 Subject: [PATCH 39/73] adding of waiting and check functions for shibboleth idp --- demo/complex/tests/main.bats | 8 +++++++- library.bash | 40 +++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 89b08f4..129bfa9 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -20,15 +20,21 @@ load ../../../library @test "020 Wait until components are started" { touch $BATS_TMPDIR/not-started wait_for_midpoint_start complex_midpoint-server_1 + wait_for_shibboleth_idp_start complex_idp_1 rm $BATS_TMPDIR/not-started # TODO wait for shibboleth, grouper-ui, (also something other?) } -@test "050 Check midPoint health" { +@test "040 Check midPoint health" { if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi check_health } +@test "050 Check Shibboleth IDP health" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi + check_health_shibboleth_idp +} + @test "060 Check Grouper health" { if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi skip TODO diff --git a/library.bash b/library.bash index 9ed8046..5d093a3 100644 --- a/library.bash +++ b/library.bash @@ -8,7 +8,7 @@ function wait_for_midpoint_start () { CONTAINER_NAME=$1 ATTEMPT=0 - MAX_ATTEMPTS=20 + MAX_ATTEMPTS=30 DELAY=10 until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do @@ -26,6 +26,29 @@ function wait_for_midpoint_start () { return 1 } +# Waits until Shibboleth IDP starts +function wait_for_shibboleth_idp_start () { + CONTAINER_NAME=$1 + ATTEMPT=0 + MAX_ATTEMPTS=20 + DELAY=10 + + until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do + ATTEMPT=$((ATTEMPT+1)) + echo "Waiting $DELAY seconds for Shibboleth IDP to start (attempt $ATTEMPT) ..." + sleep $DELAY + docker ps + ( docker logs $CONTAINER_NAME 2>&1 | grep "INFO:oejs.Server:main: Started" ) && return 0 + done + + echo Shibboleth IDP did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME + echo "========== Container log ==========" + docker logs $CONTAINER_NAME 2>&1 + echo "========== End of the container log ==========" + return 1 +} + + # Checks the health of midPoint server function check_health () { echo Checking health... @@ -41,6 +64,21 @@ function check_health () { fi } +# Checks the health of Shibboleth IDP server +function check_health_shibboleth_idp () { + echo Checking health of shibboleth idp... + status="$(curl -k --write-out %{http_code} --silent --output /dev/null https://localhost:4443/idp/)" + if [ $status -ne 200 ]; then + echo Error: Http code of response is $status + docker ps + return 1 + else + echo OK + return 0 + fi +} + + # Retrieves XML object and checks if the name matches function get_and_check_object () { TYPE=$1 From 79317310259bb08b9c3025d7aea58d1df94325f1 Mon Sep 17 00:00:00 2001 From: skublik Date: Fri, 28 Sep 2018 15:58:47 +0000 Subject: [PATCH 40/73] back MAX_ATTEMPTS value --- library.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.bash b/library.bash index a8df430..0d2e857 100644 --- a/library.bash +++ b/library.bash @@ -9,7 +9,7 @@ function wait_for_midpoint_start () { CONTAINER_NAME=$1 DATABASE_CONTAINER_NAME=$2 ATTEMPT=0 - MAX_ATTEMPTS=30 + MAX_ATTEMPTS=20 DELAY=10 until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do From 71a560730141c78f69d9e3cc80b406fb4340b88c Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Sat, 29 Sep 2018 02:36:16 +0200 Subject: [PATCH 41/73] Add DB schema version check Also disabled auto-restart of midPoint (causes problems if midPoint cannot be started). --- build.sh | 2 +- container_files/supervisor/supervisord.conf | 2 +- demo/simple/tests/main.bats | 13 +++++++++ library.bash | 30 ++++++++++++++------- 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index b59e4ed..eb1b7dc 100755 --- a/build.sh +++ b/build.sh @@ -30,7 +30,7 @@ echo "" echo "(for simple demo)" echo "" echo "$ cd" $(normalize_path `pwd`/../demo/simple) -echo "$ docker-compose up --build" +echo "$ docker-compose up" echo "" echo "(for complex demo)" echo "" diff --git a/container_files/supervisor/supervisord.conf b/container_files/supervisor/supervisord.conf index d0d91e2..8619f53 100644 --- a/container_files/supervisor/supervisord.conf +++ b/container_files/supervisor/supervisord.conf @@ -16,10 +16,10 @@ command=/bin/bash -c "/usr/local/bin/start-midpoint.sh" stdout_logfile=/dev/fd/2 stdout_logfile_maxbytes=0 redirect_stderr=true +autorestart=false [program:crond] command=/usr/sbin/crond -n -i -m off stdout_logfile=/tmp/logcrond stdout_logfile_maxbytes=0 redirect_stderr=true -autorestart=false diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats index 9b07272..16e6ca5 100755 --- a/demo/simple/tests/main.bats +++ b/demo/simple/tests/main.bats @@ -50,6 +50,19 @@ load ../../../library search_and_check_object users test300 } +@test "350 Test DB schema version check" { + echo "Removing version information from m_global_metadata" + docker exec simple_midpoint-data_1 mysql -p123321 registry -e "delete from m_global_metadata" + + echo "Bringing the containers down" + docker-compose down + + echo "Re-creating the containers" + docker-compose up -d + + wait_for_log_message simple_midpoint-server_1 "com.evolveum.midpoint.util.exception.SystemException: Existing database schema version could not be determined" +} + @test "999 Clean up" { docker-compose down -v } diff --git a/library.bash b/library.bash index 01d60ad..9aea37a 100644 --- a/library.bash +++ b/library.bash @@ -4,34 +4,46 @@ # Contains common functions usable for midPoint system tests # -# Waits until midPoint starts -function wait_for_midpoint_start () { +# do not use from outside (ugly signature) +function generic_wait_for_log () { CONTAINER_NAME=$1 - DATABASE_CONTAINER_NAME=$2 + MESSAGE="$2" + WAITING_FOR="$3" + FAILURE="$4" + ADDITIONAL_CONTAINER_NAME=$5 ATTEMPT=0 MAX_ATTEMPTS=20 DELAY=10 until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do ATTEMPT=$((ATTEMPT+1)) - echo "Waiting $DELAY seconds for midPoint to start (attempt $ATTEMPT) ..." + echo "Waiting $DELAY seconds for $WAITING_FOR (attempt $ATTEMPT) ..." sleep $DELAY docker ps - ( docker logs $CONTAINER_NAME 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && return 0 + ( docker logs $CONTAINER_NAME 2>&1 | grep "$MESSAGE" ) && return 0 done - echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME + echo "$FAILURE" in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME echo "========== Container log ==========" docker logs $CONTAINER_NAME 2>&1 echo "========== End of the container log ==========" - if [ -n "$DATABASE_CONTAINER_NAME" ]; then - echo "========== Container log ($DATABASE_CONTAINER_NAME) ==========" - docker logs $DATABASE_CONTAINER_NAME 2>&1 + if [ -n "ADDITIONAL_CONTAINER_NAME" ]; then + echo "========== Container log ($ADDITIONAL_CONTAINER_NAME) ==========" + docker logs $ADDITIONAL_CONTAINER_NAME 2>&1 echo "========== End of the container log ($DATABASE_CONTAINER_NAME) ==========" fi return 1 } +function wait_for_log_message () { + generic_wait_for_log $1 "$2" "log message" "log message has not appeared" +} + +# Waits until midPoint starts +function wait_for_midpoint_start () { + generic_wait_for_log $1 "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" "midPoint to start" "midPoint did not start" $2 +} + # Checks the health of midPoint server function check_health () { echo Checking health... From 4c5e8955a2271d9450e31184be93ae5c6a7db0c6 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Sun, 30 Sep 2018 01:21:51 +0200 Subject: [PATCH 42/73] Adapt test to midpoint change --- demo/simple/tests/main.bats | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats index 16e6ca5..c7a4ca8 100755 --- a/demo/simple/tests/main.bats +++ b/demo/simple/tests/main.bats @@ -52,7 +52,7 @@ load ../../../library @test "350 Test DB schema version check" { echo "Removing version information from m_global_metadata" - docker exec simple_midpoint-data_1 mysql -p123321 registry -e "delete from m_global_metadata" + docker exec simple_midpoint-data_1 mysql -p123321 registry -e "drop table m_global_metadata" echo "Bringing the containers down" docker-compose down @@ -60,7 +60,7 @@ load ../../../library echo "Re-creating the containers" docker-compose up -d - wait_for_log_message simple_midpoint-server_1 "com.evolveum.midpoint.util.exception.SystemException: Existing database schema version could not be determined" + wait_for_log_message simple_midpoint-server_1 "Database schema is not compatible with the executing code; however, an upgrade path is available." } @test "999 Clean up" { From ceafa77a75096781e1e9191372f7f08ebe567754 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 1 Oct 2018 17:07:51 +0200 Subject: [PATCH 43/73] Add auto-upgrade support --- Dockerfile | 2 + .../usr-local-bin/start-midpoint.sh | 13 ++-- demo/complex/.env | 2 + demo/complex/docker-compose.yml | 73 +------------------ demo/simple/.env | 1 + demo/simple/docker-compose.yml | 4 + demo/simple/tests/main.bats | 21 ++++++ 7 files changed, 39 insertions(+), 77 deletions(-) diff --git a/Dockerfile b/Dockerfile index 27b026b..6b1b804 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,6 +68,8 @@ ENV REPO_DATABASE midpoint ENV REPO_JDBC_URL default ENV REPO_PASSWORD_FILE /run/secrets/m_database_password.txt ENV REPO_DATABASE_TYPE mariadb +ENV REPO_MISSING_SCHEMA_ACTION create +ENV REPO_UPGRADEABLE_SCHEMA_ACTION stop # Logging parameters diff --git a/container_files/usr-local-bin/start-midpoint.sh b/container_files/usr-local-bin/start-midpoint.sh index 856f34e..da47e3a 100755 --- a/container_files/usr-local-bin/start-midpoint.sh +++ b/container_files/usr-local-bin/start-midpoint.sh @@ -1,11 +1,5 @@ #!/bin/bash -if [ "$AUTHENTICATION" = "shibboleth" ]; then - LOGOUT_URL_DIRECTIVE="-Dauth.logout.url=$LOGOUT_URL" -else - LOGOUT_URL_DIRECTIVE= -fi - java -Xmx$MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dmidpoint.home=$MP_DIR/var \ -Dmidpoint.repository.database=$REPO_DATABASE_TYPE \ @@ -13,7 +7,10 @@ java -Xmx$MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dmidpoint.repository.jdbcPassword_FILE=$REPO_PASSWORD_FILE \ -Dmidpoint.repository.jdbcUrl="`$MP_DIR/repository-url`" \ -Dmidpoint.repository.hibernateHbm2ddl=none \ - -Dmidpoint.repository.missingSchemaAction=create \ + -Dmidpoint.repository.missingSchemaAction=$REPO_MISSING_SCHEMA_ACTION \ + -Dmidpoint.repository.upgradeableSchemaAction=$REPO_UPGRADEABLE_SCHEMA_ACTION \ + $(if [ -n "$REPO_SCHEMA_VERSION_IF_MISSING" ]; then echo "-Dmidpoint.repository.schemaVersionIfMissing=$REPO_SCHEMA_VERSION_IF_MISSING"; fi) \ + $(if [ -n "$REPO_SCHEMA_VARIANT" ]; then echo "-Dmidpoint.repository.schemaVariant=$REPO_SCHEMA_VARIANT"; fi) \ -Dmidpoint.repository.initializationFailTimeout=60000 \ -Dmidpoint.keystore.keyStorePassword_FILE=$KEYSTORE_PASSWORD_FILE \ -Dmidpoint.logging.alt.enabled=true \ @@ -21,7 +18,7 @@ java -Xmx$MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dmidpoint.logging.alt.timezone=UTC \ -Dspring.profiles.active="`$MP_DIR/active-spring-profiles`" \ -Dauth.sso.header=$SSO_HEADER \ - $LOGOUT_URL_DIRECTIVE \ + $(if [ "$AUTHENTICATION" = "shibboleth" ]; then echo "-Dauth.logout.url=$LOGOUT_URL"; fi) \ -Dserver.tomcat.ajp.enabled=$AJP_ENABLED \ -Dserver.tomcat.ajp.port=$AJP_PORT \ -Dlogging.path=/tmp/logtomcat \ diff --git a/demo/complex/.env b/demo/complex/.env index ce20478..cabe686 100644 --- a/demo/complex/.env +++ b/demo/complex/.env @@ -7,6 +7,8 @@ REPO_HOST=midpoint-data REPO_PORT=default REPO_DATABASE=registry REPO_USER=registry_user +REPO_MISSING_SCHEMA_ACTION=create +REPO_UPGRADEABLE_SCHEMA_ACTION=stop REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt KEYSTORE_PASSWORD_FILE=/run/secrets/m_keystore_password.txt MEM=2048m diff --git a/demo/complex/docker-compose.yml b/demo/complex/docker-compose.yml index 8e16c92..bd2fb36 100644 --- a/demo/complex/docker-compose.yml +++ b/demo/complex/docker-compose.yml @@ -84,75 +84,6 @@ services: source: ./configs-and-secrets/grouper/httpd/host-cert.pem target: /etc/pki/tls/certs/cachain.pem - -# grouper-ws: -# build: ./grouper-ws/ -# command: bash -c "while ! curl -s grouper-data:3306 > /dev/null; do echo waiting for mysql on grouper-data to start; sleep 3; done; while ! curl -s ldap://directory:389 > /dev/null; do echo waiting for ldap on directory to start; sleep 3; done; exec ws" -# depends_on: -# - grouper-data -# - directory -# environment: -# - ENV=dev -# - GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/g_database_password.txt -# - SUBJECT_SOURCE_LDAP_PASSWORD=password -# - USERTOKEN=build-2 -# networks: -# - back -# ports: -# - "8443:443" -# secrets: -# - g_database_password.txt -# - source: grouper.hibernate.properties -# target: grouper_grouper.hibernate.properties -# - source: grouper-loader.properties -# target: grouper_grouper-loader.properties -# - source: subject.properties -# target: grouper_subject.properties -# - source: sp-key.pem -# target: shib_sp-key.pem -# - source: host-key.pem -# volumes: -# - type: bind -# source: ./configs-and-secrets/grouper/grouper.properties -# target: /opt/grouper/conf/grouper.properties -# - type: bind -# source: ./configs-and-secrets/grouper/grouper.client.properties -# target: /opt/grouper/conf/grouper.client.properties -# - type: bind -# source: ./configs-and-secrets/httpd/host-cert.pem -# target: /etc/pki/tls/certs/host-cert.pem -# - type: bind -# source: ./configs-and-secrets/httpd/host-cert.pem -# target: /etc/pki/tls/certs/cachain.pem -# -# gsh: -# build: ./gsh/ -# depends_on: -# - grouper-data -# - directory -# environment: -# - ENV=dev -# - GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/g_database_password.txt -# - SUBJECT_SOURCE_LDAP_PASSWORD=password -# - USERTOKEN=build-2 -# networks: -# - back -# secrets: -# - g_database_password.txt -# - source: grouper.hibernate.properties -# target: grouper_grouper.hibernate.properties -# - source: grouper-loader.properties -# target: grouper_grouper-loader.properties -# - source: subject.properties -# target: grouper_subject.properties -# volumes: -# - type: bind -# source: ./configs-and-secrets/grouper/grouper.properties -# target: /opt/grouper/conf/grouper.properties -# - type: bind -# source: ./configs-and-secrets/grouper/grouper.client.properties -# target: /opt/grouper/conf/grouper.client.properties - grouper-data: build: ./grouper-data/ networks: @@ -215,6 +146,10 @@ services: - REPO_DATABASE - REPO_USER - REPO_PASSWORD_FILE + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT - KEYSTORE_PASSWORD_FILE - MEM - SSO_HEADER diff --git a/demo/simple/.env b/demo/simple/.env index 2c8a3e3..25f5a2d 100644 --- a/demo/simple/.env +++ b/demo/simple/.env @@ -8,4 +8,5 @@ REPO_HOST=midpoint-data REPO_PORT=default REPO_DATABASE=registry REPO_USER=registry_user +REPO_MISSING_SCHEMA_ACTION=create MEM=2048m diff --git a/demo/simple/docker-compose.yml b/demo/simple/docker-compose.yml index 924f2e2..e80734f 100644 --- a/demo/simple/docker-compose.yml +++ b/demo/simple/docker-compose.yml @@ -27,6 +27,10 @@ services: - REPO_PORT - REPO_DATABASE - REPO_USER + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT - MEM - TIER_BEACON_OPT_OUT networks: diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats index c7a4ca8..664cc22 100755 --- a/demo/simple/tests/main.bats +++ b/demo/simple/tests/main.bats @@ -63,6 +63,27 @@ load ../../../library wait_for_log_message simple_midpoint-server_1 "Database schema is not compatible with the executing code; however, an upgrade path is available." } +@test "360 Test DB schema upgrade" { + echo "Stopping midpoint-server container" + docker stop simple_midpoint-server_1 + + echo "Installing empty 3.8 repository" + docker exec simple_midpoint-data_1 mysql -p123321 -e "DROP DATABASE registry" + docker exec simple_midpoint-data_1 bash -c " curl https://raw.githubusercontent.com/Evolveum/midpoint/v3.8/config/sql/_all/mysql-3.8-all-utf8mb4.sql > /tmp/create-3.8-utf8mb4.sql" + docker exec simple_midpoint-data_1 mysql -p123321 -e "CREATE DATABASE IF NOT EXISTS registry;" + docker exec simple_midpoint-data_1 mysql -p123321 -e "GRANT ALL ON registry.* TO 'registry_user'@'%' IDENTIFIED BY 'WJzesbe3poNZ91qIbmR7' ;" + docker exec simple_midpoint-data_1 bash -c "mysql -p123321 registry < /tmp/create-3.8-utf8mb4.sql" + + echo "Bringing the containers down" + docker-compose down + + echo "Re-creating the containers" + env REPO_SCHEMA_VERSION_IF_MISSING=3.8 REPO_UPGRADEABLE_SCHEMA_ACTION=upgrade REPO_SCHEMA_VARIANT=utf8mb4 docker-compose up -d + + wait_for_log_message simple_midpoint-server_1 "Schema was successfully upgraded from 3.8 to 3.9 using script 'mysql-upgrade-3.8-3.9-utf8mb4.sql'" + wait_for_midpoint_start simple_midpoint-server_1 +} + @test "999 Clean up" { docker-compose down -v } From 2d8dee228aa84812c32b6c2460364bfdc9c86d61 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 1 Oct 2018 17:28:55 +0200 Subject: [PATCH 44/73] Add assert_task_success method --- library.bash | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/library.bash b/library.bash index a8d5561..0aa34fe 100644 --- a/library.bash +++ b/library.bash @@ -67,7 +67,6 @@ function wait_for_shibboleth_idp_start () { return 1 } - # Checks the health of midPoint server function check_health () { echo Checking health... @@ -98,6 +97,15 @@ function check_health_shibboleth_idp () { } +function get_object () { + local TYPE=$1 + local OID=$2 + TMPFILE=$(mktemp /tmp/get.XXXXXX) + echo tmp file is $TMPFILE + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$TMPFILE || (rm $TMPFILE ; return 1) + return 0 +} + # Retrieves XML object and checks if the name matches function get_and_check_object () { TYPE=$1 @@ -190,8 +198,18 @@ function test_resource () { function assert_task_success () { local OID=$1 - # TODO - return 0 + get_object tasks $OID + TASK_STATUS=$(xmllint --xpath "/*/*[local-name()='resultStatus']/text()" $TMPFILE) || (echo "Couldn't extract task status from task $OID" ; cat $TMPFILE ; rm $TMPFILE ; return 1) + if [[ $TASK_STATUS = "success" ]]; then + echo "Task $OID status is OK" + rm $TMPFILE + return 0 + else + echo "Task $OID status is not OK: $TASK_STATUS" + cat $TMPFILE + rm $TMPFILE + return 1 + fi } function wait_for_task_completion () { From 3fe1f67c291b96588104eede92800a0ed1456815 Mon Sep 17 00:00:00 2001 From: skublik Date: Mon, 1 Oct 2018 18:58:44 +0000 Subject: [PATCH 45/73] adding validation for function --- library.bash | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/library.bash b/library.bash index a8d5561..e0e0f57 100644 --- a/library.bash +++ b/library.bash @@ -125,9 +125,31 @@ function add_object () { local TYPE=$1 local FILE=$2 echo "Adding to $TYPE from $FILE..." - curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE || return 1 + + response=$(curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE) + http_code=$(sed '$!d' <<<"$response") + + if [ "$http_code" -eq 201 ]; then + headers=$(sed -n '1,/^\r$/p' <<<"$response") + + # get the real Location + location=$(grep -oP 'Location: \K.*' <<<"$headers") + oid=$(sed 's/.*\///' <<<"$location") + + echo "Oid created object: $oid" + return 0 + else + echo "Error code: $http_code" + if [ "$http_code" -eq 500 ]; then + echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." + else + error_message=$(grep 'message' <<<"$response" | head -1 | awk -F">" '{print $2}' | awk -F"<" '{print $1}') + echo "Error message: $error_message" + fi + return 1 + fi + #curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE || return 1 #TODO check the returned XML - return 0 } # Tries to find an object with a given name @@ -138,7 +160,7 @@ function search_objects_by_name () { NAME="$2" TMPFILE=$(mktemp /tmp/search.XXXXXX) - curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE/search" -d @- << EOF >$TMPFILE || (rm $TMPFILE ; return 1) + curl -k --write-out %{http_code} --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE/search" -d @- << EOF >$TMPFILE || (rm $TMPFILE ; return 1) @@ -149,8 +171,16 @@ function search_objects_by_name () { EOF SEARCH_RESULT_FILE=$TMPFILE - # TODO check validity of the file - return 0 + + http_code=$(sed '$!d' <<<"$(cat $SEARCH_RESULT_FILE)") + + sed -i '$ d' $SEARCH_RESULT_FILE + cat $SEARCH_RESULT_FILE + if [ "$http_code" -eq 200 ]; then + return 0 + else + return 1 + fi } # Searches for object with a given name and verifies it was found From 9b1a4d7376ac69465195245ec463be9516cb5d9c Mon Sep 17 00:00:00 2001 From: skublik Date: Mon, 1 Oct 2018 19:54:06 +0000 Subject: [PATCH 46/73] adding condition for response 202 --- library.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.bash b/library.bash index 50c9cc6..0b2172f 100644 --- a/library.bash +++ b/library.bash @@ -137,7 +137,7 @@ function add_object () { response=$(curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE) http_code=$(sed '$!d' <<<"$response") - if [ "$http_code" -eq 201 ]; then + if [ "$http_code" -eq 201 ] || [ "$http_code" -eq 202 ]; then headers=$(sed -n '1,/^\r$/p' <<<"$response") # get the real Location From 7b809045aef9c5578f383ca25e695c11b58e0b26 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 1 Oct 2018 22:59:27 +0200 Subject: [PATCH 47/73] Fix build.sh The demo directories were shown incorrectly. --- build.sh | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index eb1b7dc..783e3bf 100755 --- a/build.sh +++ b/build.sh @@ -1,18 +1,5 @@ #!/bin/bash -function normalize_path() -{ - # Remove all /./ sequences. - local path=${1//\/.\//\/} - - # Remove dir/.. sequences. - while [[ $path =~ ([^/][^/]*/\.\./) ]] - do - path=${path/${BASH_REMATCH[0]}/} - done - echo $path -} - cd "$(dirname "$0")" SKIP_DOWNLOAD=0 while getopts "nh?" opt; do @@ -29,10 +16,10 @@ echo "The midPoint containers were successfully built. To start them, execute th echo "" echo "(for simple demo)" echo "" -echo "$ cd" $(normalize_path `pwd`/../demo/simple) +echo "$ cd" $(pwd)/demo/simple echo "$ docker-compose up" echo "" echo "(for complex demo)" echo "" -echo "$ cd" $(normalize_path `pwd`/../demo/complex) +echo "$ cd" $(pwd)/demo/complex echo "$ docker-compose up --build" From e893b3e7c4535e563168d285b1de6971f5e53c6e Mon Sep 17 00:00:00 2001 From: skublik Date: Mon, 1 Oct 2018 21:41:13 +0000 Subject: [PATCH 48/73] removing mistake --- library.bash | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library.bash b/library.bash index 0b2172f..a66144e 100644 --- a/library.bash +++ b/library.bash @@ -138,11 +138,10 @@ function add_object () { http_code=$(sed '$!d' <<<"$response") if [ "$http_code" -eq 201 ] || [ "$http_code" -eq 202 ]; then - headers=$(sed -n '1,/^\r$/p' <<<"$response") - + # get the real Location - location=$(grep -oP 'Location: \K.*' <<<"$headers") - oid=$(sed 's/.*\///' <<<"$location") + location=$(grep -oP "Location: \K.*" <<<"$response") + oid=$(sed 's/.*\///' <<<"$location") echo "Oid created object: $oid" return 0 From 8ee694b7daecab75c15c6db50f96b57beda19b2d Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Mon, 1 Oct 2018 23:43:46 +0200 Subject: [PATCH 49/73] Do naming cleanup Environmental variables and container names are improved. Only demo/simple is OK now; other ones are inconsistent now. --- Dockerfile | 18 +++--- Jenkinsfile | 6 +- container_files/usr-local-bin/start-httpd.sh | 4 +- .../usr-local-bin/start-midpoint.sh | 6 +- demo/simple/.env | 4 +- demo/simple/docker-compose.yml | 28 ++++----- demo/simple/tests/main.bats | 26 ++++---- midpoint-obsolete/README.md | 9 --- midpoint-obsolete/build.sh | 30 --------- midpoint-obsolete/cleanup.sh | 6 -- midpoint-obsolete/test-root.sh | 15 ----- midpoint-obsolete/test.sh | 51 --------------- midpoint-obsolete/test/common.sh | 62 ------------------- midpoint-obsolete/test/t010-wait-for-start.sh | 16 ----- midpoint-obsolete/test/t100-check-health.sh | 3 - .../test/t110-get-administrator.sh | 8 --- midpoint-obsolete/test/t120-add-get-user.sh | 28 --------- midpoint-obsolete/test/t200-stop-start.sh | 21 ------- .../test/t300-repository-preservation.sh | 58 ----------------- 19 files changed, 47 insertions(+), 352 deletions(-) delete mode 100644 midpoint-obsolete/README.md delete mode 100755 midpoint-obsolete/build.sh delete mode 100755 midpoint-obsolete/cleanup.sh delete mode 100755 midpoint-obsolete/test-root.sh delete mode 100755 midpoint-obsolete/test.sh delete mode 100755 midpoint-obsolete/test/common.sh delete mode 100755 midpoint-obsolete/test/t010-wait-for-start.sh delete mode 100755 midpoint-obsolete/test/t100-check-health.sh delete mode 100755 midpoint-obsolete/test/t110-get-administrator.sh delete mode 100755 midpoint-obsolete/test/t120-add-get-user.sh delete mode 100755 midpoint-obsolete/test/t200-stop-start.sh delete mode 100755 midpoint-obsolete/test/t300-repository-preservation.sh diff --git a/Dockerfile b/Dockerfile index 6b1b804..4d3a318 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,13 +61,13 @@ VOLUME ${MP_DIR}/var # Repository parameters -ENV REPO_HOST midpoint-data -ENV REPO_PORT default -ENV REPO_USER root -ENV REPO_DATABASE midpoint -ENV REPO_JDBC_URL default -ENV REPO_PASSWORD_FILE /run/secrets/m_database_password.txt ENV REPO_DATABASE_TYPE mariadb +ENV REPO_JDBC_URL default +ENV REPO_HOST midpoint_data +ENV REPO_PORT default +ENV REPO_DATABASE registry +ENV REPO_USER registry_user +ENV REPO_PASSWORD_FILE /run/secrets/mp_database_password.txt ENV REPO_MISSING_SCHEMA_ACTION create ENV REPO_UPGRADEABLE_SCHEMA_ACTION stop @@ -82,12 +82,12 @@ ENV AUTHENTICATION internal ENV SSO_HEADER uid ENV AJP_ENABLED true ENV AJP_PORT 9090 -ENV LOGOUT_URL https://localhost:8443/Shibboleth.sso/Logout +ENV MP_LOGOUT_URL https://localhost:8443/Shibboleth.sso/Logout # Other parameters -ENV KEYSTORE_PASSWORD_FILE /run/secrets/m_keystore_password.txt -ENV MEM 2048m +ENV MP_KEYSTORE_PASSWORD_FILE /run/secrets/mp_keystore_password.txt +ENV MP_MEM 2048m ENV TIER_RELEASE not-released-yet ENV TIER_MAINTAINER tier diff --git a/Jenkinsfile b/Jenkinsfile index c270952..b29363f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,8 +56,10 @@ pipeline { sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + + // temporarily disabled + //sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + //sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // sh 'echo Test output ; cat debug' } catch (error) { diff --git a/container_files/usr-local-bin/start-httpd.sh b/container_files/usr-local-bin/start-httpd.sh index 8dd3583..c386df4 100755 --- a/container_files/usr-local-bin/start-httpd.sh +++ b/container_files/usr-local-bin/start-httpd.sh @@ -1,8 +1,8 @@ #!/bin/bash echo "Linking secrets and config files; using authentication: $AUTHENTICATION" -ln -sf /run/secrets/m_sp-key.pem /etc/shibboleth/sp-key.pem -ln -sf /run/secrets/m_host-key.pem /etc/pki/tls/private/host-key.pem +ln -sf /run/secrets/mp_sp-key.pem /etc/shibboleth/sp-key.pem +ln -sf /run/secrets/mp_host-key.pem /etc/pki/tls/private/host-key.pem ln -sf /etc/httpd/conf.d/midpoint.conf.auth.$AUTHENTICATION /etc/httpd/conf.d/midpoint.conf httpd-shib-foreground diff --git a/container_files/usr-local-bin/start-midpoint.sh b/container_files/usr-local-bin/start-midpoint.sh index da47e3a..ed7b13b 100755 --- a/container_files/usr-local-bin/start-midpoint.sh +++ b/container_files/usr-local-bin/start-midpoint.sh @@ -1,6 +1,6 @@ #!/bin/bash -java -Xmx$MEM -Xms2048m -Dfile.encoding=UTF8 \ +java -Xmx$MP_MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dmidpoint.home=$MP_DIR/var \ -Dmidpoint.repository.database=$REPO_DATABASE_TYPE \ -Dmidpoint.repository.jdbcUsername=$REPO_USER \ @@ -12,13 +12,13 @@ java -Xmx$MEM -Xms2048m -Dfile.encoding=UTF8 \ $(if [ -n "$REPO_SCHEMA_VERSION_IF_MISSING" ]; then echo "-Dmidpoint.repository.schemaVersionIfMissing=$REPO_SCHEMA_VERSION_IF_MISSING"; fi) \ $(if [ -n "$REPO_SCHEMA_VARIANT" ]; then echo "-Dmidpoint.repository.schemaVariant=$REPO_SCHEMA_VARIANT"; fi) \ -Dmidpoint.repository.initializationFailTimeout=60000 \ - -Dmidpoint.keystore.keyStorePassword_FILE=$KEYSTORE_PASSWORD_FILE \ + -Dmidpoint.keystore.keyStorePassword_FILE=$MP_KEYSTORE_PASSWORD_FILE \ -Dmidpoint.logging.alt.enabled=true \ -Dmidpoint.logging.alt.filename=/tmp/logmidpoint \ -Dmidpoint.logging.alt.timezone=UTC \ -Dspring.profiles.active="`$MP_DIR/active-spring-profiles`" \ -Dauth.sso.header=$SSO_HEADER \ - $(if [ "$AUTHENTICATION" = "shibboleth" ]; then echo "-Dauth.logout.url=$LOGOUT_URL"; fi) \ + $(if [ "$AUTHENTICATION" = "shibboleth" ]; then echo "-Dauth.logout.url=$MP_LOGOUT_URL"; fi) \ -Dserver.tomcat.ajp.enabled=$AJP_ENABLED \ -Dserver.tomcat.ajp.port=$AJP_PORT \ -Dlogging.path=/tmp/logtomcat \ diff --git a/demo/simple/.env b/demo/simple/.env index 25f5a2d..2cc995d 100644 --- a/demo/simple/.env +++ b/demo/simple/.env @@ -4,9 +4,9 @@ ENV=demo USERTOKEN= REPO_DATABASE_TYPE=mariadb REPO_JDBC_URL=default -REPO_HOST=midpoint-data +REPO_HOST=midpoint_data REPO_PORT=default REPO_DATABASE=registry REPO_USER=registry_user REPO_MISSING_SCHEMA_ACTION=create -MEM=2048m +MP_MEM=2048m diff --git a/demo/simple/docker-compose.yml b/demo/simple/docker-compose.yml index e80734f..7658907 100644 --- a/demo/simple/docker-compose.yml +++ b/demo/simple/docker-compose.yml @@ -1,19 +1,19 @@ version: "3.3" services: - midpoint-data: + midpoint_data: image: tier/mariadb:mariadb10 ports: - 3306:3306 networks: - - back + - net volumes: - midpoint_mysql:/var/lib/mysql - midpoint_data:/var/lib/mysqlmounted environment: - CREATE_NEW_DATABASE=if_needed - midpoint-server: + midpoint_server: image: tier/midpoint:latest ports: - 8443:443 @@ -31,15 +31,15 @@ services: - REPO_UPGRADEABLE_SCHEMA_ACTION - REPO_SCHEMA_VERSION_IF_MISSING - REPO_SCHEMA_VARIANT - - MEM + - MP_MEM - TIER_BEACON_OPT_OUT networks: - - back + - net secrets: - - m_database_password.txt - - m_keystore_password.txt - - m_sp-key.pem - - m_host-key.pem + - mp_database_password.txt + - mp_keystore_password.txt + - mp_sp-key.pem + - mp_host-key.pem volumes: - midpoint_home:/opt/midpoint/var - type: bind @@ -59,17 +59,17 @@ services: target: /etc/pki/tls/certs/cachain.pem networks: - back: + net: driver: bridge secrets: - m_host-key.pem: + mp_host-key.pem: file: ./configs-and-secrets/midpoint/httpd/host-key.pem - m_sp-key.pem: + mp_sp-key.pem: file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem - m_database_password.txt: + mp_database_password.txt: file: ./configs-and-secrets/midpoint/application/database_password.txt - m_keystore_password.txt: + mp_keystore_password.txt: file: ./configs-and-secrets/midpoint/application/keystore_password.txt volumes: diff --git a/demo/simple/tests/main.bats b/demo/simple/tests/main.bats index 664cc22..1d0a671 100755 --- a/demo/simple/tests/main.bats +++ b/demo/simple/tests/main.bats @@ -9,7 +9,7 @@ load ../../../library @test "010 Initialize and start midPoint" { docker-compose up -d - wait_for_midpoint_start simple_midpoint-server_1 + wait_for_midpoint_start simple_midpoint_server_1 } @test "010 Check health" { @@ -44,7 +44,7 @@ load ../../../library echo "Re-creating the containers" docker-compose up --no-start docker-compose start - wait_for_midpoint_start simple_midpoint-server_1 + wait_for_midpoint_start simple_midpoint_server_1 echo "Searching for the user again" search_and_check_object users test300 @@ -52,7 +52,7 @@ load ../../../library @test "350 Test DB schema version check" { echo "Removing version information from m_global_metadata" - docker exec simple_midpoint-data_1 mysql -p123321 registry -e "drop table m_global_metadata" + docker exec simple_midpoint_data_1 mysql -p123321 registry -e "drop table m_global_metadata" echo "Bringing the containers down" docker-compose down @@ -60,19 +60,19 @@ load ../../../library echo "Re-creating the containers" docker-compose up -d - wait_for_log_message simple_midpoint-server_1 "Database schema is not compatible with the executing code; however, an upgrade path is available." + wait_for_log_message simple_midpoint_server_1 "Database schema is not compatible with the executing code; however, an upgrade path is available." } @test "360 Test DB schema upgrade" { - echo "Stopping midpoint-server container" - docker stop simple_midpoint-server_1 + echo "Stopping midpoint_server container" + docker stop simple_midpoint_server_1 echo "Installing empty 3.8 repository" - docker exec simple_midpoint-data_1 mysql -p123321 -e "DROP DATABASE registry" - docker exec simple_midpoint-data_1 bash -c " curl https://raw.githubusercontent.com/Evolveum/midpoint/v3.8/config/sql/_all/mysql-3.8-all-utf8mb4.sql > /tmp/create-3.8-utf8mb4.sql" - docker exec simple_midpoint-data_1 mysql -p123321 -e "CREATE DATABASE IF NOT EXISTS registry;" - docker exec simple_midpoint-data_1 mysql -p123321 -e "GRANT ALL ON registry.* TO 'registry_user'@'%' IDENTIFIED BY 'WJzesbe3poNZ91qIbmR7' ;" - docker exec simple_midpoint-data_1 bash -c "mysql -p123321 registry < /tmp/create-3.8-utf8mb4.sql" + docker exec simple_midpoint_data_1 mysql -p123321 -e "DROP DATABASE registry" + docker exec simple_midpoint_data_1 bash -c " curl https://raw.githubusercontent.com/Evolveum/midpoint/v3.8/config/sql/_all/mysql-3.8-all-utf8mb4.sql > /tmp/create-3.8-utf8mb4.sql" + docker exec simple_midpoint_data_1 mysql -p123321 -e "CREATE DATABASE IF NOT EXISTS registry;" + docker exec simple_midpoint_data_1 mysql -p123321 -e "GRANT ALL ON registry.* TO 'registry_user'@'%' IDENTIFIED BY 'WJzesbe3poNZ91qIbmR7' ;" + docker exec simple_midpoint_data_1 bash -c "mysql -p123321 registry < /tmp/create-3.8-utf8mb4.sql" echo "Bringing the containers down" docker-compose down @@ -80,8 +80,8 @@ load ../../../library echo "Re-creating the containers" env REPO_SCHEMA_VERSION_IF_MISSING=3.8 REPO_UPGRADEABLE_SCHEMA_ACTION=upgrade REPO_SCHEMA_VARIANT=utf8mb4 docker-compose up -d - wait_for_log_message simple_midpoint-server_1 "Schema was successfully upgraded from 3.8 to 3.9 using script 'mysql-upgrade-3.8-3.9-utf8mb4.sql'" - wait_for_midpoint_start simple_midpoint-server_1 + wait_for_log_message simple_midpoint_server_1 "Schema was successfully upgraded from 3.8 to 3.9 using script 'mysql-upgrade-3.8-3.9-utf8mb4.sql'" + wait_for_midpoint_start simple_midpoint_server_1 } @test "999 Clean up" { diff --git a/midpoint-obsolete/README.md b/midpoint-obsolete/README.md deleted file mode 100644 index bd1cfd4..0000000 --- a/midpoint-obsolete/README.md +++ /dev/null @@ -1,9 +0,0 @@ -This is a midPoint dockerization for TIER environment. It is a work in progress. - -# Building and execution -``` -$ ./build.sh -$ docker-compose up --build -``` - -Please see a detailed description [here](https://spaces.at.internet2.edu/display/MID/Dockerized+midPoint). diff --git a/midpoint-obsolete/build.sh b/midpoint-obsolete/build.sh deleted file mode 100755 index 4b53a25..0000000 --- a/midpoint-obsolete/build.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -function normalize_path() -{ - # Remove all /./ sequences. - local path=${1//\/.\//\/} - - # Remove dir/.. sequences. - while [[ $path =~ ([^/][^/]*/\.\./) ]] - do - path=${path/${BASH_REMATCH[0]}/} - done - echo $path -} - -cd "$(dirname "$0")" -./download-midpoint -docker build --tag tier/midpoint:latest midpoint-server -echo "---------------------------------------------------------------------------------------" -echo "The midPoint containers were successfully built. To start them, execute the following:" -echo "" -echo "(for standalone execution)" -echo "" -echo "$ cd" `pwd` -echo "$ docker-compose up --build" -echo "" -echo "(for complex demo)" -echo "" -echo "$ cd" $(normalize_path `pwd`/../demo/complex) -echo "$ docker-compose up --build" diff --git a/midpoint-obsolete/cleanup.sh b/midpoint-obsolete/cleanup.sh deleted file mode 100755 index b9fe089..0000000 --- a/midpoint-obsolete/cleanup.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -cd "$(dirname "$0")" -echo "Cleaning up containers and images in `pwd`" - -docker-compose down -v diff --git a/midpoint-obsolete/test-root.sh b/midpoint-obsolete/test-root.sh deleted file mode 100755 index 65527cf..0000000 --- a/midpoint-obsolete/test-root.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -. test/common.sh - -trap 'exitcode=$? ; error "Exiting test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR -yellow "**************************************************************************************" -yellow "*** Testing midPoint image ***" -yellow "**************************************************************************************" -echo -midpoint/test.sh -demo/shibboleth/test.sh -echo -lgreen "**************************************************************************************" -lgreen "*** All tests passed ***" -lgreen "**************************************************************************************" diff --git a/midpoint-obsolete/test.sh b/midpoint-obsolete/test.sh deleted file mode 100755 index 2570c4b..0000000 --- a/midpoint-obsolete/test.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash - -trap 'exitcode=$? ; error "Exiting midpoint/test.sh because of an error ($exitcode) occurred" ; exit $exitcode' ERR - -cd "$(dirname "$0")" -. ../test/common.sh - -heading "Cleaning up containers and volumes if they exist" -docker-compose down -v || true -ok "Done" -echo - -heading "Composing midPoint..." -docker-compose up --no-start -ok "midPoint composed OK" -echo - -heading "Starting midPoint..." -docker-compose start -ok "midPoint started OK" -echo - -heading "Test 010: Waiting for midPoint to start..." -test/t010-wait-for-start.sh -ok "midPoint started" -echo - -heading "Test 100: Checking health via HTTP..." -test/t100-check-health.sh -ok "Health check passed" -echo - -heading "Test 110: Getting user 'administrator'..." -test/t110-get-administrator.sh -ok "User 'administrator' retrieved and checked" -echo - -heading "Test 120: Adding and getting a user..." -test/t120-add-get-user.sh -ok "OK" -echo - -#heading "Test 200: Stop/start cycle..." -#test/t200-stop-start.sh -#ok "OK" -#echo - -heading "Test 300: Checking repository preservation across compose down/up..." -test/t300-repository-preservation.sh -ok "OK" -echo diff --git a/midpoint-obsolete/test/common.sh b/midpoint-obsolete/test/common.sh deleted file mode 100755 index 89c6130..0000000 --- a/midpoint-obsolete/test/common.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -BOLD='\033[1m' -UNDERLINE='\033[4m' -LRED='\033[1;31m' -LGREEN='\033[1;32m' -LCYAN='\033[1;36m' -YELLOW='\033[1;33m' -NC='\033[0m' - -function lred () { - if [ -z "$NOCOLOR" ]; then - echo -e "${LRED}$*${NC}" - else - echo "$*" - fi -} - -function lgreen () { - if [ -z "$NOCOLOR" ]; then - echo -e "${LGREEN}$*${NC}" - else - echo "$*" - fi -} - -function lcyan () { - if [ -z "$NOCOLOR" ]; then - echo -e "${LCYAN}$*${NC}" - else - echo "$*" - fi -} - -function yellow () { - if [ -z "$NOCOLOR" ]; then - echo -e "${YELLOW}$*${NC}" - else - echo "$*" - fi -} - -function boldUnderline () { - if [ -z "$NOCOLOR" ]; then - echo -e "${BOLD}${UNDERLINE}$*${NC}" - else - echo "$*" - fi -} - -function heading () { - lcyan "=== $*" -} - -function ok () { - lgreen "==> $*" -} - -function error () { - lred "$*" -} - diff --git a/midpoint-obsolete/test/t010-wait-for-start.sh b/midpoint-obsolete/test/t010-wait-for-start.sh deleted file mode 100755 index ddb7a92..0000000 --- a/midpoint-obsolete/test/t010-wait-for-start.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -ATTEMPT=0 -MAX_ATTEMPTS=20 -DELAY=10 - -until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do - ATTEMPT=$((ATTEMPT+1)) - echo "Waiting $DELAY seconds for midPoint to start (attempt $ATTEMPT) ..." - sleep $DELAY - docker ps - ( docker logs midpoint_midpoint-server_1 2>&1 | grep "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" ) && exit 0 -done - -echo midPoint did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds -exit 1 diff --git a/midpoint-obsolete/test/t100-check-health.sh b/midpoint-obsolete/test/t100-check-health.sh deleted file mode 100755 index c6e864c..0000000 --- a/midpoint-obsolete/test/t100-check-health.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -set -o pipefail ; curl -k -f https://localhost:8443/midpoint/actuator/health | tr -d '[:space:]' | grep -q "\"status\":\"UP\"" diff --git a/midpoint-obsolete/test/t110-get-administrator.sh b/midpoint-obsolete/test/t110-get-administrator.sh deleted file mode 100755 index 55d5a4f..0000000 --- a/midpoint-obsolete/test/t110-get-administrator.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR -. ../test/common.sh - -curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/users/00000000-0000-0000-0000-000000000002" >/tmp/admin.xml -grep -q "administrator" - test120 - -EOF -echo "OK" - -echo "Searching for user 'test120'..." -curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users/search" -d @- << EOF >/tmp/test120.xml - - - - name - test120 - - - -EOF -echo "OK" - -grep -q "test120" &1 | grep "ERROR Shibboleth.Listener : failed socket call (bind), result (98): Address already in use") && yellow "=== Address already in use! ===" && docker-compose down && docker-compose up --no-start && docker-compose start - -echo -echo "Getting user 'administrator'..." -test/t110-get-administrator.sh diff --git a/midpoint-obsolete/test/t300-repository-preservation.sh b/midpoint-obsolete/test/t300-repository-preservation.sh deleted file mode 100755 index 4fa95da..0000000 --- a/midpoint-obsolete/test/t300-repository-preservation.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -USER=test300 -trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR -. ../test/common.sh - -docker ps -echo Checking health before action -test/t100-check-health.sh -docker ps - -echo "Adding user '${USER}'..." -curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users" -d @- << EOF - - ${USER} - -EOF -echo "OK" - -echo "Searching for user '${USER}'..." -curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/users/search" -d @- << EOF >/tmp/${USER}.xml - - - - name - ${USER} - - - -EOF -echo "OK" - -grep -q "${USER}" /tmp/${USER}.xml - - - - name - ${USER} - - - -EOF -echo "OK" - -grep -q "${USER}" Date: Tue, 2 Oct 2018 00:07:44 +0200 Subject: [PATCH 50/73] Temporarily disable push step in Jenkinsfile This is to avoid collisions with the more stable build from the "bats" branch. --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b29363f..c1cb934 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,7 +71,7 @@ pipeline { } } } - stage ('Push') { +/* stage ('Push') { steps { script { docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { @@ -81,10 +81,11 @@ pipeline { } } } +*/ stage ('Notify') { steps { echo "$maintainer" - slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" + slackSend color: 'good', message: "$maintainer/$imagename:$tag built but NOT pushed to DockerHub (push temporarily disabled for this branch)" } } } From 32e0845e720acb42193dfbf2e1943d028426a119 Mon Sep 17 00:00:00 2001 From: skublik Date: Tue, 2 Oct 2018 19:34:43 +0000 Subject: [PATCH 51/73] adding test for LDAP Account --- demo/complex/tests/main.bats | 27 +++++- ...ign-role-grouper-sysadmin-to-test-user.xml | 33 +++++++ .../task/recom-role-grouper-sysadmin.xml | 27 ++++++ library.bash | 90 +++++++++++++++++-- 4 files changed, 168 insertions(+), 9 deletions(-) create mode 100644 demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml create mode 100644 demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index f980cdf..0568257 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -81,7 +81,7 @@ load ../../../library add_object tasks midpoint-objects-manual/tasks/task-import-sis-persons.xml search_and_check_object tasks "Import from SIS persons" - wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a79aeaaa + wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a79aeaaa 6 10 assert_task_success 22c2a3d0-0961-4255-9eec-c550a79aeaaa search_and_check_object users jsmith @@ -97,7 +97,30 @@ load ../../../library # TODO check in LDAP, check assignments etc } +@test "230 Check 'TestUser230' in Midpoint and LDAP" { + if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi + check_health + echo "TestUser230Test User230TestUser230password" >/tmp/testuser230.xml + add_object users /tmp/testuser230.xml + rm /tmp/testuser230.xml + search_and_check_object users TestUser230 + + add_object tasks tests/resources/task/recom-role-grouper-sysadmin.xml + search_and_check_object tasks "Recompute role-grouper-sysadmin" + wait_for_task_completion 22c2a3d0-0961-4255-9eec-caasa79aeaaa 6 10 + assert_task_success 22c2a3d0-0961-4255-9eec-caasa79aeaaa + + add_object tasks tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml + search_and_check_object tasks "Assign role-grouper-sysadmin to TestUser230" + wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a791237s 6 10 + assert_task_success 22c2a3d0-0961-4255-9eec-c550a791237s + + check_ldap_account_by_user_name TestUser230 + check_of_ldap_membership TestUser230 sysadmingroup +} + + @test "999 Clean up" { -# skip TEMP + skip TEMP docker-compose down -v } diff --git a/demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml b/demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml new file mode 100644 index 0000000..7d490f5 --- /dev/null +++ b/demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml @@ -0,0 +1,33 @@ + + Assign role-grouper-sysadmin to TestUser230 + + + + c:UserType + + + c:name + TestUser230 + + + + assign + + role + d48ec05b-fffd-4262-acd3-d9ff63365b62 + + + + + + + runnable + BulkActions + http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3 + single + diff --git a/demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml b/demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml new file mode 100644 index 0000000..cfb41bb --- /dev/null +++ b/demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml @@ -0,0 +1,27 @@ + + Recompute role-grouper-sysadmin + + + + c:RoleType + + + name + role-grouper-sysadmin + + + + recompute + + + + + + runnable + BulkActions + http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3 + single + diff --git a/library.bash b/library.bash index a66144e..10afbf4 100644 --- a/library.bash +++ b/library.bash @@ -134,23 +134,23 @@ function add_object () { local FILE=$2 echo "Adding to $TYPE from $FILE..." - response=$(curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE) - http_code=$(sed '$!d' <<<"$response") + local response=$(curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE) + local http_code=$(sed '$!d' <<<"$response") if [ "$http_code" -eq 201 ] || [ "$http_code" -eq 202 ]; then # get the real Location - location=$(grep -oP "Location: \K.*" <<<"$response") - oid=$(sed 's/.*\///' <<<"$location") + local location=$(grep -oP "Location: \K.*" <<<"$response") + OID=$(sed 's/.*\///' <<<"$location") - echo "Oid created object: $oid" + echo "Oid created object: $OID" return 0 else echo "Error code: $http_code" if [ "$http_code" -eq 500 ]; then echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." else - error_message=$(grep 'message' <<<"$response" | head -1 | awk -F">" '{print $2}' | awk -F"<" '{print $1}') + local error_message=$(grep 'message' <<<"$response" | head -1 | awk -F">" '{print $2}' | awk -F"<" '{print $1}') echo "Error message: $error_message" fi return 1 @@ -186,6 +186,7 @@ EOF if [ "$http_code" -eq 200 ]; then return 0 else + rm $SEARCH_RESULT_FILE return 1 fi } @@ -243,6 +244,81 @@ function assert_task_success () { function wait_for_task_completion () { local OID=$1 - sleep 60 # TODO + local ATTEMPT=0 + local MAX_ATTEMPTS=$2 + local DELAY=$3 + + until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do + ATTEMPT=$((ATTEMPT+1)) + echo "Waiting $DELAY seconds for task with oid $OID to finish (attempt $ATTEMPT) ..." + sleep $DELAY + get_object tasks $OID + TASK_EXECUTION_STATUS=$(xmllint --xpath "/*/*[local-name()='executionStatus']/text()" $TMPFILE) || (echo "Couldn't extract task status from task $OID" ; cat $TMPFILE ; rm $TMPFILE ; return 1) + if [[ $TASK_EXECUTION_STATUS = "suspended" ]] || [[ $TASK_EXECUTION_STATUS = "closed" ]]; then + echo "Task $OID is finished" + rm $TMPFILE + return 0 + fi + done + rm $TMPFILE + echo Task with $OID did not finish in $(( $MAX_ATTEMPTS * $DELAY )) seconds + return 1 +} + + +#search LDAP accout by uid +function search_ldap_object_by_filter () { + local BASE_CONTEXT_FOR_SEARCH=$1 + local FILTER="$2" + TMPFILE=$(mktemp /tmp/ldapsearch.XXXXXX) + + ldapsearch -h localhost -p 389 -D "cn=Directory Manager" -w password -b "$BASE_CONTEXT_FOR_SEARCH" "($FILTER)" >$TMPFILE || (rm $TMPFILE ; return 1) + LDAPSEARCH_RESULT_FILE=$TMPFILE return 0 } + +function check_ldap_account_by_user_name () { + local NAME=$1 + search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME" + search_objects_by_name users $NAME + + local MP_FULL_NAME=$(xmllint --xpath "/*/*/*[local-name()='fullName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user fullName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + local MP_GIVEN_NAME=$(xmllint --xpath "/*/*/*[local-name()='givenName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user givenName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + local MP_FAMILY_NAME=$(xmllint --xpath "/*/*/*[local-name()='familyName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user familyName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + + local LDAP_CN=$(grep -oP "cn: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user cn from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + local LDAP_GIVEN_NAME=$(grep -oP "givenName: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user givenName from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + local LDAP_SN=$(grep -oP "sn: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user sn from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + + rm $SEARCH_RESULT_FILE + rm $LDAPSEARCH_RESULT_FILE + + if [[ $MP_FULL_NAME = $LDAP_CN ]] && [[ $MP_GIVEN_NAME = $LDAP_GIVEN_NAME ]] && [[ $MP_FAMILY_NAME = $LDAP_SN ]]; then + return 0 + fi + + echo "User in Midpoint and LDAP Account with uid $NAME are not same" + return 1 +} + +function check_of_ldap_membership () { + local NAME_OF_USER=$1 + local NAME_OF_GROUP=$2 + search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME_OF_USER" + + local LDAP_ACCOUNT_DN=$(grep -oP "dn: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user dn from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + + search_ldap_object_by_filter "ou=groups,dc=internet2,dc=edu" "cn=$NAME_OF_GROUP" + + local LDAP_MEMBERS_DNS=$(grep -oP "uniqueMember: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user uniqueMember from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + + rm $LDAPSEARCH_RESULT_FILE + + if [[ $LDAP_MEMBERS_DNS =~ $LDAP_ACCOUNT_DN ]]; then + return 0 + fi + + echo "LDAP Account with uid $NAME_OF_USER is not member of LDAP Group $NAME_OF_GROUP" + return 1 +} + From 55b1d16c5ae5a137f969ba14f80de1ba163cfa88 Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 07:06:04 +0000 Subject: [PATCH 52/73] using docker exec for ldapsearch --- demo/complex/tests/main.bats | 4 ++-- library.bash | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 0568257..0a87412 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -115,8 +115,8 @@ load ../../../library wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a791237s 6 10 assert_task_success 22c2a3d0-0961-4255-9eec-c550a791237s - check_ldap_account_by_user_name TestUser230 - check_of_ldap_membership TestUser230 sysadmingroup + check_ldap_account_by_user_name TestUser230 complex_directory_1 + check_of_ldap_membership TestUser230 sysadmingroup complex_directory_1 } diff --git a/library.bash b/library.bash index 10afbf4..f12ef85 100644 --- a/library.bash +++ b/library.bash @@ -12,7 +12,7 @@ function generic_wait_for_log () { FAILURE="$4" ADDITIONAL_CONTAINER_NAME=$5 ATTEMPT=0 - MAX_ATTEMPTS=20 + MAX_ATTEMPTS=40 DELAY=10 until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do @@ -270,16 +270,18 @@ function wait_for_task_completion () { function search_ldap_object_by_filter () { local BASE_CONTEXT_FOR_SEARCH=$1 local FILTER="$2" + local LDAP_CONTAINER=$3 TMPFILE=$(mktemp /tmp/ldapsearch.XXXXXX) - ldapsearch -h localhost -p 389 -D "cn=Directory Manager" -w password -b "$BASE_CONTEXT_FOR_SEARCH" "($FILTER)" >$TMPFILE || (rm $TMPFILE ; return 1) + docker exec $LDAP_CONTAINER ldapsearch -h localhost -p 389 -D "cn=Directory Manager" -w password -b "$BASE_CONTEXT_FOR_SEARCH" "($FILTER)" >$TMPFILE || (rm $TMPFILE ; return 1) LDAPSEARCH_RESULT_FILE=$TMPFILE return 0 } function check_ldap_account_by_user_name () { local NAME=$1 - search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME" + local LDAP_CONTAINER=$2 + search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME" $LDAP_CONTAINER search_objects_by_name users $NAME local MP_FULL_NAME=$(xmllint --xpath "/*/*/*[local-name()='fullName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user fullName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) @@ -304,11 +306,12 @@ function check_ldap_account_by_user_name () { function check_of_ldap_membership () { local NAME_OF_USER=$1 local NAME_OF_GROUP=$2 - search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME_OF_USER" + local LDAP_CONTAINER=$3 + search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME_OF_USER" $LDAP_CONTAINER local LDAP_ACCOUNT_DN=$(grep -oP "dn: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user dn from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) - search_ldap_object_by_filter "ou=groups,dc=internet2,dc=edu" "cn=$NAME_OF_GROUP" + search_ldap_object_by_filter "ou=groups,dc=internet2,dc=edu" "cn=$NAME_OF_GROUP" $LDAP_CONTAINER local LDAP_MEMBERS_DNS=$(grep -oP "uniqueMember: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user uniqueMember from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) From e85c28d6504e258c5319fe0427fd0bbc76824fed Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 07:08:40 +0000 Subject: [PATCH 53/73] return back MAX_ATTEMPTS to 20 --- library.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.bash b/library.bash index f12ef85..ec4065c 100644 --- a/library.bash +++ b/library.bash @@ -12,7 +12,7 @@ function generic_wait_for_log () { FAILURE="$4" ADDITIONAL_CONTAINER_NAME=$5 ATTEMPT=0 - MAX_ATTEMPTS=40 + MAX_ATTEMPTS=20 DELAY=10 until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do From 834a65222cf933e9f9114ccb5f55e56ac798cb51 Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 10:23:13 +0000 Subject: [PATCH 54/73] adding function for bulk action --- demo/complex/tests/main.bats | 12 ++--- ...ign-role-grouper-sysadmin-to-test-user.xml | 22 ++++++++ .../recom-role-grouper-sysadmin.xml | 16 ++++++ ...ign-role-grouper-sysadmin-to-test-user.xml | 33 ------------ .../task/recom-role-grouper-sysadmin.xml | 27 ---------- demo/shibboleth/tests/main.bats | 3 +- library.bash | 54 ++++++++++++------- 7 files changed, 76 insertions(+), 91 deletions(-) create mode 100644 demo/complex/tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml create mode 100644 demo/complex/tests/resources/bulk-action/recom-role-grouper-sysadmin.xml delete mode 100644 demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml delete mode 100644 demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 0a87412..99fec0d 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -22,7 +22,7 @@ load ../../../library wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1 wait_for_shibboleth_idp_start complex_idp_1 rm $BATS_TMPDIR/not-started -# TODO wait for shibboleth, grouper-ui, (also something other?) + TODO wait for shibboleth, grouper-ui, (also something other?) } @test "040 Check midPoint health" { @@ -105,15 +105,9 @@ load ../../../library rm /tmp/testuser230.xml search_and_check_object users TestUser230 - add_object tasks tests/resources/task/recom-role-grouper-sysadmin.xml - search_and_check_object tasks "Recompute role-grouper-sysadmin" - wait_for_task_completion 22c2a3d0-0961-4255-9eec-caasa79aeaaa 6 10 - assert_task_success 22c2a3d0-0961-4255-9eec-caasa79aeaaa + execute_bulk_action tests/resources/bulk-action/recom-role-grouper-sysadmin.xml - add_object tasks tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml - search_and_check_object tasks "Assign role-grouper-sysadmin to TestUser230" - wait_for_task_completion 22c2a3d0-0961-4255-9eec-c550a791237s 6 10 - assert_task_success 22c2a3d0-0961-4255-9eec-c550a791237s + execute_bulk_action tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml check_ldap_account_by_user_name TestUser230 complex_directory_1 check_of_ldap_membership TestUser230 sysadmingroup complex_directory_1 diff --git a/demo/complex/tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml b/demo/complex/tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml new file mode 100644 index 0000000..c2736da --- /dev/null +++ b/demo/complex/tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml @@ -0,0 +1,22 @@ + + + c:UserType + + + c:name + TestUser230 + + + + assign + + role + d48ec05b-fffd-4262-acd3-d9ff63365b62 + + + + diff --git a/demo/complex/tests/resources/bulk-action/recom-role-grouper-sysadmin.xml b/demo/complex/tests/resources/bulk-action/recom-role-grouper-sysadmin.xml new file mode 100644 index 0000000..1356484 --- /dev/null +++ b/demo/complex/tests/resources/bulk-action/recom-role-grouper-sysadmin.xml @@ -0,0 +1,16 @@ + + + c:RoleType + + + name + role-grouper-sysadmin + + + + recompute + + + diff --git a/demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml b/demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml deleted file mode 100644 index 7d490f5..0000000 --- a/demo/complex/tests/resources/task/assign-role-grouper-sysadmin-to-test-user.xml +++ /dev/null @@ -1,33 +0,0 @@ - - Assign role-grouper-sysadmin to TestUser230 - - - - c:UserType - - - c:name - TestUser230 - - - - assign - - role - d48ec05b-fffd-4262-acd3-d9ff63365b62 - - - - - - - runnable - BulkActions - http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3 - single - diff --git a/demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml b/demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml deleted file mode 100644 index cfb41bb..0000000 --- a/demo/complex/tests/resources/task/recom-role-grouper-sysadmin.xml +++ /dev/null @@ -1,27 +0,0 @@ - - Recompute role-grouper-sysadmin - - - - c:RoleType - - - name - role-grouper-sysadmin - - - - recompute - - - - - - runnable - BulkActions - http://midpoint.evolveum.com/xml/ns/public/model/scripting/handler-3 - single - diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 4a791fa..105395d 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -15,8 +15,7 @@ load ../../../library @test "020 Initialize and start Shibboleth" { docker-compose up -d - # TODO implement wait_for_shibboleth_start - sleep 60 + wait_for_shibboleth_idp_start shibboleth_idp_1 } @test "030 Check health" { diff --git a/library.bash b/library.bash index ec4065c..0982c3f 100644 --- a/library.bash +++ b/library.bash @@ -47,24 +47,7 @@ function wait_for_midpoint_start () { # Waits until Shibboleth IDP starts ... TODO refactor using generic waiting function function wait_for_shibboleth_idp_start () { - CONTAINER_NAME=$1 - ATTEMPT=0 - MAX_ATTEMPTS=20 - DELAY=10 - - until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do - ATTEMPT=$((ATTEMPT+1)) - echo "Waiting $DELAY seconds for Shibboleth IDP to start (attempt $ATTEMPT) ..." - sleep $DELAY - docker ps - ( docker logs $CONTAINER_NAME 2>&1 | grep "INFO:oejs.Server:main: Started" ) && return 0 - done - - echo Shibboleth IDP did not start in $(( $MAX_ATTEMPTS * $DELAY )) seconds in $CONTAINER_NAME - echo "========== Container log ==========" - docker logs $CONTAINER_NAME 2>&1 - echo "========== End of the container log ==========" - return 1 + generic_wait_for_log $1 "INFO:oejs.Server:main: Started" "shibboleth idp to start" "shibboleth idp did not start" $2 } # Checks the health of midPoint server @@ -155,10 +138,41 @@ function add_object () { fi return 1 fi - #curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE || return 1 - #TODO check the returned XML } +function execute_bulk_action () { + local FILE=$1 + echo "Executing bulk action from $FILE..." + TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX) + + curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/rpc/executeScript" -d @$FILE >$TMPFILE + local HTTP_CODE=$(sed '$!d' $TMPFILE) + sed -i '$ d' $TMPFILE + + if [ "$HTTP_CODE" -eq 200 ]; then + + local STATUS=$(xmllint --xpath "/*/*/*[local-name()='status']/text()" $TMPFILE) || (echo "Couldn't extract status from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + if [ $STATUS = "success" ]; then + rm $TMPFILE + return 0 + else + echo "Bulk action status is not OK: $STATUS" + local CONSOLE_OUTPUT=$(xmllint --xpath "/*/*/*[local-name()='consoleOutput']/text()" $TMPFILE) || (echo "Couldn't extract console output from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Console output: $CONSOLE_OUTPUT" + rm $TMPFILE + return 1 + fi + + else + echo "Error code: $HTTP_CODE" + if [ "$http_code" -eq 500 ]; then + echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." + fi + return 1 + fi +} + + # Tries to find an object with a given name # Results of the search are in the $SEARCH_RESULT_FILE # TODO check if the result is valid (i.e. not an error) - return 1 if invalid, otherwise return 0 ("no objects" is considered OK here) From 38f496df8d03c24de6bfc43005007ecf57e84bc1 Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 10:26:22 +0000 Subject: [PATCH 55/73] removing mistake with comment --- demo/complex/tests/main.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 99fec0d..279abac 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -22,7 +22,7 @@ load ../../../library wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1 wait_for_shibboleth_idp_start complex_idp_1 rm $BATS_TMPDIR/not-started - TODO wait for shibboleth, grouper-ui, (also something other?) +# TODO wait for shibboleth, grouper-ui, (also something other?) } @test "040 Check midPoint health" { From 2fc6232c60bdd051163f3aecbe716e1506cfda43 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 14:14:06 +0200 Subject: [PATCH 56/73] Disable Shib if not needed; add env var checks If AUTHENTICATION=internal we avoid loading mod_shib and starting shibd. Also added environment variable checks so if some are missing due to wrong Docker composition, midPoint will inform user in a reasonable way. --- Dockerfile | 6 ++++- container_files/mp-dir/repository-url | 4 +-- container_files/usr-local-bin/start-httpd.sh | 18 ++++++++++++- .../usr-local-bin/start-midpoint.sh | 26 +++++++++++++++++-- 4 files changed, 48 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 4d3a318..ca245a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,6 +35,10 @@ RUN chmod 755 /opt/tier/setenv.sh \ && chmod 755 /usr/local/bin/healthcheck.sh RUN cp /dev/null /etc/httpd/conf.d/ssl.conf \ + && mv /etc/httpd/conf.d/shib.conf shib.conf.auth.shibboleth \ + && touch /etc/httpd/conf.d/shib.conf.auth.internal \ + && mv /etc/httpd/conf.modules.d/00-shib.conf 00-shib.conf.auth.shibboleth \ + && touch /etc/httpd/conf.modules.d/00-shib.conf.auth.internal \ && sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' /etc/httpd/conf/httpd.conf \ && echo -e "\nErrorLogFormat \"httpd;error_log;%{ENV}e;%{USERTOKEN}e;[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i\"" >> /etc/httpd/conf/httpd.conf \ && sed -i 's/CustomLog "logs\/access_log"/CustomLog "\/tmp\/loghttpd"/g' /etc/httpd/conf/httpd.conf \ @@ -82,7 +86,7 @@ ENV AUTHENTICATION internal ENV SSO_HEADER uid ENV AJP_ENABLED true ENV AJP_PORT 9090 -ENV MP_LOGOUT_URL https://localhost:8443/Shibboleth.sso/Logout +ENV LOGOUT_URL https://localhost:8443/Shibboleth.sso/Logout # Other parameters diff --git a/container_files/mp-dir/repository-url b/container_files/mp-dir/repository-url index 2ba287a..6977cbf 100755 --- a/container_files/mp-dir/repository-url +++ b/container_files/mp-dir/repository-url @@ -1,7 +1,7 @@ #!/bin/bash function resolvePort() { - if [ $REPO_PORT == "default" ]; then + if [[ $REPO_PORT == "default" ]]; then case $REPO_DATABASE_TYPE in mariadb) echo 3306 @@ -26,7 +26,7 @@ function resolvePort() { fi } -if [ $REPO_JDBC_URL == "default" ]; then +if [[ $REPO_JDBC_URL == "default" ]]; then REPO_PORT=$( resolvePort ) case $REPO_DATABASE_TYPE in mariadb) diff --git a/container_files/usr-local-bin/start-httpd.sh b/container_files/usr-local-bin/start-httpd.sh index c386df4..0bc2028 100755 --- a/container_files/usr-local-bin/start-httpd.sh +++ b/container_files/usr-local-bin/start-httpd.sh @@ -4,5 +4,21 @@ echo "Linking secrets and config files; using authentication: $AUTHENTICATION" ln -sf /run/secrets/mp_sp-key.pem /etc/shibboleth/sp-key.pem ln -sf /run/secrets/mp_host-key.pem /etc/pki/tls/private/host-key.pem ln -sf /etc/httpd/conf.d/midpoint.conf.auth.$AUTHENTICATION /etc/httpd/conf.d/midpoint.conf +ln -sf /etc/httpd/conf.d/shib.conf.auth.$AUTHENTICATION /etc/httpd/conf.d/shib.conf +ln -sf /etc/httpd/conf.modules.d/00-shib.conf.auth.$AUTHENTICATION /etc/httpd/conf.modules.d/00-shib.conf -httpd-shib-foreground +case $AUTHENTICATION in + shibboleth) + echo "*** Starting httpd WITH Shibboleth support" + httpd-shib-foreground + ;; + internal) + echo "*** Starting httpd WITHOUT Shibboleth support" + rm -f /etc/httpd/logs/httpd.pid /run/httpd/httpd.pid + httpd -DFOREGROUND + ;; + *) + echo "*** Couldn't start httpd: unsupported AUTHENTICATION variable value: '$AUTHENTICATION'" + sleep infinity + ;; +esac diff --git a/container_files/usr-local-bin/start-midpoint.sh b/container_files/usr-local-bin/start-midpoint.sh index ed7b13b..0ccf340 100755 --- a/container_files/usr-local-bin/start-midpoint.sh +++ b/container_files/usr-local-bin/start-midpoint.sh @@ -1,5 +1,28 @@ #!/bin/bash +function check () { + local VARNAME=$1 + if [ -z ${!VARNAME} ]; then + echo "*** Couldn't start midPoint: $VARNAME variable is undefined. Please check your Docker composition." + exit 1 + fi +} + +# These variables have reasonable defaults in Dockerfile. So we will _not_ supply defaults here. +# The composer or user has to make sure they are well defined. + +check MP_MEM +check MP_DIR +check REPO_DATABASE_TYPE +check REPO_USER +check REPO_PASSWORD_FILE +check REPO_MISSING_SCHEMA_ACTION +check REPO_UPGRADEABLE_SCHEMA_ACTION +check MP_KEYSTORE_PASSWORD_FILE +check SSO_HEADER +check AJP_ENABLED +check AJP_PORT + java -Xmx$MP_MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dmidpoint.home=$MP_DIR/var \ -Dmidpoint.repository.database=$REPO_DATABASE_TYPE \ @@ -17,8 +40,7 @@ java -Xmx$MP_MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dmidpoint.logging.alt.filename=/tmp/logmidpoint \ -Dmidpoint.logging.alt.timezone=UTC \ -Dspring.profiles.active="`$MP_DIR/active-spring-profiles`" \ - -Dauth.sso.header=$SSO_HEADER \ - $(if [ "$AUTHENTICATION" = "shibboleth" ]; then echo "-Dauth.logout.url=$MP_LOGOUT_URL"; fi) \ + $(if [ "$AUTHENTICATION" = "shibboleth" ]; then echo "-Dauth.logout.url=$LOGOUT_URL -Dauth.sso.header=$SSO_HEADER"; fi) \ -Dserver.tomcat.ajp.enabled=$AJP_ENABLED \ -Dserver.tomcat.ajp.port=$AJP_PORT \ -Dlogging.path=/tmp/logtomcat \ From 43f7b7aed452b67172d2f8e219f53f3e84d5c526 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 14:14:33 +0200 Subject: [PATCH 57/73] Simplify demo/simple by removing Shib items And fix .env file by adding missing variable. --- demo/simple/.env | 2 +- .../midpoint/shibboleth/idp-metadata.xml | 207 ------------------ .../midpoint/shibboleth/shibboleth2.xml | 136 ------------ .../midpoint/shibboleth/sp-cert.pem | 22 -- .../midpoint/shibboleth/sp-key.pem | 28 --- demo/simple/docker-compose.yml | 13 -- 6 files changed, 1 insertion(+), 407 deletions(-) delete mode 100644 demo/simple/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml delete mode 100644 demo/simple/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml delete mode 100644 demo/simple/configs-and-secrets/midpoint/shibboleth/sp-cert.pem delete mode 100644 demo/simple/configs-and-secrets/midpoint/shibboleth/sp-key.pem diff --git a/demo/simple/.env b/demo/simple/.env index 2cc995d..84e50b2 100644 --- a/demo/simple/.env +++ b/demo/simple/.env @@ -1,5 +1,4 @@ # These parameters can be overridden by setting environment variables before calling docker-compose up -AUTHENTICATION=internal ENV=demo USERTOKEN= REPO_DATABASE_TYPE=mariadb @@ -9,4 +8,5 @@ REPO_PORT=default REPO_DATABASE=registry REPO_USER=registry_user REPO_MISSING_SCHEMA_ACTION=create +REPO_UPGRADEABLE_SCHEMA_ACTION=stop MP_MEM=2048m diff --git a/demo/simple/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml b/demo/simple/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml deleted file mode 100644 index 35914b7..0000000 --- a/demo/simple/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - example.org - - - - - - - -MIIDEzCCAfugAwIBAgIUS9SuTXws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S2l873J5PrsbpeKEVR/IIoKo= - - - - - - - urn:mace:shibboleth:1.0:nameIdentifier - urn:oasis:names:tc:SAML:2.0:nameid-format:transient - - - - - - - - - - - - - localhost - - - - - - -MIIDEzCCAfugAwIBAgIUS9SuTXwsFVVG+LjOEAbLqqT/el0wDQYJKoZIhvcNAQEL -BQAwFTETMBEGA1UEAwwKaWRwdGVzdGJlZDAeFw0xNTEyMTEwMjIwMjZaFw0zNTEy -MTEwMjIwMjZaMBUxEzARBgNVBAMMCmlkcHRlc3RiZWQwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQCMAoDHx8xCIfv/6QKqt9mcHYmEJ8y2dKprUbpdcOjH -YvNPIl/lHPsUyrb+Nc+q2CDeiWjVk1mWYq0UpIwpBMuw1H6+oOqr4VQRi65pin0M -SfE0MWIaFo5FPvpvoptkHD4gvREbm4swyXGMczcMRfqgalFXhUD2wz8W3XAM5Cq2 -03XeJbj6TwjvKatG5XPdeUe2FBGuOO2q54L1hcIGnLMCQrg7D31lR13PJbjnJ0No -5C3k8TPuny6vJsBC03GNLNKfmrKVTdzr3VKp1uay1G3DL9314fgmbl8HA5iRQmy+ -XInUU6/8NXZSF59p3ITAOvZQeZsbJjg5gGDip5OZo9YlAgMBAAGjWzBZMB0GA1Ud -DgQWBBRPlM4VkKZ0U4ec9GrIhFQl0hNbLDA4BgNVHREEMTAvggppZHB0ZXN0YmVk -hiFodHRwczovL2lkcHRlc3RiZWQvaWRwL3NoaWJib2xldGgwDQYJKoZIhvcNAQEL -BQADggEBAIZ0a1ov3my3ljJG588I/PHx+TxAWONWmpKbO9c/qI3Drxk4oRIffiac -ANxdvtabgIzrlk5gMMisD7oyqHJiWgKv5Bgctd8w3IS3lLl7wHX65mTKQRXniG98 -NIjkvfrhe2eeJxecOqnDI8GOhIGCIqZUn8ShdM/yHjhQ2Mh0Hj3U0LlKvnmfGSQl -j0viGwbFCaNaIP3zc5UmCrdE5h8sWL3Fu7ILKM9RyFa2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Fhn1rCo2QiojzjSlV3yLTh49iTyhE3cG+RxaNKDCxhp0jSSLX1BW/ZoPA8 -+PMJEA+Q0QbyRD8aJOHN5O8jGxCa/ZzcOnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H -p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= - - - - - - - - - - - - - - diff --git a/demo/simple/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml b/demo/simple/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml deleted file mode 100644 index a644264..0000000 --- a/demo/simple/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - SAML2 - - - - SAML2 Local - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-cert.pem b/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-cert.pem deleted file mode 100644 index 0f5474e..0000000 --- a/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-cert.pem +++ /dev/null @@ -1,22 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDqDCCApCgAwIBAgIJAKUZrfriIt9cMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNV -BAYTAlVTMQswCQYDVQQIDAJNSTESMBAGA1UEBwwJQW5uIEFyYm9yMRcwFQYDVQQK -DA5JbnRlcm5ldDIvVElFUjEgMB4GA1UEAwwXZXZvbHZldW0uc3AuZXhhbXBsZS5v -cmcwHhcNMTgwOTE0MDU0NjU3WhcNMTkwOTE0MDU0NjU3WjBpMQswCQYDVQQGEwJV -UzELMAkGA1UECAwCTUkxEjAQBgNVBAcMCUFubiBBcmJvcjEXMBUGA1UECgwOSW50 -ZXJuZXQyL1RJRVIxIDAeBgNVBAMMF2V2b2x2ZXVtLnNwLmV4YW1wbGUub3JnMIIB -IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw5v1zxlM94yaBssgNNbIUJwW -XxbGxgSs2AWBeg2aEi/VQd2UE5ivZakNJlqWSJyHo2xE4kxeSyBBxinjSyhmpNao -xIcqQsgW0gxo4SEHo3kUXWPo+of/pj6CslutsSJZWGTRV0dHITvaWX+NM8eXMfgu -mJFwy3RMdLaWQhY1Dyi2jNoO+DZnfNgPyPeEZcmORaoeEID9QdZfHtcgTf2QfSHq -+xsTwHB6Ro5t7YD2ma8Krb/XcDTfsq3qJemd7LhPj5lGmhYSMgDbgwEkZgZ1kBOP -lfsP2BvX5nipv7Vd1C5YXmv+NDR8V3yAWBC7ZAenxGmrnkaSVXnpUplUsGGm1QID -AQABo1MwUTAdBgNVHQ4EFgQUuxSZwW6V1P/b0tsTM32OU/v/n+UwHwYDVR0jBBgw -FoAUuxSZwW6V1P/b0tsTM32OU/v/n+UwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG -9w0BAQsFAAOCAQEAJWLXEfZkPeUyiGvsIUjczzdF3ptqXoP9aETS2pOV9sTri19R -TsQZW6XQRHGtuEOsqEGH8yiTdGR5hbGC+ynH/xTJnK+tBn/R3KrgxLKyMvoUzAPl -mhVq1dh+ZEtbsRpQRRubP6nm9kXNma0cXrkJSzuWM0W+l/xSOOYiSRRk3XWJfVjn -9jQlcJRh5SOkKN08oZHrCYKxToEuOfV8PtRj3T80DhsBTv2SHqhg4cBhzQPb0Kjm -9m4IkYOz8c5ZtuHDGnqMHw60Nyt+jyik4mMFP2frcOVP0W0sgwcfHllYzHoA/Khq -Yk3TBVs1BjPuNDJWHct8Eo68YP2/ZvzqfVM87Q== ------END CERTIFICATE----- diff --git a/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-key.pem b/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-key.pem deleted file mode 100644 index b4c7a68..0000000 --- a/demo/simple/configs-and-secrets/midpoint/shibboleth/sp-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCB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CwKBgQDPdmOlODBeB/Iomt+Kl3qtxaW0j9zp12JNfk7oJUY3IA0Uprss -2T0qnbTnRQ5myGkbThHMSQKDhfwTeZqJSRakNKOYBDisxQ//yd4IKEYFmuYF0gxE -ueDR4h5GcxfyMirFsRAPUqe5fKH/f+zy5HFp6B/FONkkDXDgd7aVPTxURQKBgF8q -sUUXJTqnvqNpqQ1ZK1+8JeRNcLw2IuM64L9bIrTYdbYI9A/2dxL4fdE0+JN3WRF4 -AwwYeby044N8lfydwySr7kkdTiYeFi6oCAhUmyPTHE7G+iivZGaDE4Xeu/w6gF3E -G48e2SMFeLiu0y0TdZvK31tqlRp8RXVKVhJjLSLtAoGBAP01ZMUJu5AU19c7xRTy -kfVzE6PI+E8ZZ6qEWMs2Xt3NQL4Bffh94QQCmQYX3AY7xVD1gAQgbLXx4lEDQdzu -i/kV4t+oeYwXSn1UEgOQj504qwR3gi4JZdfa0LbiMzhp9qyxofyk7Lre7Tc3Xmu1 -jyigTF7oAYoPBWk/mAthK1wO ------END PRIVATE KEY----- diff --git a/demo/simple/docker-compose.yml b/demo/simple/docker-compose.yml index 7658907..ecadd67 100644 --- a/demo/simple/docker-compose.yml +++ b/demo/simple/docker-compose.yml @@ -18,7 +18,6 @@ services: ports: - 8443:443 environment: - - AUTHENTICATION - ENV - USERTOKEN - REPO_DATABASE_TYPE @@ -38,19 +37,9 @@ services: secrets: - mp_database_password.txt - mp_keystore_password.txt - - mp_sp-key.pem - mp_host-key.pem volumes: - midpoint_home:/opt/midpoint/var - - type: bind - source: ./configs-and-secrets/midpoint/shibboleth/shibboleth2.xml - target: /etc/shibboleth/shibboleth2.xml - - type: bind - source: ./configs-and-secrets/midpoint/shibboleth/idp-metadata.xml - target: /etc/shibboleth/idp-metadata.xml - - type: bind - source: ./configs-and-secrets/midpoint/shibboleth/sp-cert.pem - target: /etc/shibboleth/sp-cert.pem - type: bind source: ./configs-and-secrets/midpoint/httpd/host-cert.pem target: /etc/pki/tls/certs/host-cert.pem @@ -65,8 +54,6 @@ networks: secrets: mp_host-key.pem: file: ./configs-and-secrets/midpoint/httpd/host-key.pem - mp_sp-key.pem: - file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem mp_database_password.txt: file: ./configs-and-secrets/midpoint/application/database_password.txt mp_keystore_password.txt: From baa274922aea6f3ce4907cafdaca83c5a471bff2 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 14:36:51 +0200 Subject: [PATCH 58/73] Fix Shibboleth support in container --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index ca245a0..19561a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,9 +35,9 @@ RUN chmod 755 /opt/tier/setenv.sh \ && chmod 755 /usr/local/bin/healthcheck.sh RUN cp /dev/null /etc/httpd/conf.d/ssl.conf \ - && mv /etc/httpd/conf.d/shib.conf shib.conf.auth.shibboleth \ + && mv /etc/httpd/conf.d/shib.conf /etc/httpd/conf.d/shib.conf.auth.shibboleth \ && touch /etc/httpd/conf.d/shib.conf.auth.internal \ - && mv /etc/httpd/conf.modules.d/00-shib.conf 00-shib.conf.auth.shibboleth \ + && mv /etc/httpd/conf.modules.d/00-shib.conf /etc/httpd/conf.modules.d/00-shib.conf.auth.shibboleth \ && touch /etc/httpd/conf.modules.d/00-shib.conf.auth.internal \ && sed -i 's/LogFormat "/LogFormat "httpd;access_log;%{ENV}e;%{USERTOKEN}e;/g' /etc/httpd/conf/httpd.conf \ && echo -e "\nErrorLogFormat \"httpd;error_log;%{ENV}e;%{USERTOKEN}e;[%{u}t] [%-m:%l] [pid %P:tid %T] %7F: %E: [client\ %a] %M% ,\ referer\ %{Referer}i\"" >> /etc/httpd/conf/httpd.conf \ From c94165719e8d818387692b4ba0ca7236ff1df130 Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 12:37:38 +0000 Subject: [PATCH 59/73] adding of function for delete object --- demo/complex/tests/main.bats | 7 ++-- library.bash | 67 ++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 14 deletions(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 279abac..9daa28e 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -53,7 +53,7 @@ load ../../../library add_object users /tmp/test110.xml rm /tmp/test110.xml search_and_check_object users test110 -# TODO delete user after + delete_object_by_name users test110 } @test "200 Upload objects" { @@ -105,12 +105,13 @@ load ../../../library rm /tmp/testuser230.xml search_and_check_object users TestUser230 - execute_bulk_action tests/resources/bulk-action/recom-role-grouper-sysadmin.xml - + execute_bulk_action tests/resources/bulk-action/recom-role-grouper-sysadmin.xml execute_bulk_action tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml check_ldap_account_by_user_name TestUser230 complex_directory_1 check_of_ldap_membership TestUser230 sysadmingroup complex_directory_1 + + delete_object_by_name users TestUser230 } diff --git a/library.bash b/library.bash index 0982c3f..6d02a2f 100644 --- a/library.bash +++ b/library.bash @@ -12,7 +12,7 @@ function generic_wait_for_log () { FAILURE="$4" ADDITIONAL_CONTAINER_NAME=$5 ATTEMPT=0 - MAX_ATTEMPTS=20 + MAX_ATTEMPTS=40 DELAY=10 until [[ $ATTEMPT = $MAX_ATTEMPTS ]]; do @@ -115,27 +115,29 @@ function get_and_check_object () { function add_object () { local TYPE=$1 local FILE=$2 + TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX) echo "Adding to $TYPE from $FILE..." - local response=$(curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE) - local http_code=$(sed '$!d' <<<"$response") + curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE >$TMPFILE + local HTTP_CODE=$(sed '$!d' $TMPFILE) - if [ "$http_code" -eq 201 ] || [ "$http_code" -eq 202 ]; then + if [ "$HTTP_CODE" -eq 201 ] || [ "$HTTP_CODE" -eq 202 ]; then # get the real Location - local location=$(grep -oP "Location: \K.*" <<<"$response") - OID=$(sed 's/.*\///' <<<"$location") + OID=$(grep -oP "Location: \K.*" $TMPFILE | awk -F "$TYPE/" '{print $2}') || (echo "Couldn't extract oid from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) echo "Oid created object: $OID" + rm $TMPFILE return 0 else - echo "Error code: $http_code" - if [ "$http_code" -eq 500 ]; then + echo "Error code: $HTTP_CODE" + if [ "$HTTP_CODE" -ge 500 ]; then echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." else - local error_message=$(grep 'message' <<<"$response" | head -1 | awk -F">" '{print $2}' | awk -F"<" '{print $1}') - echo "Error message: $error_message" + local ERROR_MESSAGE=$(xmllint --xpath "/*/*[local-name()='error']/text()" $TMPFILE) || (echo "Couldn't extract error message from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Error message: $ERROR_MESSAGE" fi + rm $TMPFILE return 1 fi } @@ -153,6 +155,8 @@ function execute_bulk_action () { local STATUS=$(xmllint --xpath "/*/*/*[local-name()='status']/text()" $TMPFILE) || (echo "Couldn't extract status from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) if [ $STATUS = "success" ]; then + local CONSOLE_OUTPUT=$(xmllint --xpath "/*/*/*[local-name()='consoleOutput']/text()" $TMPFILE) || (echo "Couldn't extract console output from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Console output: $CONSOLE_OUTPUT" rm $TMPFILE return 0 else @@ -165,13 +169,54 @@ function execute_bulk_action () { else echo "Error code: $HTTP_CODE" - if [ "$http_code" -eq 500 ]; then + if [ "$HTTP_CODE" -ge 500 ]; then echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." + else + local ERROR_MESSAGE=$(xmllint --xpath "/*/*[local-name()='error']/text()" $TMPFILE) || (echo "Couldn't extract error message from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Error message: $ERROR_MESSAGE" fi + rm $TMPFILE return 1 fi } +function delete_object_by_name () { + local TYPE=$1 + local NAME=$2 + search_objects_by_name users $NAME + local OID=$(xmllint --xpath "/*/*[local-name()='object']/@oid" $SEARCH_RESULT_FILE | awk -F"\"" '{print $2}' ) || (echo "Couldn't extract oid from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE; return 1) + delete_object $TYPE $OID +} + +function delete_object () { + local TYPE=$1 + local OID=$2 + echo "Deleting object with type $TYPE and oid $OID..." + TMPFILE=$(mktemp /tmp/delete.XXXXXX) + + curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X DELETE "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$TMPFILE + local HTTP_CODE=$(sed '$!d' $TMPFILE) + sed -i '$ d' $TMPFILE + + if [ "$HTTP_CODE" -eq 204 ]; then + + echo "Object with type $TYPE and oid $OID was deleted" + rm $TMPFILE + return 0 + else + echo "Error code: $HTTP_CODE" + if [ "$HTTP_CODE" -ge 500 ]; then + echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." + else + local ERROR_MESSAGE=$(xmllint --xpath "/*/*[local-name()='error']/text()" $TMPFILE) || (echo "Couldn't extract error message from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Error message: $ERROR_MESSAGE" + fi + rm $TMPFILE + return 1 + fi +} + + # Tries to find an object with a given name # Results of the search are in the $SEARCH_RESULT_FILE From c543811e4acebad10d9221cfd966451ed348bce0 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 14:45:11 +0200 Subject: [PATCH 60/73] Refactor demo/shibboleth Now all components are started within single docker-compose.yml file. --- Jenkinsfile | 3 +- demo/shibboleth/.env | 13 ++ demo/shibboleth/README.md | 3 - .../application/database_password.txt | 1 + .../application/keystore_password.txt | 1 + .../midpoint/httpd/host-cert.pem | 22 ++ .../midpoint/httpd/host-key.pem | 28 +++ .../midpoint/shibboleth/idp-metadata.xml | 207 ++++++++++++++++++ .../midpoint/shibboleth/shibboleth2.xml | 136 ++++++++++++ .../midpoint/shibboleth/sp-cert.pem | 22 ++ .../midpoint/shibboleth/sp-key.pem | 28 +++ demo/shibboleth/docker-compose.yml | 71 ++++++ demo/shibboleth/tests/main.bats | 13 +- 13 files changed, 537 insertions(+), 11 deletions(-) create mode 100644 demo/shibboleth/.env delete mode 100644 demo/shibboleth/README.md create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/application/database_password.txt create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/application/keystore_password.txt create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/httpd/host-cert.pem create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/httpd/host-key.pem create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-cert.pem create mode 100644 demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-key.pem diff --git a/Jenkinsfile b/Jenkinsfile index c1cb934..7831838 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -56,11 +56,10 @@ pipeline { sh 'echo Docker containers before compositions tests ; docker ps -a' // temporary sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // temporarily disabled - //sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' //sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' - // sh 'echo Test output ; cat debug' } catch (error) { def error_details = readFile('./debug') diff --git a/demo/shibboleth/.env b/demo/shibboleth/.env new file mode 100644 index 0000000..d731cbd --- /dev/null +++ b/demo/shibboleth/.env @@ -0,0 +1,13 @@ +# These parameters can be overridden by setting environment variables before calling docker-compose up +AUTHENTICATION=shibboleth +ENV=demo +USERTOKEN= +REPO_DATABASE_TYPE=mariadb +REPO_JDBC_URL=default +REPO_HOST=midpoint_data +REPO_PORT=default +REPO_DATABASE=registry +REPO_USER=registry_user +REPO_MISSING_SCHEMA_ACTION=create +REPO_UPGRADEABLE_SCHEMA_ACTION=stop +MP_MEM=2048m diff --git a/demo/shibboleth/README.md b/demo/shibboleth/README.md deleted file mode 100644 index 79a1bb8..0000000 --- a/demo/shibboleth/README.md +++ /dev/null @@ -1,3 +0,0 @@ -This container composition is to be used outside other midPoint compositions like `demo/simple` or `demo/postgresql-full`. - -Just start it along with the other midPoint composition. They should work together seamlessly. diff --git a/demo/shibboleth/configs-and-secrets/midpoint/application/database_password.txt b/demo/shibboleth/configs-and-secrets/midpoint/application/database_password.txt new file mode 100644 index 0000000..11bff19 --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/application/database_password.txt @@ -0,0 +1 @@ +WJzesbe3poNZ91qIbmR7 diff --git a/demo/shibboleth/configs-and-secrets/midpoint/application/keystore_password.txt b/demo/shibboleth/configs-and-secrets/midpoint/application/keystore_password.txt new file mode 100644 index 0000000..1d40192 --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/application/keystore_password.txt @@ -0,0 +1 @@ +changeit diff --git a/demo/shibboleth/configs-and-secrets/midpoint/httpd/host-cert.pem b/demo/shibboleth/configs-and-secrets/midpoint/httpd/host-cert.pem new file mode 100644 index 0000000..9b1021b --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/httpd/host-cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAMOSkn4oS2aAMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJNSTESMBAGA1UEBw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SB8jKyCS1Ve0v2wVze2038Wukz02dq9uKPTIO3T+B+ibZmxn6Op/kFCc1/kK5NS +Q6JdO1B6KquGAYdGmKAcQ19mv+jqGktqWEEf0g== +-----END CERTIFICATE----- diff --git a/demo/shibboleth/configs-and-secrets/midpoint/httpd/host-key.pem b/demo/shibboleth/configs-and-secrets/midpoint/httpd/host-key.pem new file mode 100644 index 0000000..5746e59 --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/httpd/host-key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCmP9vswRRJ+7eh +cx82BHBOx7trlRXsmzB/Uz9k39lmQCQjE0F69mCjON6y8s9auaxOA42LteKAlQm8 +KN2OaVb14MyWuL+uQPwe45HUNAJUov2e+hLZzcPuyrkSZ1rdXxOWPzZWp8SZ493e +xqPHuZxN9sfyPAAv02GQL5YyJvkimMsakbQUQALSFrsvFv7uMiKodUlqotckYLIY +3iaHpzVD1LV/xFVOJbZrzHbYb73CdlhuSIDYrGWzXvuKYeWFLPwR29XgikbDVqas +RaGG4MS6bsG9nXFAMtq2BGqHioAoshVh5GcnwfUV6Uxr3SoHgbTwwg+J+ZOxDCon +IFhoR2BZAgMBAAECggEAEIRBpjjceiku6jRUwnoYaks/nIWYQwR8AfpUTwJKR/VR +Yca097Fokm7A+UhUP3A45RtHQb0VPq8P44iv0kk24YCu8r5yFK7SHYOAZnOwU5ZJ +2jSAEPF3aM7tKh3okhuzB3dKP7u1NZDE5zAW723KUJiW7sL1RcsbY0bHBj6G+9/H +NplmsjuGt684vRBB0qOBfKF7EiG7mT69tHuNj4gRza9SMY31UtKbZdt2fNY6mp5V +HscMba7egZP+Ke0pVX4+go9j7K8GG8hYaQDLjrzlPqrxZ2c5X9cC+CRDI/CHuL/s +V/2yGZJ6n6UabwZoH83RdFrbQ94rU8Hkli6EvxXvMQKBgQDRpheNW5jDG5TfeJKh +yfKTDQqH2Tk3BsBYYBN7Hf3m7vbkzlxnAKJAoSLmtRMuoeXvI5MrhzaHGsNIUS76 +LDIZnvB7DLUxhFUZsCPkpAA1QHuTWY96oR3PHnPjpk8lSUvtbOPwDLdzVApeFJgZ +VqMNArZ7AHsK3Kkyi+f4WVQjbQKBgQDLAWiGb5dx6fAM2W6B6HjNmzjBWOuVEXa2 +76to9jzupBZmETfZgxtWUaWUDuNS+f7dtVUTE+p6v/w8clrHEhEZYkqunIOLo/UA +LFPiuoTfEsWb1rh+nsCjCgy4uimixj/bSkf7NC6NyKTvCygA1mGnVVJUEPegYlDy +LXCkaKWxHQKBgQCmyHSKL2lrJkEcOwakEU2acNCE3Gno/cT9SYmV83kvQ8JEqmrW +QqnRsp9aXIljGscapPmKsmnNt5vNp1AxFAHTYh88NRLczsMIyZj0ZwgHVUI6KhC7 +5Psa78YQQBlMt2/g9TSsnuE+rYgF6mpKFiNm0Vasqeg47uzn2mdzqlUGTQKBgE04 +JutkTUY+h1pL5vYxWKpVDfy19z7H2tFxT1FowPrBneeLSyRI88Ac5I/yLdRlVeY9 +0LOmEr5Igwj3MsKgg7KVKfVLgdo/LrW3Jt2Kt3onKNXDkoBPoNUjwH0QC0Boiue+ +VK0gR0kVdm+bXccbxR+im+NwZNE0NLg6Qqu3RredAoGBALuVoqbPPmTCZXYG328H +bzOs2aiR7BzPSVByV+qG6jW7w03RAnFPJZp7HMU+ViI5VY0wabUscMSvz5163+gM +4KwY3v9ZjZzZGukIfLuudkdqtaiVOx/KeAC0n+nG21YU+wpZww8gkfHh1/sa2CME +CWYCgOnmiTHcj83UaTqEXtmv +-----END PRIVATE KEY----- diff --git a/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml new file mode 100644 index 0000000..35914b7 --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml @@ -0,0 +1,207 @@ + + + + + + +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OnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H +p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= + + + + + + + urn:mace:shibboleth:1.0:nameIdentifier + urn:oasis:names:tc:SAML:2.0:nameid-format:transient + + + + + + + + + + + + + localhost + + + + + + +MIIDEzCCAfugAwIBAgIUS9SuTXwsFVVG+LjOEAbLqqT/el0wDQYJKoZIhvcNAQEL +BQAwFTETMBEGA1UEAwwKaWRwdGVzdGJlZDAeFw0xNTEyMTEwMjIwMjZaFw0zNTEy +MTEwMjIwMjZaMBUxEzARBgNVBAMMCmlkcHRlc3RiZWQwggEiMA0GCSqGSIb3DQEB +AQUAA4IBDwAwggEKAoIBAQCMAoDHx8xCIfv/6QKqt9mcHYmEJ8y2dKprUbpdcOjH +YvNPIl/lHPsUyrb+Nc+q2CDeiWjVk1mWYq0UpIwpBMuw1H6+oOqr4VQRi65pin0M +SfE0MWIaFo5FPvpvoptkHD4gvREbm4swyXGMczcMRfqgalFXhUD2wz8W3XAM5Cq2 +03XeJbj6TwjvKatG5XPdeUe2FBGuOO2q54L1hcIGnLMCQrg7D31lR13PJbjnJ0No +5C3k8TPuny6vJsBC03GNLNKfmrKVTdzr3VKp1uay1G3DL9314fgmbl8HA5iRQmy+ +XInUU6/8NXZSF59p3ITAOvZQeZsbJjg5gGDip5OZo9YlAgMBAAGjWzBZMB0GA1Ud +DgQWBBRPlM4VkKZ0U4ec9GrIhFQl0hNbLDA4BgNVHREEMTAvggppZHB0ZXN0YmVk +hiFodHRwczovL2lkcHRlc3RiZWQvaWRwL3NoaWJib2xldGgwDQYJKoZIhvcNAQEL +BQADggEBAIZ0a1ov3my3ljJG588I/PHx+TxAWONWmpKbO9c/qI3Drxk4oRIffiac +ANxdvtabgIzrlk5gMMisD7oyqHJiWgKv5Bgctd8w3IS3lLl7wHX65mTKQRXniG98 +NIjkvfrhe2eeJxecOqnDI8GOhIGCIqZUn8ShdM/yHjhQ2Mh0Hj3U0LlKvnmfGSQl +j0viGwb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bwTn1Mjb5TBsKwtDMJsaxPvdj0u7M5r +xL/wHkFhn1rCo2QiojzjSlV3yLTh49iTyhE3cG+RxaNKDCxhp0jSSLX1BW/ZoPA8 ++PMJEA+Q0QbyRD8aJOHN5O8jGxCa/ZzcOnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H +p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= + + + + + + + + + + + + + + diff --git a/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml new file mode 100644 index 0000000..a644264 --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + SAML2 + + + + SAML2 Local + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-cert.pem b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-cert.pem new file mode 100644 index 0000000..0f5474e --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAKUZrfriIt9cMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJNSTESMBAGA1UEBwwJQW5uIEFyYm9yMRcwFQYDVQQK +DA5JbnRlcm5ldDIvVElFUjEgMB4GA1UEAwwXZXZvbHZldW0uc3AuZXhhbXBsZS5v +cmcwHhcNMTgwOTE0MDU0NjU3WhcNMTkwOTE0MDU0NjU3WjBpMQswCQYDVQQGEwJV +UzELMAkGA1UECAwCTUkxEjAQBgNVBAcMCUFubiBBcmJvcjEXMBUGA1UECgwOSW50 +ZXJuZXQyL1RJRVIxIDAeBgNVBAMMF2V2b2x2ZXVtLnNwLmV4YW1wbGUub3JnMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw5v1zxlM94yaBssgNNbIUJwW +XxbGxgSs2AWBeg2aEi/VQd2UE5ivZakNJlqWSJyHo2xE4kxeSyBBxinjSyhmpNao +xIcqQsgW0gxo4SEHo3kUXWPo+of/pj6CslutsSJZWGTRV0dHITvaWX+NM8eXMfgu +mJFwy3RMdLaWQhY1Dyi2jNoO+DZnfNgPyPeEZcmORaoeEID9QdZfHtcgTf2QfSHq ++xsTwHB6Ro5t7YD2ma8Krb/XcDTfsq3qJemd7LhPj5lGmhYSMgDbgwEkZgZ1kBOP +lfsP2BvX5nipv7Vd1C5YXmv+NDR8V3yAWBC7ZAenxGmrnkaSVXnpUplUsGGm1QID +AQABo1MwUTAdBgNVHQ4EFgQUuxSZwW6V1P/b0tsTM32OU/v/n+UwHwYDVR0jBBgw +FoAUuxSZwW6V1P/b0tsTM32OU/v/n+UwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG +9w0BAQsFAAOCAQEAJWLXEfZkPeUyiGvsIUjczzdF3ptqXoP9aETS2pOV9sTri19R +TsQZW6XQRHGtuEOsqEGH8yiTdGR5hbGC+ynH/xTJnK+tBn/R3KrgxLKyMvoUzAPl +mhVq1dh+ZEtbsRpQRRubP6nm9kXNma0cXrkJSzuWM0W+l/xSOOYiSRRk3XWJfVjn +9jQlcJRh5SOkKN08oZHrCYKxToEuOfV8PtRj3T80DhsBTv2SHqhg4cBhzQPb0Kjm +9m4IkYOz8c5ZtuHDGnqMHw60Nyt+jyik4mMFP2frcOVP0W0sgwcfHllYzHoA/Khq +Yk3TBVs1BjPuNDJWHct8Eo68YP2/ZvzqfVM87Q== +-----END CERTIFICATE----- diff --git a/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-key.pem b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-key.pem new file mode 100644 index 0000000..b4c7a68 --- /dev/null +++ b/demo/shibboleth/configs-and-secrets/midpoint/shibboleth/sp-key.pem @@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OWGKhOclkzs2nvxOcC/pEjWm83cgOz/IPWqkw0/wefmh6RDcPz1JgwO2Jij +P14FGG9YCwKBgQDPdmOlODBeB/Iomt+Kl3qtxaW0j9zp12JNfk7oJUY3IA0Uprss +2T0qnbTnRQ5myGkbThHMSQKDhfwTeZqJSRakNKOYBDisxQ//yd4IKEYFmuYF0gxE +ueDR4h5GcxfyMirFsRAPUqe5fKH/f+zy5HFp6B/FONkkDXDgd7aVPTxURQKBgF8q +sUUXJTqnvqNpqQ1ZK1+8JeRNcLw2IuM64L9bIrTYdbYI9A/2dxL4fdE0+JN3WRF4 +AwwYeby044N8lfydwySr7kkdTiYeFi6oCAhUmyPTHE7G+iivZGaDE4Xeu/w6gF3E +G48e2SMFeLiu0y0TdZvK31tqlRp8RXVKVhJjLSLtAoGBAP01ZMUJu5AU19c7xRTy +kfVzE6PI+E8ZZ6qEWMs2Xt3NQL4Bffh94QQCmQYX3AY7xVD1gAQgbLXx4lEDQdzu +i/kV4t+oeYwXSn1UEgOQj504qwR3gi4JZdfa0LbiMzhp9qyxofyk7Lre7Tc3Xmu1 +jyigTF7oAYoPBWk/mAthK1wO +-----END PRIVATE KEY----- diff --git a/demo/shibboleth/docker-compose.yml b/demo/shibboleth/docker-compose.yml index 3b57a84..9c5be10 100644 --- a/demo/shibboleth/docker-compose.yml +++ b/demo/shibboleth/docker-compose.yml @@ -1,6 +1,64 @@ version: "3.3" services: + + midpoint_data: + image: tier/mariadb:mariadb10 + ports: + - 3306:3306 + networks: + - net + volumes: + - midpoint_mysql:/var/lib/mysql + - midpoint_data:/var/lib/mysqlmounted + environment: + - CREATE_NEW_DATABASE=if_needed + + midpoint_server: + image: tier/midpoint:latest + ports: + - 8443:443 + environment: + - AUTHENTICATION + - ENV + - USERTOKEN + - REPO_DATABASE_TYPE + - REPO_JDBC_URL + - REPO_HOST + - REPO_PORT + - REPO_DATABASE + - REPO_USER + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT + - MP_MEM + - TIER_BEACON_OPT_OUT + networks: + - net + secrets: + - mp_database_password.txt + - mp_keystore_password.txt + - mp_sp-key.pem + - mp_host-key.pem + volumes: + - midpoint_home:/opt/midpoint/var + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/shibboleth2.xml + target: /etc/shibboleth/shibboleth2.xml + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/idp-metadata.xml + target: /etc/shibboleth/idp-metadata.xml + - type: bind + source: ./configs-and-secrets/midpoint/shibboleth/sp-cert.pem + target: /etc/shibboleth/sp-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/host-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/cachain.pem + directory: build: ./directory/ expose: @@ -29,5 +87,18 @@ networks: net: driver: bridge +secrets: + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem + mp_sp-key.pem: + file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem + mp_database_password.txt: + file: ./configs-and-secrets/midpoint/application/database_password.txt + mp_keystore_password.txt: + file: ./configs-and-secrets/midpoint/application/keystore_password.txt + volumes: + midpoint_mysql: + midpoint_data: + midpoint_home: ldap: diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 105395d..3bc6fa1 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -8,16 +8,18 @@ load ../../../library run docker-compose down -v } -@test "010 Initialize and start midPoint" { - cd ../simple ; env AUTHENTICATION=shibboleth docker-compose up -d - wait_for_midpoint_start simple_midpoint-server_1 +@test "010 Initialize and start containers" { + env docker-compose up -d } -@test "020 Initialize and start Shibboleth" { - docker-compose up -d +@test "012 Wait for Shibboleth to start up" { wait_for_shibboleth_idp_start shibboleth_idp_1 } +@test "014 Wait for midPoint to start up" { + wait_for_midpoint_start shibboleth_midpoint_server_1 +} + @test "030 Check health" { check_health } @@ -49,6 +51,5 @@ load ../../../library } @test "999 Clean up" { - cd ../simple ; docker-compose down -v ; true docker-compose down -v } From 3e6ed0d48cac5280e1bb7168a1cf6ff6ca20166c Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 14:40:58 +0000 Subject: [PATCH 61/73] adding of debug log --- library.bash | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/library.bash b/library.bash index 6d02a2f..a61e833 100644 --- a/library.bash +++ b/library.bash @@ -110,8 +110,6 @@ function get_and_check_object () { } # Adds object from a given file -# TODO Returns the OID in OID variable -# it can be found in the following HTTP reader returned: Location: "https://localhost:8443/midpoint/ws/rest/users/85e62669-d36b-41ce-b4f1-1ffdd9f66262" function add_object () { local TYPE=$1 local FILE=$2 @@ -123,7 +121,6 @@ function add_object () { if [ "$HTTP_CODE" -eq 201 ] || [ "$HTTP_CODE" -eq 202 ]; then - # get the real Location OID=$(grep -oP "Location: \K.*" $TMPFILE | awk -F "$TYPE/" '{print $2}') || (echo "Couldn't extract oid from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) echo "Oid created object: $OID" @@ -147,7 +144,7 @@ function execute_bulk_action () { echo "Executing bulk action from $FILE..." TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX) - curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/rpc/executeScript" -d @$FILE >$TMPFILE + (curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/rpc/executeScript" -d @$FILE >$TMPFILE) || (echo "Midpoint logs: " ; docker logs "complex_midpoint-server_1" ; return 1) local HTTP_CODE=$(sed '$!d' $TMPFILE) sed -i '$ d' $TMPFILE From 51365609bdc02c92610634830cf97d485f96b46c Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 17:04:01 +0200 Subject: [PATCH 62/73] Add MP_MEM_MAX, MP_MEM_INIT, MP_JAVA_OPTS vars MP_MEM_MAX was originally known as MP_MEM. MP_JAVA_OPTS can be used to send arbitrary options to Java that hosts midPoint. --- Dockerfile | 3 ++- container_files/usr-local-bin/start-midpoint.sh | 6 ++++-- demo/simple/.env | 3 ++- demo/simple/docker-compose.yml | 8 +++++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 19561a1..aceaac1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -91,7 +91,8 @@ ENV LOGOUT_URL https://localhost:8443/Shibboleth.sso/Logout # Other parameters ENV MP_KEYSTORE_PASSWORD_FILE /run/secrets/mp_keystore_password.txt -ENV MP_MEM 2048m +ENV MP_MEM_MAX 2048m +ENV MP_MEM_INIT 1024m ENV TIER_RELEASE not-released-yet ENV TIER_MAINTAINER tier diff --git a/container_files/usr-local-bin/start-midpoint.sh b/container_files/usr-local-bin/start-midpoint.sh index 0ccf340..ddc377b 100755 --- a/container_files/usr-local-bin/start-midpoint.sh +++ b/container_files/usr-local-bin/start-midpoint.sh @@ -11,7 +11,8 @@ function check () { # These variables have reasonable defaults in Dockerfile. So we will _not_ supply defaults here. # The composer or user has to make sure they are well defined. -check MP_MEM +check MP_MEM_MAX +check MP_MEM_INIT check MP_DIR check REPO_DATABASE_TYPE check REPO_USER @@ -23,7 +24,7 @@ check SSO_HEADER check AJP_ENABLED check AJP_PORT -java -Xmx$MP_MEM -Xms2048m -Dfile.encoding=UTF8 \ +java -Xmx$MP_MEM_MAX -Xms$MP_MEM_INIT -Dfile.encoding=UTF8 \ -Dmidpoint.home=$MP_DIR/var \ -Dmidpoint.repository.database=$REPO_DATABASE_TYPE \ -Dmidpoint.repository.jdbcUsername=$REPO_USER \ @@ -44,4 +45,5 @@ java -Xmx$MP_MEM -Xms2048m -Dfile.encoding=UTF8 \ -Dserver.tomcat.ajp.enabled=$AJP_ENABLED \ -Dserver.tomcat.ajp.port=$AJP_PORT \ -Dlogging.path=/tmp/logtomcat \ + $MP_JAVA_OPTS \ -jar $MP_DIR/lib/midpoint.war &>/tmp/logmidpoint-console diff --git a/demo/simple/.env b/demo/simple/.env index 84e50b2..2ae3222 100644 --- a/demo/simple/.env +++ b/demo/simple/.env @@ -9,4 +9,5 @@ REPO_DATABASE=registry REPO_USER=registry_user REPO_MISSING_SCHEMA_ACTION=create REPO_UPGRADEABLE_SCHEMA_ACTION=stop -MP_MEM=2048m +MP_MEM_MAX=2048m +MP_MEM_INIT=1024m diff --git a/demo/simple/docker-compose.yml b/demo/simple/docker-compose.yml index ecadd67..2d1788c 100644 --- a/demo/simple/docker-compose.yml +++ b/demo/simple/docker-compose.yml @@ -30,7 +30,9 @@ services: - REPO_UPGRADEABLE_SCHEMA_ACTION - REPO_SCHEMA_VERSION_IF_MISSING - REPO_SCHEMA_VARIANT - - MP_MEM + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS - TIER_BEACON_OPT_OUT networks: - net @@ -52,12 +54,12 @@ networks: driver: bridge secrets: - mp_host-key.pem: - file: ./configs-and-secrets/midpoint/httpd/host-key.pem mp_database_password.txt: file: ./configs-and-secrets/midpoint/application/database_password.txt mp_keystore_password.txt: file: ./configs-and-secrets/midpoint/application/keystore_password.txt + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem volumes: midpoint_mysql: From ceed5acdc210bb48d1e5a29973633d58966b4c74 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 17:34:02 +0200 Subject: [PATCH 63/73] Adapt demo/shibboleth (MP_MEM_*/MP_JAVA_OPTS) --- demo/shibboleth/.env | 3 ++- demo/shibboleth/docker-compose.yml | 32 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/demo/shibboleth/.env b/demo/shibboleth/.env index d731cbd..21ec0af 100644 --- a/demo/shibboleth/.env +++ b/demo/shibboleth/.env @@ -10,4 +10,5 @@ REPO_DATABASE=registry REPO_USER=registry_user REPO_MISSING_SCHEMA_ACTION=create REPO_UPGRADEABLE_SCHEMA_ACTION=stop -MP_MEM=2048m +MP_MEM_MAX=2048m +MP_MEM_INIT=1024m diff --git a/demo/shibboleth/docker-compose.yml b/demo/shibboleth/docker-compose.yml index 9c5be10..c656fe4 100644 --- a/demo/shibboleth/docker-compose.yml +++ b/demo/shibboleth/docker-compose.yml @@ -32,7 +32,9 @@ services: - REPO_UPGRADEABLE_SCHEMA_ACTION - REPO_SCHEMA_VERSION_IF_MISSING - REPO_SCHEMA_VARIANT - - MP_MEM + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS - TIER_BEACON_OPT_OUT networks: - net @@ -43,6 +45,12 @@ services: - mp_host-key.pem volumes: - midpoint_home:/opt/midpoint/var + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/host-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/cachain.pem - type: bind source: ./configs-and-secrets/midpoint/shibboleth/shibboleth2.xml target: /etc/shibboleth/shibboleth2.xml @@ -52,19 +60,11 @@ services: - type: bind source: ./configs-and-secrets/midpoint/shibboleth/sp-cert.pem target: /etc/shibboleth/sp-cert.pem - - type: bind - source: ./configs-and-secrets/midpoint/httpd/host-cert.pem - target: /etc/pki/tls/certs/host-cert.pem - - type: bind - source: ./configs-and-secrets/midpoint/httpd/host-cert.pem - target: /etc/pki/tls/certs/cachain.pem directory: build: ./directory/ - expose: - - "389" ports: - - "389:389" + - 389:389 networks: - net volumes: @@ -74,28 +74,28 @@ services: build: ./idp/ depends_on: - directory + ports: + - 4443:4443 environment: - JETTY_MAX_HEAP=64m - JETTY_BROWSER_SSL_KEYSTORE_PASSWORD=password - JETTY_BACKCHANNEL_SSL_KEYSTORE_PASSWORD=password networks: - net - ports: - - "4443:4443" networks: net: driver: bridge secrets: - mp_host-key.pem: - file: ./configs-and-secrets/midpoint/httpd/host-key.pem - mp_sp-key.pem: - file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem mp_database_password.txt: file: ./configs-and-secrets/midpoint/application/database_password.txt mp_keystore_password.txt: file: ./configs-and-secrets/midpoint/application/keystore_password.txt + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem + mp_sp-key.pem: + file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem volumes: midpoint_mysql: From 9a16f7b1a05c1bfbd72251ebed6106154c9bfa8a Mon Sep 17 00:00:00 2001 From: skublik Date: Wed, 3 Oct 2018 16:09:01 +0000 Subject: [PATCH 64/73] resolving all TODO --- demo/complex/tests/main.bats | 32 +++++++++++++++++++++++++++++--- demo/shibboleth/test.sh | 33 --------------------------------- library.bash | 36 ++++++++++++++++++++++++------------ 3 files changed, 53 insertions(+), 48 deletions(-) delete mode 100755 demo/shibboleth/test.sh diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 9daa28e..6ec5782 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -21,8 +21,8 @@ load ../../../library touch $BATS_TMPDIR/not-started wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1 wait_for_shibboleth_idp_start complex_idp_1 + wait_for_grouper_ui_start complex_grouper-ui_1 rm $BATS_TMPDIR/not-started -# TODO wait for shibboleth, grouper-ui, (also something other?) } @test "040 Check midPoint health" { @@ -61,11 +61,26 @@ load ../../../library check_health pwd >&2 ./upload-objects + search_and_check_object objectTemplates template-org-course search_and_check_object objectTemplates template-org-department search_and_check_object objectTemplates template-role-affiliation search_and_check_object objectTemplates template-role-generic-group -# TODO check other objects that were uploaded + + search_and_check_object orgs courses + search_and_check_object orgs departments + + search_and_check_object resources "OpenLDAP (directory)" + search_and_check_object resources "Grouper SQL/MQ" + search_and_check_object resources "SQL SIS courses (sources)" + search_and_check_object resources "SQL SIS persons (sources)" + + search_and_check_object roles metarole-affiliation + search_and_check_object roles metarole-course + search_and_check_object roles metarole-department + search_and_check_object roles metarole-generic-group + search_and_check_object roles role-grouper-sysadmin + search_and_check_object roles role-ldap-basic } @test "210 Test resource" { @@ -94,7 +109,18 @@ load ../../../library search_and_check_object users amorrison search_and_check_object users wprice search_and_check_object users mroberts - # TODO check in LDAP, check assignments etc + + check_ldap_account_by_user_name jsmith complex_directory_1 + check_ldap_account_by_user_name banderson complex_directory_1 + check_ldap_account_by_user_name kwhite complex_directory_1 + check_ldap_account_by_user_name whenderson complex_directory_1 + check_ldap_account_by_user_name ddavis complex_directory_1 + check_ldap_account_by_user_name cmorrison complex_directory_1 + check_ldap_account_by_user_name danderson complex_directory_1 + check_ldap_account_by_user_name amorrison complex_directory_1 + check_ldap_account_by_user_name wprice complex_directory_1 + check_ldap_account_by_user_name mroberts complex_directory_1 + # TODO check assignments etc } @test "230 Check 'TestUser230' in Midpoint and LDAP" { diff --git a/demo/shibboleth/test.sh b/demo/shibboleth/test.sh deleted file mode 100755 index c23693b..0000000 --- a/demo/shibboleth/test.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -trap 'exitcode=$? ; error "Exiting $0 because of an error ($exitcode) occurred" ; exit $exitcode' ERR - -cd "$(dirname "$0")" -. ../../test/common.sh - -heading "Cleaning up containers and volumes if they exist" -docker-compose down -v || true -ok "Done" -echo - -heading "Composing and starting Shibboleth..." -docker-compose up --build -d -ok "OK" -echo - -# TODO wait for Shib to start - -heading "Composing and starting midPoint..." -pushd ../../midpoint -MPDIR=`pwd` -docker-compose down -v || true -env AUTHENTICATION=shibboleth docker-compose up --build -d -popd -$MPDIR/test/t010-wait-for-start.sh -ok "OK" -echo - -heading "Test 100: Checking health via HTTP..." -$MPDIR/test/t100-check-health.sh -ok "Health check passed" -echo diff --git a/library.bash b/library.bash index a61e833..f22a759 100644 --- a/library.bash +++ b/library.bash @@ -45,11 +45,17 @@ function wait_for_midpoint_start () { generic_wait_for_log $1 "INFO (com.evolveum.midpoint.web.boot.MidPointSpringApplication): Started MidPointSpringApplication in" "midPoint to start" "midPoint did not start" $2 } -# Waits until Shibboleth IDP starts ... TODO refactor using generic waiting function +# Waits until Shibboleth IDP starts function wait_for_shibboleth_idp_start () { generic_wait_for_log $1 "INFO:oejs.Server:main: Started" "shibboleth idp to start" "shibboleth idp did not start" $2 } +# Waits until Grouper UI starts +function wait_for_grouper_ui_start () { + generic_wait_for_log $1 "INFO org.apache.catalina.startup.Catalina- Server startup in" "grouper ui to start" "grouper ui did not start" $2 +} + + # Checks the health of midPoint server function check_health () { echo Checking health... @@ -219,8 +225,8 @@ function delete_object () { # Results of the search are in the $SEARCH_RESULT_FILE # TODO check if the result is valid (i.e. not an error) - return 1 if invalid, otherwise return 0 ("no objects" is considered OK here) function search_objects_by_name () { - TYPE=$1 - NAME="$2" + local TYPE=$1 + local NAME="$2" TMPFILE=$(mktemp /tmp/search.XXXXXX) curl -k --write-out %{http_code} --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE/search" -d @- << EOF >$TMPFILE || (rm $TMPFILE ; return 1) @@ -233,15 +239,21 @@ function search_objects_by_name () { EOF - SEARCH_RESULT_FILE=$TMPFILE - - http_code=$(sed '$!d' <<<"$(cat $SEARCH_RESULT_FILE)") + local HTTP_CODE=$(sed '$!d' <<<"$(cat $TMPFILE)") + sed -i '$ d' $TMPFILE + cat $TMPFILE - sed -i '$ d' $SEARCH_RESULT_FILE - cat $SEARCH_RESULT_FILE - if [ "$http_code" -eq 200 ]; then + if [ "$HTTP_CODE" -eq 200 ]; then + SEARCH_RESULT_FILE=$TMPFILE return 0 else + echo "Error code: $HTTP_CODE" + if [ "$HTTP_CODE" -ge 500 ]; then + echo "Error message: Internal server error. Unexpected error occurred, if necessary please contact system administrator." + else + local ERROR_MESSAGE=$(xmllint --xpath "/*/*[local-name()='error']/text()" $TMPFILE) || (echo "Couldn't extract error message from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + echo "Error message: $ERROR_MESSAGE" + fi rm $SEARCH_RESULT_FILE return 1 fi @@ -335,7 +347,7 @@ function search_ldap_object_by_filter () { } function check_ldap_account_by_user_name () { - local NAME=$1 + local NAME="$1" local LDAP_CONTAINER=$2 search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME" $LDAP_CONTAINER search_objects_by_name users $NAME @@ -360,8 +372,8 @@ function check_ldap_account_by_user_name () { } function check_of_ldap_membership () { - local NAME_OF_USER=$1 - local NAME_OF_GROUP=$2 + local NAME_OF_USER="$1" + local NAME_OF_GROUP="$2" local LDAP_CONTAINER=$3 search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME_OF_USER" $LDAP_CONTAINER From 54f02b6e9f20c0e240724b7a8af83a43c3c64152 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 18:35:59 +0200 Subject: [PATCH 65/73] Add some demo/shibboleth tests (related to internal authentication) --- demo/shibboleth/tests/main.bats | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/demo/shibboleth/tests/main.bats b/demo/shibboleth/tests/main.bats index 3bc6fa1..8244ad0 100755 --- a/demo/shibboleth/tests/main.bats +++ b/demo/shibboleth/tests/main.bats @@ -9,7 +9,7 @@ load ../../../library } @test "010 Initialize and start containers" { - env docker-compose up -d + docker-compose up -d } @test "012 Wait for Shibboleth to start up" { @@ -50,6 +50,31 @@ load ../../../library [ "$status" -eq 200 ] } +@test "100 Check internally-authenticated REST call: get 'administrator'" { + check_health + get_and_check_object users 00000000-0000-0000-0000-000000000002 administrator +} + +@test "200 Shut down" { + docker-compose down +} + +@test "210 Start with internal authentication" { + env AUTHENTICATION=internal docker-compose up -d +} + +@test "210 Wait for midPoint to start up" { + wait_for_midpoint_start shibboleth_midpoint_server_1 +} + +@test "220 Check health" { + check_health +} + +@test "230 Check internal login redirection" { + curl -k --write-out %{redirect_url} --silent --output /dev/null https://localhost:8443/midpoint/self/dashboard | grep 'https:\/\/localhost:8443\/midpoint\/login' +} + @test "999 Clean up" { docker-compose down -v } From fa61ce0eb975ce1d485d034dd7bcfaaa5b0053b2 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 19:13:16 +0200 Subject: [PATCH 66/73] Consolidate demo/postgresql --- .../midpoint/shibboleth/idp-metadata.xml | 207 ------------------ .../midpoint/shibboleth/shibboleth2.xml | 136 ------------ .../midpoint/shibboleth/sp-cert.pem | 22 -- .../midpoint/shibboleth/sp-key.pem | 28 --- .../postgresql-to-be-removed/Dockerfile | 3 - .../container_files/init-user-db.sh | 12 - demo/postgresql-increment/docker-compose.yml | 23 -- .../midpoint-additions-for-standalone-run.yml | 37 ---- .../midpoint-additions.yml | 38 ---- .../postgresql/Dockerfile | 3 - .../container_files/init-user-db.sh | 12 - demo/{postgresql-full => postgresql}/.env | 6 +- .../application/database_password.txt | 0 .../application/keystore_password.txt | 0 .../midpoint/httpd/host-cert.pem | 0 .../midpoint/httpd/host-key.pem | 0 .../docker-compose.yml | 51 ++--- 17 files changed, 26 insertions(+), 552 deletions(-) delete mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml delete mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml delete mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem delete mode 100644 demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem delete mode 100644 demo/postgresql-full/postgresql-to-be-removed/Dockerfile delete mode 100755 demo/postgresql-full/postgresql-to-be-removed/container_files/init-user-db.sh delete mode 100644 demo/postgresql-increment/docker-compose.yml delete mode 100644 demo/postgresql-increment/midpoint-additions-for-standalone-run.yml delete mode 100644 demo/postgresql-increment/midpoint-additions.yml delete mode 100644 demo/postgresql-increment/postgresql/Dockerfile delete mode 100755 demo/postgresql-increment/postgresql/container_files/init-user-db.sh rename demo/{postgresql-full => postgresql}/.env (53%) rename demo/{postgresql-full => postgresql}/configs-and-secrets/midpoint/application/database_password.txt (100%) rename demo/{postgresql-full => postgresql}/configs-and-secrets/midpoint/application/keystore_password.txt (100%) rename demo/{postgresql-full => postgresql}/configs-and-secrets/midpoint/httpd/host-cert.pem (100%) rename demo/{postgresql-full => postgresql}/configs-and-secrets/midpoint/httpd/host-key.pem (100%) rename demo/{postgresql-full => postgresql}/docker-compose.yml (56%) diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml deleted file mode 100644 index 35914b7..0000000 --- a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/idp-metadata.xml +++ /dev/null @@ -1,207 +0,0 @@ - - - - - - - - example.org - - - - - - - -MIIDEzCCAfugAwIBAgIUS9SuTXwsFVVG+LjOEAbLqqT/el0wDQYJKoZIhvcNAQEL -BQAwFTETMBEGA1UEAwwKaWRwdGVzdGJlZDAeFw0xNTEyMTEwMjIwMjZaFw0zNTEy -MTEwMjIwMjZaMBUxEzARBgNVBAMMCmlkcHRlc3RiZWQwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQCMAoDHx8xCIfv/6QKqt9mcHYmEJ8y2dKprUbpdcOjH -YvNPIl/lHPsUyrb+Nc+q2CDeiWjVk1mWYq0UpIwpBMuw1H6+oOqr4VQRi65pin0M -SfE0MWIaFo5FPvpvoptkHD4gvREbm4swyXGMczcMRfqgalFXhUD2wz8W3XAM5Cq2 -03XeJbj6TwjvKatG5XPdeUe2FBGuOO2q54L1hcIGnLMCQrg7D31lR13PJbjnJ0No -5C3k8TPuny6vJsBC03GNLNKfmrKVTdzr3VKp1uay1G3DL9314fgmbl8HA5iRQmy+ -XInUU6/8NXZSF59p3ITAOvZQeZsbJjg5gGDip5OZo9YlAgMBAAGjWzBZMB0GA1Ud -DgQWBBRPlM4VkKZ0U4ec9GrIhFQl0hNbL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GjWzBZMB0GA1Ud -DgQWBBStTyogRPuAVG6q7yPyav1uvE+7pTA4BgNVHREEMTAvggppZHB0ZXN0YmVk -hiFodHRwczovL2lkcHRlc3RiZWQvaWRwL3NoaWJib2xldGgwDQYJKoZIhvcNAQEL -BQADggEBAFMfoOv+oISGjvamq7+Y4G7ep5vxlAPeK3RATYPYvAmyH946qZXh98ni -QXyuqZW5P5eEt86toY45IwDU5r09SKwHughEe99iiEkxh0mb2qo84qX9/qcg+kyN -jeLd/OSyolpUCEFNwOFcog7pj7Eer+6AHbwTn1Mjb5TBsKwtDMJsaxPvdj0u7M5r -xL/wHkFhn1rCo2QiojzjSlV3yLTh49iTyhE3cG+RxaNKDCxhp0jSSLX1BW/ZoPA8 -+PMJEA+Q0QbyRD8aJOHN5O8jGxCa/ZzcOnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H -p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= - - - - - - - urn:mace:shibboleth:1.0:nameIdentifier - urn:oasis:names:tc:SAML:2.0:nameid-format:transient - - - - - - - - - - - - - localhost - - - - - - -MIIDEzCCAfugAwIBAgIUS9SuTXwsFVVG+LjOEAbLqqT/el0wDQYJKoZIhvcNAQEL -BQAwFTETMBEGA1UEAwwKaWRwdGVzdGJlZDAeFw0xNTEyMTEwMjIwMjZaFw0zNTEy -MTEwMjIwMjZaMBUxEzARBgNVBAMMCmlkcHRlc3RiZWQwggEiMA0GCSqGSIb3DQEB -AQUAA4IBDwAwggEKAoIBAQCMAoDHx8xCIfv/6QKqt9mcHYmEJ8y2dKprUbpdcOjH -YvNPIl/lHPsUyrb+Nc+q2CDeiWjVk1mWYq0UpIwpBMuw1H6+oOqr4VQRi65pin0M -SfE0MWIaFo5FPvpvoptkHD4gvREbm4swyXGMczcMRfqgalFXhUD2wz8W3XAM5Cq2 -03XeJbj6TwjvKatG5XPdeUe2FBGuOO2q54L1hcIGnLMCQrg7D31lR13PJbjnJ0No -5C3k8TPuny6vJsBC03GNLNKfmrKV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pq0eq/9MAsVlIIXEa8 -9WfH8J2kFcTOfoWtIc70b7TLZQsx4YnNcnrGLSUEcstFyPLX+Xtv5SNZF89OOIxX -VNjNvgE5DbJb9hMM4UAFqI+1bo9QqtxwThjc/sOvIxzNAgMBAAGjWzBZMB0GA1Ud -DgQWBBStTyogRPuAVG6q7yPyav1uvE+7pTA4BgNVHREEMTAvggppZHB0ZXN0YmVk -hiFodHRwczovL2lkcHRlc3RiZWQvaWRwL3NoaWJib2xldGgwDQYJKoZIhvcNAQEL -BQADggEBAFMfoOv+oISGjvamq7+Y4G7ep5vxlAPeK3RATYPYvAmyH946qZXh98ni -QXyuqZW5P5eEt86toY45IwDU5r09SKwHughEe99iiEkxh0mb2qo84qX9/qcg+kyN -jeLd/OSyolpUCEFNwOFcog7pj7Eer+6AHbwTn1Mjb5TBsKwtDMJsaxPvdj0u7M5r -xL/wHkFhn1rCo2QiojzjSlV3yLTh49iTyhE3cG+RxaNKDCxhp0jSSLX1BW/ZoPA8 -+PMJEA+Q0QbyRD8aJOHN5O8jGxCa/ZzcOnYVL6AsEXoDiY3vAUYh1FUonOWw0m9H -p+tGUbGS2l873J5PrsbpeKEVR/IIoKo= - - - - - - - - - - - - - - diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml deleted file mode 100644 index a644264..0000000 --- a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/shibboleth2.xml +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - - - - - - - - - - - - SAML2 - - - - SAML2 Local - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem deleted file mode 100644 index 0f5474e..0000000 --- a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-cert.pem +++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xTJnK+tBn/R3KrgxLKyMvoUzAPl -mhVq1dh+ZEtbsRpQRRubP6nm9kXNma0cXrkJSzuWM0W+l/xSOOYiSRRk3XWJfVjn -9jQlcJRh5SOkKN08oZHrCYKxToEuOfV8PtRj3T80DhsBTv2SHqhg4cBhzQPb0Kjm -9m4IkYOz8c5ZtuHDGnqMHw60Nyt+jyik4mMFP2frcOVP0W0sgwcfHllYzHoA/Khq -Yk3TBVs1BjPuNDJWHct8Eo68YP2/ZvzqfVM87Q== ------END CERTIFICATE----- diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem b/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem deleted file mode 100644 index b4c7a68..0000000 --- a/demo/postgresql-full/configs-and-secrets/midpoint/shibboleth/sp-key.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDDm/XPGUz3jJoG -yyA01shQnBZfFsbGBKzYBYF6DZoSL9VB3ZQTmK9lqQ0mWpZInIejbETiTF5LIEHG -KeNLKGak1qjEhypCyBbSDGjhIQejeRRdY+j6h/+mPoKyW62xIllYZNFXR0chO9pZ -f40zx5cx+C6YkXDLdEx0tpZCFjUPKLaM2g74Nmd82A/I94RlyY5Fqh4QgP1B1l8e -1yBN/ZB9Ier7GxPAcHpGjm3tgPaZrwqtv9dwNN+yreol6Z3suE+PmUaaFhIyANuD -ASRmBnWQE4+V+w/YG9fmeKm/tV3ULlhea/40NHxXfIBYELtkB6fEaaueRpJVeelS -mVSwYabVAgMBAAECggEAeQxOdTaG9ro/puyUpZ40oA23mmiR4YCLJbNiiJFaQt7u -7a+dLvNRt2uCA7YTQiP7nBooFpKD16HCkkrhqWT7AA8GqXero2AHHz0mugqim3sW -KyTkzATVI5+TaaRqPC+xco4RLh2h2uMbID9atixRWE7pJuj6EC2MEr3bBlKPyyyj -gYEi7PLZC5oEMHCZS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- diff --git a/demo/postgresql-full/postgresql-to-be-removed/Dockerfile b/demo/postgresql-full/postgresql-to-be-removed/Dockerfile deleted file mode 100644 index dcaf4d6..0000000 --- a/demo/postgresql-full/postgresql-to-be-removed/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM postgres:9.5 - -COPY container_files/* /docker-entrypoint-initdb.d/ diff --git a/demo/postgresql-full/postgresql-to-be-removed/container_files/init-user-db.sh b/demo/postgresql-full/postgresql-to-be-removed/container_files/init-user-db.sh deleted file mode 100755 index 95df619..0000000 --- a/demo/postgresql-full/postgresql-to-be-removed/container_files/init-user-db.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -echo Creating midPoint user and database - -psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL - CREATE USER midpoint WITH PASSWORD '456654' LOGIN SUPERUSER; - CREATE DATABASE midpoint WITH OWNER = midpoint ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8' CONNECTION LIMIT = -1; -EOSQL - -echo midPoint user and database were created - diff --git a/demo/postgresql-increment/docker-compose.yml b/demo/postgresql-increment/docker-compose.yml deleted file mode 100644 index 79a3738..0000000 --- a/demo/postgresql-increment/docker-compose.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: "3.3" - -services: - postgresql: - build: ./postgresql/ - environment: - - POSTGRES_PASSWORD=password - expose: - - 5432 - ports: - - 5432:5432 - networks: - - net - volumes: - - data:/var/lib/postgresql/data - - -networks: - net: - driver: bridge - -volumes: - data: diff --git a/demo/postgresql-increment/midpoint-additions-for-standalone-run.yml b/demo/postgresql-increment/midpoint-additions-for-standalone-run.yml deleted file mode 100644 index 2e3cabe..0000000 --- a/demo/postgresql-increment/midpoint-additions-for-standalone-run.yml +++ /dev/null @@ -1,37 +0,0 @@ -# -# This is a file with additions to ../midpoint/docker-compose.yml file, to be used in the following way: -# -# (in this directory) -# -# $ docker-compose up -# -# (in ../midpoint directory) -# -# $ docker-compose -f docker-compose.yml -f ../demo/postgresql/midpoint-additions-for-standalone-run.yml up midpoint-server -# -# It expects that PostgreSQL is started independently of midPoint. When executing the containers in this way, there are two compositions with the following containers: -# -# "midpoint" -# -# - midpoint-server -# -# "postgresql" -# -# - postgresql -# - -version: "3.3" - -services: - midpoint-server: - environment: - - REPO_DATABASE_TYPE=postgresql - - REPO_HOST=postgresql - - REPO_DATABASE=midpoint - - REPO_USER=midpoint - networks: - - postgresql_net - -networks: - postgresql_net: - external: true diff --git a/demo/postgresql-increment/midpoint-additions.yml b/demo/postgresql-increment/midpoint-additions.yml deleted file mode 100644 index 5cf43d4..0000000 --- a/demo/postgresql-increment/midpoint-additions.yml +++ /dev/null @@ -1,38 +0,0 @@ -# -# This is a file with additions to ../midpoint/docker-compose.yml file, to be used in the following way: -# -# (in ../midpoint directory) -# -# $ docker-compose -f docker-compose.yml -f ../demo/postgresql/midpoint-additions.yml up midpoint-server postgresql -# -# It expects that PostgreSQL is started as part of midPoint composition. So there will be three containers there: -# -# 1) midpoint-server -# 2) postgresql -# - -version: "3.3" - -services: - postgresql: - build: ../demo/postgresql/postgresql/ - environment: - - POSTGRES_PASSWORD=password - expose: - - 5432 - ports: - - 5432:5432 - networks: - - back - volumes: - - postgresql_data:/var/lib/postgresql/data - - midpoint-server: - environment: - - REPO_DATABASE_TYPE=postgresql - - REPO_HOST=postgresql - - REPO_DATABASE=midpoint - - REPO_USER=midpoint - -volumes: - postgresql_data: diff --git a/demo/postgresql-increment/postgresql/Dockerfile b/demo/postgresql-increment/postgresql/Dockerfile deleted file mode 100644 index dcaf4d6..0000000 --- a/demo/postgresql-increment/postgresql/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM postgres:9.5 - -COPY container_files/* /docker-entrypoint-initdb.d/ diff --git a/demo/postgresql-increment/postgresql/container_files/init-user-db.sh b/demo/postgresql-increment/postgresql/container_files/init-user-db.sh deleted file mode 100755 index 95df619..0000000 --- a/demo/postgresql-increment/postgresql/container_files/init-user-db.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -set -e - -echo Creating midPoint user and database - -psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL - CREATE USER midpoint WITH PASSWORD '456654' LOGIN SUPERUSER; - CREATE DATABASE midpoint WITH OWNER = midpoint ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'en_US.utf8' LC_CTYPE = 'en_US.utf8' CONNECTION LIMIT = -1; -EOSQL - -echo midPoint user and database were created - diff --git a/demo/postgresql-full/.env b/demo/postgresql/.env similarity index 53% rename from demo/postgresql-full/.env rename to demo/postgresql/.env index 0ab53eb..a92b22a 100644 --- a/demo/postgresql-full/.env +++ b/demo/postgresql/.env @@ -1,5 +1,7 @@ # These parameters can be overridden by setting environment variables before calling docker-compose up -AUTHENTICATION=internal ENV=demo USERTOKEN= -MEM=2048m +REPO_MISSING_SCHEMA_ACTION=create +REPO_UPGRADEABLE_SCHEMA_ACTION=stop +MP_MEM_MAX=2048m +MP_MEM_INIT=1024m diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/application/database_password.txt b/demo/postgresql/configs-and-secrets/midpoint/application/database_password.txt similarity index 100% rename from demo/postgresql-full/configs-and-secrets/midpoint/application/database_password.txt rename to demo/postgresql/configs-and-secrets/midpoint/application/database_password.txt diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/application/keystore_password.txt b/demo/postgresql/configs-and-secrets/midpoint/application/keystore_password.txt similarity index 100% rename from demo/postgresql-full/configs-and-secrets/midpoint/application/keystore_password.txt rename to demo/postgresql/configs-and-secrets/midpoint/application/keystore_password.txt diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-cert.pem b/demo/postgresql/configs-and-secrets/midpoint/httpd/host-cert.pem similarity index 100% rename from demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-cert.pem rename to demo/postgresql/configs-and-secrets/midpoint/httpd/host-cert.pem diff --git a/demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-key.pem b/demo/postgresql/configs-and-secrets/midpoint/httpd/host-key.pem similarity index 100% rename from demo/postgresql-full/configs-and-secrets/midpoint/httpd/host-key.pem rename to demo/postgresql/configs-and-secrets/midpoint/httpd/host-key.pem diff --git a/demo/postgresql-full/docker-compose.yml b/demo/postgresql/docker-compose.yml similarity index 56% rename from demo/postgresql-full/docker-compose.yml rename to demo/postgresql/docker-compose.yml index a4a1ec6..60879d7 100644 --- a/demo/postgresql-full/docker-compose.yml +++ b/demo/postgresql/docker-compose.yml @@ -1,53 +1,48 @@ version: "3.3" services: - postgresql: + midpoint_data: image: postgres:9.5 environment: - - POSTGRES_PASSWORD_FILE=/run/secrets/m_database_password.txt + - POSTGRES_PASSWORD_FILE=/run/secrets/mp_database_password.txt - POSTGRES_USER=midpoint - POSTGRES_INITDB_ARGS=--lc-collate=en_US.utf8 --lc-ctype=en_US.utf8 ports: - 5432:5432 networks: - - back + - net secrets: - - m_database_password.txt + - mp_database_password.txt volumes: - midpoint_data:/var/lib/postgresql/data - midpoint-server: + midpoint_server: image: tier/midpoint:latest ports: - 8443:443 environment: - - AUTHENTICATION - ENV - USERTOKEN - REPO_DATABASE_TYPE=postgresql - - REPO_HOST=postgresql + - REPO_HOST=midpoint_data - REPO_DATABASE=midpoint - REPO_USER=midpoint - - MEM + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS - TIER_BEACON_OPT_OUT networks: - - back + - net secrets: - - m_database_password.txt - - m_keystore_password.txt - - m_sp-key.pem - - m_host-key.pem + - mp_database_password.txt + - mp_keystore_password.txt + - mp_host-key.pem volumes: - midpoint_home:/opt/midpoint/var - - type: bind - source: ./configs-and-secrets/midpoint/shibboleth/shibboleth2.xml - target: /etc/shibboleth/shibboleth2.xml - - type: bind - source: ./configs-and-secrets/midpoint/shibboleth/idp-metadata.xml - target: /etc/shibboleth/idp-metadata.xml - - type: bind - source: ./configs-and-secrets/midpoint/shibboleth/sp-cert.pem - target: /etc/shibboleth/sp-cert.pem - type: bind source: ./configs-and-secrets/midpoint/httpd/host-cert.pem target: /etc/pki/tls/certs/host-cert.pem @@ -56,18 +51,16 @@ services: target: /etc/pki/tls/certs/cachain.pem networks: - back: + net: driver: bridge secrets: - m_host-key.pem: - file: ./configs-and-secrets/midpoint/httpd/host-key.pem - m_sp-key.pem: - file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem - m_database_password.txt: + mp_database_password.txt: file: ./configs-and-secrets/midpoint/application/database_password.txt - m_keystore_password.txt: + mp_keystore_password.txt: file: ./configs-and-secrets/midpoint/application/keystore_password.txt + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem volumes: midpoint_data: From b24d7a6e30c2315e15b85f7a2e2d031a4be6f08b Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 19:13:27 +0200 Subject: [PATCH 67/73] Add demo/extrepo (external repository) --- demo/extrepo/.env | 7 +++ .../application/database_password.txt | 1 + .../application/keystore_password.txt | 1 + .../midpoint/httpd/host-cert.pem | 22 ++++++++ .../midpoint/httpd/host-key.pem | 28 ++++++++++ demo/extrepo/docker-compose.yml | 53 +++++++++++++++++++ 6 files changed, 112 insertions(+) create mode 100644 demo/extrepo/.env create mode 100644 demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt create mode 100644 demo/extrepo/configs-and-secrets/midpoint/application/keystore_password.txt create mode 100644 demo/extrepo/configs-and-secrets/midpoint/httpd/host-cert.pem create mode 100644 demo/extrepo/configs-and-secrets/midpoint/httpd/host-key.pem create mode 100644 demo/extrepo/docker-compose.yml diff --git a/demo/extrepo/.env b/demo/extrepo/.env new file mode 100644 index 0000000..a92b22a --- /dev/null +++ b/demo/extrepo/.env @@ -0,0 +1,7 @@ +# These parameters can be overridden by setting environment variables before calling docker-compose up +ENV=demo +USERTOKEN= +REPO_MISSING_SCHEMA_ACTION=create +REPO_UPGRADEABLE_SCHEMA_ACTION=stop +MP_MEM_MAX=2048m +MP_MEM_INIT=1024m diff --git a/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt b/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt new file mode 100644 index 0000000..11bff19 --- /dev/null +++ b/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt @@ -0,0 +1 @@ +WJzesbe3poNZ91qIbmR7 diff --git a/demo/extrepo/configs-and-secrets/midpoint/application/keystore_password.txt b/demo/extrepo/configs-and-secrets/midpoint/application/keystore_password.txt new file mode 100644 index 0000000..1d40192 --- /dev/null +++ b/demo/extrepo/configs-and-secrets/midpoint/application/keystore_password.txt @@ -0,0 +1 @@ +changeit diff --git a/demo/extrepo/configs-and-secrets/midpoint/httpd/host-cert.pem b/demo/extrepo/configs-and-secrets/midpoint/httpd/host-cert.pem new file mode 100644 index 0000000..9b1021b --- /dev/null +++ b/demo/extrepo/configs-and-secrets/midpoint/httpd/host-cert.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDqDCCApCgAwIBAgIJAMOSkn4oS2aAMA0GCSqGSIb3DQEBCwUAMGkxCzAJBgNV +BAYTAlVTMQswCQYDVQQIDAJNSTESMBAGA1UEBwwJQW5uIEFyYm9yMRcwFQYDVQQK +DA5JbnRlcm5ldDIvVElFUjEgMB4GA1UEAwwXbWlkcG9pbnQuc3AuZXhhbXBsZS5v +cmcwHhcNMTgwOTE0MDU1OTQ1WhcNMTkwOTE0MDU1OTQ1WjBpMQswCQYDVQQGEwJV +UzELMAkGA1UECAwCTUkxEjAQBgNVBAcMCUFubiBBcmJvcjEXMBUGA1UECgwOSW50 +ZXJuZXQyL1RJRVIxIDAeBgNVBAMMF21pZHBvaW50LnNwLmV4YW1wbGUub3JnMIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApj/b7MEUSfu3oXMfNgRwTse7 +a5UV7Jswf1M/ZN/ZZkAkIxNBevZgozjesvLPWrmsTgONi7XigJUJvCjdjmlW9eDM +lri/rkD8HuOR1DQCVKL9nvoS2c3D7sq5Emda3V8Tlj82VqfEmePd3sajx7mcTfbH +8jwAL9NhkC+WMib5IpjLGpG0FEAC0ha7Lxb+7jIiqHVJaqLXJGCyGN4mh6c1Q9S1 +f8RVTiW2a8x22G+9wnZYbkiA2Kxls177imHlhSz8EdvV4IpGw1amrEWhhuDEum7B +vZ1xQDLatgRqh4qAKLIVYeRnJ8H1FelMa90qB4G08MIPifmTsQwqJyBYaEdgWQID +AQABo1MwUTAdBgNVHQ4EFgQUqb9BteODF6wv5R57aEON/wGXMiowHwYDVR0jBBgw +FoAUqb9BteODF6wv5R57aEON/wGXMiowDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG +9w0BAQsFAAOCAQEAAcKhxI+tSItrXmqC0PSmgWyAYpqbkz6W/cefTutXqhIgY09f +h0LSv7ogTahoGpyiZk9vy6u3OE9bYwxapEfa4KBjO6HxBMIVBBb3RegVjoPzjElN +BDwAx0VGFcZTXwMxDWycWdG8ql7rCZBvS50w04uTaIgnGmqXAdWWmBgfJ9cRbxW+ +JwO/mOl1QM1lR/5142NpvuUVWlmZSKEGydE5A1qPz2wpDbBR1ym1BQNS4NEqw6Kp +GSB8jKyCS1Ve0v2wVze2038Wukz02dq9uKPTIO3T+B+ibZmxn6Op/kFCc1/kK5NS +Q6JdO1B6KquGAYdGmKAcQ19mv+jqGktqWEEf0g== +-----END CERTIFICATE----- diff --git a/demo/extrepo/configs-and-secrets/midpoint/httpd/host-key.pem b/demo/extrepo/configs-and-secrets/midpoint/httpd/host-key.pem new file mode 100644 index 0000000..5746e59 --- /dev/null +++ b/demo/extrepo/configs-and-secrets/midpoint/httpd/host-key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9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UEPegYlDy +LXCkaKWxHQKBgQCmyHSKL2lrJkEcOwakEU2acNCE3Gno/cT9SYmV83kvQ8JEqmrW +QqnRsp9aXIljGscapPmKsmnNt5vNp1AxFAHTYh88NRLczsMIyZj0ZwgHVUI6KhC7 +5Psa78YQQBlMt2/g9TSsnuE+rYgF6mpKFiNm0Vasqeg47uzn2mdzqlUGTQKBgE04 +JutkTUY+h1pL5vYxWKpVDfy19z7H2tFxT1FowPrBneeLSyRI88Ac5I/yLdRlVeY9 +0LOmEr5Igwj3MsKgg7KVKfVLgdo/LrW3Jt2Kt3onKNXDkoBPoNUjwH0QC0Boiue+ +VK0gR0kVdm+bXccbxR+im+NwZNE0NLg6Qqu3RredAoGBALuVoqbPPmTCZXYG328H +bzOs2aiR7BzPSVByV+qG6jW7w03RAnFPJZp7HMU+ViI5VY0wabUscMSvz5163+gM +4KwY3v9ZjZzZGukIfLuudkdqtaiVOx/KeAC0n+nG21YU+wpZww8gkfHh1/sa2CME +CWYCgOnmiTHcj83UaTqEXtmv +-----END PRIVATE KEY----- diff --git a/demo/extrepo/docker-compose.yml b/demo/extrepo/docker-compose.yml new file mode 100644 index 0000000..43c1d5d --- /dev/null +++ b/demo/extrepo/docker-compose.yml @@ -0,0 +1,53 @@ +version: "3.3" + +services: + midpoint_server: + image: tier/midpoint:latest + ports: + - 8443:443 + environment: + - ENV + - USERTOKEN + - REPO_DATABASE_TYPE + - REPO_JDBC_URL + - REPO_HOST + - REPO_PORT + - REPO_DATABASE + - REPO_USER + - REPO_MISSING_SCHEMA_ACTION + - REPO_UPGRADEABLE_SCHEMA_ACTION + - REPO_SCHEMA_VERSION_IF_MISSING + - REPO_SCHEMA_VARIANT + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS + - TIER_BEACON_OPT_OUT + networks: + - net + secrets: + - mp_database_password.txt + - mp_keystore_password.txt + - mp_host-key.pem + volumes: + - midpoint_home:/opt/midpoint/var + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/host-cert.pem + - type: bind + source: ./configs-and-secrets/midpoint/httpd/host-cert.pem + target: /etc/pki/tls/certs/cachain.pem + +networks: + net: + driver: bridge + +secrets: + mp_database_password.txt: + file: ./configs-and-secrets/midpoint/application/database_password.txt + mp_keystore_password.txt: + file: ./configs-and-secrets/midpoint/application/keystore_password.txt + mp_host-key.pem: + file: ./configs-and-secrets/midpoint/httpd/host-key.pem + +volumes: + midpoint_home: From ebdc5dd0653399e767839527f575b718e8953e8e Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 20:24:53 +0200 Subject: [PATCH 68/73] Fix demo/extrepo scenario --- demo/extrepo/.env | 2 ++ .../midpoint/application/database_password.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/demo/extrepo/.env b/demo/extrepo/.env index a92b22a..a29d2b2 100644 --- a/demo/extrepo/.env +++ b/demo/extrepo/.env @@ -1,6 +1,8 @@ # These parameters can be overridden by setting environment variables before calling docker-compose up ENV=demo USERTOKEN= +REPO_JDBC_URL=default +REPO_PORT=default REPO_MISSING_SCHEMA_ACTION=create REPO_UPGRADEABLE_SCHEMA_ACTION=stop MP_MEM_MAX=2048m diff --git a/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt b/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt index 11bff19..d71d29d 100644 --- a/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt +++ b/demo/extrepo/configs-and-secrets/midpoint/application/database_password.txt @@ -1 +1 @@ -WJzesbe3poNZ91qIbmR7 +oracle From 4dd717c7cd75c8ba70b58d99b4b195092222d1d9 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 22:02:25 +0200 Subject: [PATCH 69/73] Add demo/postgresql tests --- Jenkinsfile | 1 + demo/postgresql/tests/main.bats | 34 +++++++++++++++++++++++++++++++++ tests/main.bats | 7 ++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 demo/postgresql/tests/main.bats diff --git a/Jenkinsfile b/Jenkinsfile index 7831838..23b655b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,6 +57,7 @@ pipeline { sh '(cd demo/simple ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' sh '(cd demo/shibboleth ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' + sh '(cd demo/postgresql ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' // temporarily disabled //sh '(cd demo/complex ; bats tests ) 2>&1 | tee -a debug ; test ${PIPESTATUS[0]} -eq 0' diff --git a/demo/postgresql/tests/main.bats b/demo/postgresql/tests/main.bats new file mode 100755 index 0000000..5d82e6e --- /dev/null +++ b/demo/postgresql/tests/main.bats @@ -0,0 +1,34 @@ +#!/usr/bin/env bats + +load ../../../common +load ../../../library + +@test "000 Cleanup before running the tests" { + run docker-compose down -v +} + +@test "010 Initialize and start midPoint" { + docker-compose up -d + wait_for_midpoint_start postgresql_midpoint_server_1 +} + +@test "010 Check health" { + check_health +} + +@test "100 Get 'administrator'" { + check_health + get_and_check_object users 00000000-0000-0000-0000-000000000002 administrator +} + +@test "110 And and get 'test110'" { + check_health + echo "test110" >/tmp/test110.xml + add_object users /tmp/test110.xml + rm /tmp/test110.xml + search_and_check_object users test110 +} + +@test "999 Clean up" { + docker-compose down -v +} diff --git a/tests/main.bats b/tests/main.bats index 8b10b47..36dc6c1 100755 --- a/tests/main.bats +++ b/tests/main.bats @@ -25,7 +25,12 @@ load ../common cd demo/shibboleth ; docker-compose down -v ; true } -@test "120 Cleanup before further tests - demo/complex" { +@test "120 Cleanup before further tests - demo/postgresql" { + docker ps -a + cd demo/postgresql ; docker-compose down -v ; true +} + +@test "130 Cleanup before further tests - demo/complex" { docker ps -a cd demo/complex ; docker-compose down -v ; true } From 953e88703843c03abdd441259ac3e105cba61561 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 22:04:11 +0200 Subject: [PATCH 70/73] Re-enable pushing of 'master' image to Docker hub --- Jenkinsfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 23b655b..dac92f0 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -71,7 +71,7 @@ pipeline { } } } -/* stage ('Push') { + stage ('Push') { steps { script { docker.withRegistry('https://registry.hub.docker.com/', "dockerhub-$maintainer") { @@ -81,11 +81,10 @@ pipeline { } } } -*/ stage ('Notify') { steps { echo "$maintainer" - slackSend color: 'good', message: "$maintainer/$imagename:$tag built but NOT pushed to DockerHub (push temporarily disabled for this branch)" + slackSend color: 'good', message: "$maintainer/$imagename:$tag pushed to DockerHub" } } } From 0e5b5bdd7d696448266c5e936e7973691b7cec0d Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 22:42:41 +0200 Subject: [PATCH 71/73] Adapt demo/complex to new conventions Changes are in the naming of containers and secrets; some environment variables were changed as well. --- demo/complex/.env | 9 +- demo/complex/README.md | 2 +- .../application/grouper.client.properties | 2 +- .../application/grouper.hibernate.properties | 2 +- demo/complex/docker-compose.yml | 104 +++++++++--------- .../Dockerfile | 0 .../{grouper-data => grouper_data}/Dockerfile | 0 .../conf/grouper.hibernate.properties | 0 .../container_files/conf/grouper.properties | 0 .../container_files/conf/subject.properties | 0 .../container_files/seed-data/demo.gsh | 0 .../{grouper-ui => grouper_ui}/Dockerfile | 0 .../container_files/shibboleth/shibd.logger | 0 .../resources/scriptedsql-grouper2.xml | 2 +- .../Dockerfile | 0 ....bundles.db.scriptedsql-2.2.6-SNAPSHOT.jar | Bin .../mp-home/lib/amqp-client-5.3.0.jar | Bin .../mp-home/res/grouper/SchemaScript.groovy | 0 .../mp-home/res/grouper/SearchScript.groovy | 0 .../mp-home/res/grouper/TestScript.groovy | 0 .../mp-home/res/grouper2/SchemaScript.groovy | 0 .../mp-home/res/grouper2/SearchScript.groovy | 0 .../mp-home/res/grouper2/SyncScript.groovy | 0 .../mp-home/res/grouper2/TestScript.groovy | 0 .../res/sis-persons/SchemaScript.groovy | 0 .../res/sis-persons/SearchScript.groovy | 0 .../mp-home/res/sis-persons/TestScript.groovy | 0 .../mp-home/res/sis/SchemaScript.groovy | 0 .../mp-home/res/sis/SearchScript.groovy | 0 .../mp-home/res/sis/TestScript.groovy | 0 .../mp-home/schema/user-schema.xsd | 0 demo/complex/tests/main.bats | 7 +- 32 files changed, 68 insertions(+), 60 deletions(-) rename demo/complex/{grouper-daemon => grouper_daemon}/Dockerfile (100%) rename demo/complex/{grouper-data => grouper_data}/Dockerfile (100%) rename demo/complex/{grouper-data => grouper_data}/container_files/conf/grouper.hibernate.properties (100%) rename demo/complex/{grouper-data => grouper_data}/container_files/conf/grouper.properties (100%) rename demo/complex/{grouper-data => grouper_data}/container_files/conf/subject.properties (100%) rename demo/complex/{grouper-data => grouper_data}/container_files/seed-data/demo.gsh (100%) rename demo/complex/{grouper-ui => grouper_ui}/Dockerfile (100%) rename demo/complex/{grouper-ui => grouper_ui}/container_files/shibboleth/shibd.logger (100%) rename demo/complex/{midpoint-server => midpoint_server}/Dockerfile (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/icf-connectors/net.tirasa.connid.bundles.db.scriptedsql-2.2.6-SNAPSHOT.jar (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/lib/amqp-client-5.3.0.jar (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper/SchemaScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper/SearchScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper/TestScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper2/SchemaScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper2/SearchScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper2/SyncScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/grouper2/TestScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/sis-persons/SchemaScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/sis-persons/SearchScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/sis-persons/TestScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/sis/SchemaScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/sis/SearchScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/res/sis/TestScript.groovy (100%) rename demo/complex/{midpoint-server => midpoint_server}/container_files/mp-home/schema/user-schema.xsd (100%) diff --git a/demo/complex/.env b/demo/complex/.env index cabe686..d58a3c3 100644 --- a/demo/complex/.env +++ b/demo/complex/.env @@ -3,14 +3,15 @@ ENV=demo USERTOKEN= REPO_DATABASE_TYPE=mariadb REPO_JDBC_URL=default -REPO_HOST=midpoint-data +REPO_HOST=midpoint_data REPO_PORT=default REPO_DATABASE=registry REPO_USER=registry_user REPO_MISSING_SCHEMA_ACTION=create REPO_UPGRADEABLE_SCHEMA_ACTION=stop -REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt -KEYSTORE_PASSWORD_FILE=/run/secrets/m_keystore_password.txt -MEM=2048m +REPO_PASSWORD_FILE=/run/secrets/mp_database_password.txt +MP_KEYSTORE_PASSWORD_FILE=/run/secrets/mp_keystore_password.txt +MP_MEM_MAX=2048m +MP_MEM_INIT=1024m LOGOUT_URL=https://localhost:8443/Shibboleth.sso/Logout SSO_HEADER=uid diff --git a/demo/complex/README.md b/demo/complex/README.md index 4d99adf..7e24d42 100644 --- a/demo/complex/README.md +++ b/demo/complex/README.md @@ -2,7 +2,7 @@ This is a demonstration of using midPoint dockerization for TIER environment in # Building and execution ``` -$ ../../midpoint/build.sh +$ ../../build.sh $ docker-compose up --build ``` diff --git a/demo/complex/configs-and-secrets/grouper/application/grouper.client.properties b/demo/complex/configs-and-secrets/grouper/application/grouper.client.properties index ee9895f..d25ad96 100644 --- a/demo/complex/configs-and-secrets/grouper/application/grouper.client.properties +++ b/demo/complex/configs-and-secrets/grouper/application/grouper.client.properties @@ -48,7 +48,7 @@ grouperClient.ldap.password = # url of web service, should include everything up to the first resource to access # e.g. http://groups.school.edu:8090/grouper-ws/servicesRest # e.g. https://groups.school.edu/grouper-ws/servicesRest -grouperClient.webService.url = https://grouper-ws/grouper-ws/servicesRest +grouperClient.webService.url = https://grouper_ws/grouper-ws/servicesRest # kerberos principal used to connect to web service grouperClient.webService.login = banderson diff --git a/demo/complex/configs-and-secrets/grouper/application/grouper.hibernate.properties b/demo/complex/configs-and-secrets/grouper/application/grouper.hibernate.properties index f4849ba..deb0d75 100644 --- a/demo/complex/configs-and-secrets/grouper/application/grouper.hibernate.properties +++ b/demo/complex/configs-and-secrets/grouper/application/grouper.hibernate.properties @@ -20,7 +20,7 @@ # e.g. hsqldb (b): jdbc:hsqldb:hsql://localhost:9001/grouper # e.g. postgres: jdbc:postgresql://localhost:5432/database # e.g. mssql: jdbc:sqlserver://localhost:3280;databaseName=grouper -hibernate.connection.url = jdbc:mysql://grouper-data:3306/grouper?CharSet=utf8&useUnicode=true&characterEncoding=utf8 +hibernate.connection.url = jdbc:mysql://grouper_data:3306/grouper?CharSet=utf8&useUnicode=true&characterEncoding=utf8 hibernate.connection.username = root # If you are using an empty password, depending upon your version of diff --git a/demo/complex/docker-compose.yml b/demo/complex/docker-compose.yml index bd2fb36..aa9b0f9 100644 --- a/demo/complex/docker-compose.yml +++ b/demo/complex/docker-compose.yml @@ -1,21 +1,21 @@ version: "3.3" services: - grouper-daemon: - build: ./grouper-daemon/ - command: bash -c "while ! curl -s grouper-data:3306 > /dev/null; do echo waiting for mysql on grouper-data to start; sleep 3; done; while ! curl -s ldap://directory:389 > /dev/null; do echo waiting for ldap on directory to start; sleep 3; done; exec daemon" + grouper_daemon: + build: ./grouper_daemon/ + command: bash -c "while ! curl -s grouper_data:3306 > /dev/null; do echo waiting for mysql on grouper_data to start; sleep 3; done; while ! curl -s ldap://directory:389 > /dev/null; do echo waiting for ldap on directory to start; sleep 3; done; exec daemon" depends_on: - - grouper-data + - grouper_data - directory environment: - - ENV=demo + - ENV + - USERTOKEN - GROUPER_CLIENT_WEBSERVICE_PASSWORD_FILE=password - GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/g_database_password.txt - RABBITMQ_PASSWORD_FILE=/run/secrets/rabbitmq_password.txt - SUBJECT_SOURCE_LDAP_PASSWORD=password - - USERTOKEN=build-2 networks: - - back + - net secrets: - g_database_password.txt - rabbitmq_password.txt @@ -34,21 +34,21 @@ services: target: /opt/grouper/conf/grouper.client.properties - grouper-ui: - build: ./grouper-ui/ - command: bash -c "while ! curl -s grouper-data:3306 > /dev/null; do echo waiting for mysql on grouper-data to start; sleep 3; done; while ! curl -s ldap://directory:389 > /dev/null; do echo waiting for ldap on directory to start; sleep 3; done; exec ui" + grouper_ui: + build: ./grouper_ui/ + command: bash -c "while ! curl -s grouper_data:3306 > /dev/null; do echo waiting for mysql on grouper_data to start; sleep 3; done; while ! curl -s ldap://directory:389 > /dev/null; do echo waiting for ldap on directory to start; sleep 3; done; exec ui" depends_on: - - grouper-data + - grouper_data - directory environment: - - ENV=demo + - ENV + - USERTOKEN - GROUPER_DATABASE_PASSWORD_FILE=/run/secrets/g_database_password.txt - SUBJECT_SOURCE_LDAP_PASSWORD=password - - USERTOKEN=build-2 networks: - - back + - net ports: - - "443:443" + - 443:443 secrets: - g_database_password.txt - source: grouper.hibernate.properties @@ -84,57 +84,60 @@ services: source: ./configs-and-secrets/grouper/httpd/host-cert.pem target: /etc/pki/tls/certs/cachain.pem - grouper-data: - build: ./grouper-data/ + grouper_data: + build: ./grouper_data/ networks: - - back + - net ports: - - "3306:3306" + - 3306:3306 volumes: - grouper_data:/var/lib/mysql directory: build: ./directory/ ports: - - "389:389" + - 389:389 networks: - - back + - net volumes: - ldap:/var/lib/dirsrv sources: build: ./sources/ ports: - - "13306:3306" + - 13306:3306 networks: - - back + - net volumes: - source_data:/var/lib/mysql targets: build: ./targets/ ports: - - "23306:389" + - 23306:389 networks: - - back + - net volumes: - target_data:/var/lib/mysql - midpoint-data: + midpoint_data: image: tier/mariadb:mariadb10 ports: - - "33306:3306" + - 33306:3306 networks: - - back + - net volumes: - - midpoint_data:/var/lib/mysql + - midpoint_mysql:/var/lib/mysql + - midpoint_data:/var/lib/mysqlmounted + environment: + - CREATE_NEW_DATABASE=if_needed - midpoint-server: - build: ./midpoint-server/ + midpoint_server: + build: ./midpoint_server/ depends_on: - - midpoint-data + - midpoint_data ports: - - "8443:443" + - 8443:443 environment: - AUTHENTICATION - ENV @@ -150,18 +153,20 @@ services: - REPO_UPGRADEABLE_SCHEMA_ACTION - REPO_SCHEMA_VERSION_IF_MISSING - REPO_SCHEMA_VARIANT - - KEYSTORE_PASSWORD_FILE - - MEM + - MP_KEYSTORE_PASSWORD_FILE + - MP_MEM_MAX + - MP_MEM_INIT + - MP_JAVA_OPTS - SSO_HEADER - LOGOUT_URL - TIER_BEACON_OPT_OUT networks: - - back + - net secrets: - - m_database_password.txt - - m_keystore_password.txt - - m_sp-key.pem - - m_host-key.pem + - mp_database_password.txt + - mp_keystore_password.txt + - mp_sp-key.pem + - mp_host-key.pem volumes: - midpoint_home:/opt/midpoint/var - type: bind @@ -189,9 +194,9 @@ services: - JETTY_BROWSER_SSL_KEYSTORE_PASSWORD=password - JETTY_BACKCHANNEL_SSL_KEYSTORE_PASSWORD=password networks: - - back + - net ports: - - "4443:4443" + - 4443:4443 mq: image: rabbitmq:management @@ -199,12 +204,12 @@ services: - RABBITMQ_NODENAME=docker-rabbit hostname: rabbitmq networks: - - back + - net ports: - - "15672:15672" + - 15672:15672 networks: - back: + net: driver: bridge secrets: @@ -224,13 +229,13 @@ secrets: subject.properties: file: ./configs-and-secrets/grouper/application/subject.properties # midPoint - m_host-key.pem: + mp_host-key.pem: file: ./configs-and-secrets/midpoint/httpd/host-key.pem - m_sp-key.pem: + mp_sp-key.pem: file: ./configs-and-secrets/midpoint/shibboleth/sp-key.pem - m_database_password.txt: + mp_database_password.txt: file: ./configs-and-secrets/midpoint/application/database_password.txt - m_keystore_password.txt: + mp_keystore_password.txt: file: ./configs-and-secrets/midpoint/application/keystore_password.txt volumes: @@ -239,4 +244,5 @@ volumes: target_data: ldap: midpoint_data: + midpoint_mysql: midpoint_home: diff --git a/demo/complex/grouper-daemon/Dockerfile b/demo/complex/grouper_daemon/Dockerfile similarity index 100% rename from demo/complex/grouper-daemon/Dockerfile rename to demo/complex/grouper_daemon/Dockerfile diff --git a/demo/complex/grouper-data/Dockerfile b/demo/complex/grouper_data/Dockerfile similarity index 100% rename from demo/complex/grouper-data/Dockerfile rename to demo/complex/grouper_data/Dockerfile diff --git a/demo/complex/grouper-data/container_files/conf/grouper.hibernate.properties b/demo/complex/grouper_data/container_files/conf/grouper.hibernate.properties similarity index 100% rename from demo/complex/grouper-data/container_files/conf/grouper.hibernate.properties rename to demo/complex/grouper_data/container_files/conf/grouper.hibernate.properties diff --git a/demo/complex/grouper-data/container_files/conf/grouper.properties b/demo/complex/grouper_data/container_files/conf/grouper.properties similarity index 100% rename from demo/complex/grouper-data/container_files/conf/grouper.properties rename to demo/complex/grouper_data/container_files/conf/grouper.properties diff --git a/demo/complex/grouper-data/container_files/conf/subject.properties b/demo/complex/grouper_data/container_files/conf/subject.properties similarity index 100% rename from demo/complex/grouper-data/container_files/conf/subject.properties rename to demo/complex/grouper_data/container_files/conf/subject.properties diff --git a/demo/complex/grouper-data/container_files/seed-data/demo.gsh b/demo/complex/grouper_data/container_files/seed-data/demo.gsh similarity index 100% rename from demo/complex/grouper-data/container_files/seed-data/demo.gsh rename to demo/complex/grouper_data/container_files/seed-data/demo.gsh diff --git a/demo/complex/grouper-ui/Dockerfile b/demo/complex/grouper_ui/Dockerfile similarity index 100% rename from demo/complex/grouper-ui/Dockerfile rename to demo/complex/grouper_ui/Dockerfile diff --git a/demo/complex/grouper-ui/container_files/shibboleth/shibd.logger b/demo/complex/grouper_ui/container_files/shibboleth/shibd.logger similarity index 100% rename from demo/complex/grouper-ui/container_files/shibboleth/shibd.logger rename to demo/complex/grouper_ui/container_files/shibboleth/shibd.logger diff --git a/demo/complex/midpoint-objects/resources/scriptedsql-grouper2.xml b/demo/complex/midpoint-objects/resources/scriptedsql-grouper2.xml index ddd0c4b..250ddb1 100644 --- a/demo/complex/midpoint-objects/resources/scriptedsql-grouper2.xml +++ b/demo/complex/midpoint-objects/resources/scriptedsql-grouper2.xml @@ -18,7 +18,7 @@ - grouper-data + grouper_data 3306 root diff --git a/demo/complex/midpoint-server/Dockerfile b/demo/complex/midpoint_server/Dockerfile similarity index 100% rename from demo/complex/midpoint-server/Dockerfile rename to demo/complex/midpoint_server/Dockerfile diff --git a/demo/complex/midpoint-server/container_files/mp-home/icf-connectors/net.tirasa.connid.bundles.db.scriptedsql-2.2.6-SNAPSHOT.jar b/demo/complex/midpoint_server/container_files/mp-home/icf-connectors/net.tirasa.connid.bundles.db.scriptedsql-2.2.6-SNAPSHOT.jar similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/icf-connectors/net.tirasa.connid.bundles.db.scriptedsql-2.2.6-SNAPSHOT.jar rename to demo/complex/midpoint_server/container_files/mp-home/icf-connectors/net.tirasa.connid.bundles.db.scriptedsql-2.2.6-SNAPSHOT.jar diff --git a/demo/complex/midpoint-server/container_files/mp-home/lib/amqp-client-5.3.0.jar b/demo/complex/midpoint_server/container_files/mp-home/lib/amqp-client-5.3.0.jar similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/lib/amqp-client-5.3.0.jar rename to demo/complex/midpoint_server/container_files/mp-home/lib/amqp-client-5.3.0.jar diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper/SchemaScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper/SchemaScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper/SchemaScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper/SchemaScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper/SearchScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper/SearchScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper/SearchScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper/SearchScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper/TestScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper/TestScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper/TestScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper/TestScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper2/SchemaScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper2/SchemaScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper2/SchemaScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper2/SchemaScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper2/SearchScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper2/SearchScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper2/SearchScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper2/SearchScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper2/SyncScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper2/SyncScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper2/SyncScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper2/SyncScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/grouper2/TestScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/grouper2/TestScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/grouper2/TestScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/grouper2/TestScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/sis-persons/SchemaScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/sis-persons/SchemaScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/sis-persons/SchemaScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/sis-persons/SchemaScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/sis-persons/SearchScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/sis-persons/SearchScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/sis-persons/SearchScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/sis-persons/SearchScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/sis-persons/TestScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/sis-persons/TestScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/sis-persons/TestScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/sis-persons/TestScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/sis/SchemaScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/sis/SchemaScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/sis/SchemaScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/sis/SchemaScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/sis/SearchScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/sis/SearchScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/sis/SearchScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/sis/SearchScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/res/sis/TestScript.groovy b/demo/complex/midpoint_server/container_files/mp-home/res/sis/TestScript.groovy similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/res/sis/TestScript.groovy rename to demo/complex/midpoint_server/container_files/mp-home/res/sis/TestScript.groovy diff --git a/demo/complex/midpoint-server/container_files/mp-home/schema/user-schema.xsd b/demo/complex/midpoint_server/container_files/mp-home/schema/user-schema.xsd similarity index 100% rename from demo/complex/midpoint-server/container_files/mp-home/schema/user-schema.xsd rename to demo/complex/midpoint_server/container_files/mp-home/schema/user-schema.xsd diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 6ec5782..564c239 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -6,22 +6,23 @@ load ../../../library @test "000 Cleanup before running the tests" { (cd ../simple ; docker-compose down -v) (cd ../shibboleth ; docker-compose down -v) + (cd ../postgresql ; docker-compose down -v) docker-compose down -v } @test "010 Initialize and start the composition" { docker ps -a >> /tmp/log docker ps - ! (docker ps | grep -E "shibboleth_(idp|directory)_1|complex_(midpoint-server|midpoint-data)_1|simple_(midpoint-server|midpoint-data)_1") + ! (docker ps | grep -E "shibboleth_(idp|directory)_1|(complex|simple|shibboleth|postgresql)_(midpoint_server|midpoint_data)_1") cp tests/resources/sql/* sources/container_files/seed-data/ docker-compose up -d --build } @test "020 Wait until components are started" { touch $BATS_TMPDIR/not-started - wait_for_midpoint_start complex_midpoint-server_1 complex_midpoint-data_1 + wait_for_midpoint_start complex_midpoint_server_1 complex_midpoint_data_1 wait_for_shibboleth_idp_start complex_idp_1 - wait_for_grouper_ui_start complex_grouper-ui_1 + wait_for_grouper_ui_start complex_grouper_ui_1 rm $BATS_TMPDIR/not-started } From 23e077646b99e354d919cf5469cf5a21b56c9061 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Wed, 3 Oct 2018 22:56:57 +0200 Subject: [PATCH 72/73] Re-enable test999 in demo/complex (i.e. the final cleanup) --- demo/complex/tests/main.bats | 1 - 1 file changed, 1 deletion(-) diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 564c239..76ce315 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -143,6 +143,5 @@ load ../../../library @test "999 Clean up" { - skip TEMP docker-compose down -v } From fef5e57dbf50cdcf4558e986a3b04d34c1136fe7 Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Thu, 4 Oct 2018 00:13:55 +0200 Subject: [PATCH 73/73] Do cosmetic changes in tests --- demo/complex/test-resources | 8 +++ demo/complex/tests/main.bats | 14 ++-- ...ml => recompute-role-grouper-sysadmin.xml} | 0 library.bash | 72 +++++++++---------- 4 files changed, 52 insertions(+), 42 deletions(-) create mode 100755 demo/complex/test-resources rename demo/complex/tests/resources/bulk-action/{recom-role-grouper-sysadmin.xml => recompute-role-grouper-sysadmin.xml} (100%) diff --git a/demo/complex/test-resources b/demo/complex/test-resources new file mode 100755 index 0000000..0674f73 --- /dev/null +++ b/demo/complex/test-resources @@ -0,0 +1,8 @@ +#!/bin/bash + +source $(dirname "$0")/../../library.bash + +test_resource 0a37121f-d515-4a23-9b6d-554c5ef61272 +test_resource 6dcb84f5-bf82-4931-9072-fbdf87f96442 +test_resource 13660d60-071b-4596-9aa1-5efcd1256c04 +test_resource 4d70a0da-02dd-41cf-b0a1-00e75d3eaa15 diff --git a/demo/complex/tests/main.bats b/demo/complex/tests/main.bats index 76ce315..5cd95bb 100755 --- a/demo/complex/tests/main.bats +++ b/demo/complex/tests/main.bats @@ -11,10 +11,9 @@ load ../../../library } @test "010 Initialize and start the composition" { - docker ps -a >> /tmp/log + # We want to fail cleanly if there's any interference docker ps ! (docker ps | grep -E "shibboleth_(idp|directory)_1|(complex|simple|shibboleth|postgresql)_(midpoint_server|midpoint_data)_1") - cp tests/resources/sql/* sources/container_files/seed-data/ docker-compose up -d --build } @@ -59,8 +58,13 @@ load ../../../library @test "200 Upload objects" { if [ -e $BATS_TMPDIR/not-started ]; then skip 'not started'; fi + + # reduce data in SIS database so imports will take reasonable time + docker exec complex_sources_1 mysql sis -e "delete from SIS_COURSES where uid not in ('amorrison', 'banderson', 'cmorrison', 'danderson', 'ddavis', 'jsmith', 'kwhite', 'mroberts', 'whenderson', 'wprice')" + docker exec complex_sources_1 mysql sis -e "delete from SIS_AFFILIATIONS where uid not in ('amorrison', 'banderson', 'cmorrison', 'danderson', 'ddavis', 'jsmith', 'kwhite', 'mroberts', 'whenderson', 'wprice')" + docker exec complex_sources_1 mysql sis -e "delete from SIS_PERSONS where uid not in ('amorrison', 'banderson', 'cmorrison', 'danderson', 'ddavis', 'jsmith', 'kwhite', 'mroberts', 'whenderson', 'wprice')" + check_health - pwd >&2 ./upload-objects search_and_check_object objectTemplates template-org-course @@ -132,8 +136,8 @@ load ../../../library rm /tmp/testuser230.xml search_and_check_object users TestUser230 - execute_bulk_action tests/resources/bulk-action/recom-role-grouper-sysadmin.xml - execute_bulk_action tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml + execute_bulk_action tests/resources/bulk-action/recompute-role-grouper-sysadmin.xml complex_midpoint_server_1 + execute_bulk_action tests/resources/bulk-action/assign-role-grouper-sysadmin-to-test-user.xml complex_midpoint_server_1 check_ldap_account_by_user_name TestUser230 complex_directory_1 check_of_ldap_membership TestUser230 sysadmingroup complex_directory_1 diff --git a/demo/complex/tests/resources/bulk-action/recom-role-grouper-sysadmin.xml b/demo/complex/tests/resources/bulk-action/recompute-role-grouper-sysadmin.xml similarity index 100% rename from demo/complex/tests/resources/bulk-action/recom-role-grouper-sysadmin.xml rename to demo/complex/tests/resources/bulk-action/recompute-role-grouper-sysadmin.xml diff --git a/library.bash b/library.bash index f22a759..eae9fb2 100644 --- a/library.bash +++ b/library.bash @@ -55,7 +55,6 @@ function wait_for_grouper_ui_start () { generic_wait_for_log $1 "INFO org.apache.catalina.startup.Catalina- Server startup in" "grouper ui to start" "grouper ui did not start" $2 } - # Checks the health of midPoint server function check_health () { echo Checking health... @@ -85,22 +84,23 @@ function check_health_shibboleth_idp () { fi } - +# Result is in OUTFILE function get_object () { local TYPE=$1 local OID=$2 - TMPFILE=$(mktemp /tmp/get.XXXXXX) - echo tmp file is $TMPFILE - curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$TMPFILE || (rm $TMPFILE ; return 1) + OUTFILE=$(mktemp /tmp/get.XXXXXX) + echo out file is $OUTFILE + curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$OUTFILE || (rm $OUTFILE ; return 1) return 0 } # Retrieves XML object and checks if the name matches +# Object is deleted before return function get_and_check_object () { - TYPE=$1 - OID=$2 - NAME=$3 - TMPFILE=$(mktemp /tmp/get.XXXXXX) + local TYPE=$1 + local OID=$2 + local NAME=$3 + local TMPFILE=$(mktemp /tmp/get.XXXXXX) echo tmp file is $TMPFILE curl -k --user administrator:5ecr3t -H "Content-Type: application/xml" -X GET "https://localhost:8443/midpoint/ws/rest/$TYPE/$OID" >$TMPFILE || (rm $TMPFILE ; return 1) if (grep -q "$NAME" <$TMPFILE); then @@ -119,17 +119,17 @@ function get_and_check_object () { function add_object () { local TYPE=$1 local FILE=$2 - TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX) + TMPFILE=$(mktemp /tmp/addobject.XXXXXX) echo "Adding to $TYPE from $FILE..." - + curl -k -sD - --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/$TYPE" -d @$FILE >$TMPFILE - local HTTP_CODE=$(sed '$!d' $TMPFILE) - + local HTTP_CODE=$(sed '$!d' $TMPFILE) + if [ "$HTTP_CODE" -eq 201 ] || [ "$HTTP_CODE" -eq 202 ]; then - + OID=$(grep -oP "Location: \K.*" $TMPFILE | awk -F "$TYPE/" '{print $2}') || (echo "Couldn't extract oid from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) - echo "Oid created object: $OID" + echo "OID of created object: $OID" rm $TMPFILE return 0 else @@ -145,18 +145,20 @@ function add_object () { fi } +# parameter $2 (CONTAINER) is just for diagnostics: it is the container whose logs we want to dump on error (might be omitted) function execute_bulk_action () { local FILE=$1 + local CONTAINER=$2 echo "Executing bulk action from $FILE..." - TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX) + TMPFILE=$(mktemp /tmp/execbulkaction.XXXXXX) - (curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/rpc/executeScript" -d @$FILE >$TMPFILE) || (echo "Midpoint logs: " ; docker logs "complex_midpoint-server_1" ; return 1) + (curl -k --silent --write-out "%{http_code}" --user administrator:5ecr3t -H "Content-Type: application/xml" -X POST "https://localhost:8443/midpoint/ws/rest/rpc/executeScript" -d @$FILE >$TMPFILE) || (echo "Midpoint logs: " ; ([[ -n "$CONTAINER" ]] && docker logs $CONTAINER ) ; return 1) local HTTP_CODE=$(sed '$!d' $TMPFILE) sed -i '$ d' $TMPFILE if [ "$HTTP_CODE" -eq 200 ]; then - - local STATUS=$(xmllint --xpath "/*/*/*[local-name()='status']/text()" $TMPFILE) || (echo "Couldn't extract status from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) + + local STATUS=$(xmllint --xpath "/*/*/*[local-name()='status']/text()" $TMPFILE) || (echo "Couldn't extract status from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) if [ $STATUS = "success" ]; then local CONSOLE_OUTPUT=$(xmllint --xpath "/*/*/*[local-name()='consoleOutput']/text()" $TMPFILE) || (echo "Couldn't extract console output from file:" ; cat $TMPFILE ; rm $TMPFILE; return 1) echo "Console output: $CONSOLE_OUTPUT" @@ -188,7 +190,7 @@ function delete_object_by_name () { local NAME=$2 search_objects_by_name users $NAME local OID=$(xmllint --xpath "/*/*[local-name()='object']/@oid" $SEARCH_RESULT_FILE | awk -F"\"" '{print $2}' ) || (echo "Couldn't extract oid from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE; return 1) - delete_object $TYPE $OID + delete_object $TYPE $OID } function delete_object () { @@ -202,7 +204,6 @@ function delete_object () { sed -i '$ d' $TMPFILE if [ "$HTTP_CODE" -eq 204 ]; then - echo "Object with type $TYPE and oid $OID was deleted" rm $TMPFILE return 0 @@ -219,8 +220,6 @@ function delete_object () { fi } - - # Tries to find an object with a given name # Results of the search are in the $SEARCH_RESULT_FILE # TODO check if the result is valid (i.e. not an error) - return 1 if invalid, otherwise return 0 ("no objects" is considered OK here) @@ -241,7 +240,7 @@ function search_objects_by_name () { EOF local HTTP_CODE=$(sed '$!d' <<<"$(cat $TMPFILE)") sed -i '$ d' $TMPFILE - cat $TMPFILE + cat $TMPFILE if [ "$HTTP_CODE" -eq 200 ]; then SEARCH_RESULT_FILE=$TMPFILE @@ -297,15 +296,15 @@ function test_resource () { function assert_task_success () { local OID=$1 get_object tasks $OID - TASK_STATUS=$(xmllint --xpath "/*/*[local-name()='resultStatus']/text()" $TMPFILE) || (echo "Couldn't extract task status from task $OID" ; cat $TMPFILE ; rm $TMPFILE ; return 1) + TASK_STATUS=$(xmllint --xpath "/*/*[local-name()='resultStatus']/text()" $OUTFILE) || (echo "Couldn't extract task status from task $OID" ; cat $OUTFILE ; rm $OUTFILE ; return 1) if [[ $TASK_STATUS = "success" ]]; then echo "Task $OID status is OK" - rm $TMPFILE + rm $OUTFILE return 0 else echo "Task $OID status is not OK: $TASK_STATUS" - cat $TMPFILE - rm $TMPFILE + cat $OUTFILE + rm $OUTFILE return 1 fi } @@ -321,14 +320,14 @@ function wait_for_task_completion () { echo "Waiting $DELAY seconds for task with oid $OID to finish (attempt $ATTEMPT) ..." sleep $DELAY get_object tasks $OID - TASK_EXECUTION_STATUS=$(xmllint --xpath "/*/*[local-name()='executionStatus']/text()" $TMPFILE) || (echo "Couldn't extract task status from task $OID" ; cat $TMPFILE ; rm $TMPFILE ; return 1) + TASK_EXECUTION_STATUS=$(xmllint --xpath "/*/*[local-name()='executionStatus']/text()" $OUTFILE) || (echo "Couldn't extract task status from task $OID" ; cat $OUTFILE ; rm $OUTFILE ; return 1) if [[ $TASK_EXECUTION_STATUS = "suspended" ]] || [[ $TASK_EXECUTION_STATUS = "closed" ]]; then echo "Task $OID is finished" - rm $TMPFILE + rm $OUTFILE return 0 fi done - rm $TMPFILE + rm $OUTFILE echo Task with $OID did not finish in $(( $MAX_ATTEMPTS * $DELAY )) seconds return 1 } @@ -342,7 +341,7 @@ function search_ldap_object_by_filter () { TMPFILE=$(mktemp /tmp/ldapsearch.XXXXXX) docker exec $LDAP_CONTAINER ldapsearch -h localhost -p 389 -D "cn=Directory Manager" -w password -b "$BASE_CONTEXT_FOR_SEARCH" "($FILTER)" >$TMPFILE || (rm $TMPFILE ; return 1) - LDAPSEARCH_RESULT_FILE=$TMPFILE + LDAPSEARCH_RESULT_FILE=$TMPFILE return 0 } @@ -351,10 +350,10 @@ function check_ldap_account_by_user_name () { local LDAP_CONTAINER=$2 search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME" $LDAP_CONTAINER search_objects_by_name users $NAME - + local MP_FULL_NAME=$(xmllint --xpath "/*/*/*[local-name()='fullName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user fullName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) local MP_GIVEN_NAME=$(xmllint --xpath "/*/*/*[local-name()='givenName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user givenName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) - local MP_FAMILY_NAME=$(xmllint --xpath "/*/*/*[local-name()='familyName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user familyName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) + local MP_FAMILY_NAME=$(xmllint --xpath "/*/*/*[local-name()='familyName']/text()" $SEARCH_RESULT_FILE) || (echo "Couldn't extract user familyName from file:" ; cat $SEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) local LDAP_CN=$(grep -oP "cn: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user cn from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) local LDAP_GIVEN_NAME=$(grep -oP "givenName: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user givenName from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $SEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) @@ -366,7 +365,7 @@ function check_ldap_account_by_user_name () { if [[ $MP_FULL_NAME = $LDAP_CN ]] && [[ $MP_GIVEN_NAME = $LDAP_GIVEN_NAME ]] && [[ $MP_FAMILY_NAME = $LDAP_SN ]]; then return 0 fi - + echo "User in Midpoint and LDAP Account with uid $NAME are not same" return 1 } @@ -378,7 +377,7 @@ function check_of_ldap_membership () { search_ldap_object_by_filter "ou=people,dc=internet2,dc=edu" "uid=$NAME_OF_USER" $LDAP_CONTAINER local LDAP_ACCOUNT_DN=$(grep -oP "dn: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user dn from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) - + search_ldap_object_by_filter "ou=groups,dc=internet2,dc=edu" "cn=$NAME_OF_GROUP" $LDAP_CONTAINER local LDAP_MEMBERS_DNS=$(grep -oP "uniqueMember: \K.*" $LDAPSEARCH_RESULT_FILE) || (echo "Couldn't extract user uniqueMember from file:" ; cat $LDAPSEARCH_RESULT_FILE ; rm $LDAPSEARCH_RESULT_FILE ; return 1) @@ -392,4 +391,3 @@ function check_of_ldap_membership () { echo "LDAP Account with uid $NAME_OF_USER is not member of LDAP Group $NAME_OF_GROUP" return 1 } -