From 47122bc018e4cf32618580a71cc149523e12463a Mon Sep 17 00:00:00 2001 From: Jim Van Fleet Date: Thu, 13 Jul 2017 12:05:45 -0400 Subject: [PATCH] Adding extra validations, running in foreground and startability test --- Dockerfile | 5 +- bin/ci-run.sh | 6 + bin/ci-stop.sh | 8 ++ .../etc/shibboleth/shibboleth2.xml | 114 +++++++++++++++++- container_files/usr/sbin/httpd-foreground | 7 ++ tests/image.bats | 8 ++ tests/running.bats | 10 ++ 7 files changed, 154 insertions(+), 4 deletions(-) create mode 100755 bin/ci-run.sh create mode 100755 bin/ci-stop.sh create mode 100755 container_files/usr/sbin/httpd-foreground create mode 100644 tests/running.bats diff --git a/Dockerfile b/Dockerfile index 9e3aeec..a9581ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ ADD ./container_files /opt # This SP will connect via the TCP listener RUN rm /opt/bin/httpd-shib-foreground /etc/httpd/conf.d/ssl.conf && \ cp /opt/etc/httpd/conf.d/*.conf /etc/httpd/conf.d/. && \ - cp /opt/etc/shibboleth/* /etc/shibboleth/. + cp /opt/etc/shibboleth/* /etc/shibboleth/. && \ + cp /opt/usr/sbin/httpd-foreground /usr/sbin/. && chmod +x /usr/sbin/httpd-foreground EXPOSE 80 443 -CMD ["/usr/sbin/httpd"] +CMD ["/usr/sbin/httpd-foreground"] diff --git a/bin/ci-run.sh b/bin/ci-run.sh new file mode 100755 index 0000000..532ece0 --- /dev/null +++ b/bin/ci-run.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# This file will run a container in the background +source common.bash . + +docker run -d --name=$imagename $maintainer/$imagename \ No newline at end of file diff --git a/bin/ci-stop.sh b/bin/ci-stop.sh new file mode 100755 index 0000000..54ab019 --- /dev/null +++ b/bin/ci-stop.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# This file will run a container in the background +source common.bash . + +echo "Cleaning up Docker image($maintainer/$imagename)" +docker stop $imagename >> /dev/null +docker rm $imagename diff --git a/container_files/etc/shibboleth/shibboleth2.xml b/container_files/etc/shibboleth/shibboleth2.xml index 916eae9..1dbe2fc 100644 --- a/container_files/etc/shibboleth/shibboleth2.xml +++ b/container_files/etc/shibboleth/shibboleth2.xml @@ -5,6 +5,116 @@ xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" clockSkew="180"> - + + - \ No newline at end of file + + + + + + + + + + + + + + SAML2 SAML1 + + + SAML2 Local + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/container_files/usr/sbin/httpd-foreground b/container_files/usr/sbin/httpd-foreground new file mode 100755 index 0000000..feb1ae2 --- /dev/null +++ b/container_files/usr/sbin/httpd-foreground @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +# Apache gets grumpy about PID files pre-existing +rm -f /run/httpd/httpd.pid + +exec httpd -DFOREGROUND \ No newline at end of file diff --git a/tests/image.bats b/tests/image.bats index b6924eb..66f28f8 100644 --- a/tests/image.bats +++ b/tests/image.bats @@ -13,4 +13,12 @@ load ../common @test "shibboleth2.xml using a TCP Listener configuration" { docker run -i $maintainer/$imagename grep TCPListener /etc/shibboleth/shibboleth2.xml +} + +@test "Shibboleth configuration is well formed" { + docker run -i $maintainer/$imagename xmlwf /etc/shibboleth/shibboleth2.xml +} + +@test "Shibboleth configuration is valid" { + docker run -i $maintainer/$imagename /usr/sbin/shibd -tc /etc/shibboleth/shibboleth2.xml } \ No newline at end of file diff --git a/tests/running.bats b/tests/running.bats new file mode 100644 index 0000000..4161d23 --- /dev/null +++ b/tests/running.bats @@ -0,0 +1,10 @@ +#!/usr/bin/env bats + +load ../common + +# These tests assume the pipeline will start and stop the container. + +@test "Leaves running process" { + result="$(docker ps | grep $imagename)" + [ "$result" != '' ] +} \ No newline at end of file