Implement testing using BATSpull/488/head
| @ -0,0 +1,28 @@ | |||
| #! /usr/bin/env bats | |||
| load '/bats-support/load.bash' | |||
| load '/bats-assert/load.bash' | |||
| load '/getssl/test/test_helper.bash' | |||
| # This is run for every test | |||
| setup() { | |||
| export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt | |||
| } | |||
| @test "Create new certificate using HTTP-01 verification" { | |||
| CONFIG_FILE="getssl-http01.cfg" | |||
| setup_environment | |||
| init_getssl | |||
| create_certificate | |||
| assert_success | |||
| } | |||
| @test "Force renewal of certificate using HTTP-01" { | |||
| #!FIXME test certificate has been updated | |||
| run ${CODE_DIR}/getssl -f $GETSSL_HOST | |||
| assert_success | |||
| cleanup_environment | |||
| } | |||
| @ -0,0 +1,28 @@ | |||
| #! /usr/bin/env bats | |||
| load '/bats-support/load.bash' | |||
| load '/bats-assert/load.bash' | |||
| load '/getssl/test/test_helper.bash' | |||
| # This is run for every test | |||
| setup() { | |||
| export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt | |||
| } | |||
| @test "Create new certificate using DNS-01 verification" { | |||
| CONFIG_FILE="getssl-dns01.cfg" | |||
| setup_environment | |||
| init_getssl | |||
| create_certificate | |||
| assert_success | |||
| } | |||
| @test "Force renewal of certificate using DNS-01" { | |||
| #!FIXME test certificate has been updated | |||
| run ${CODE_DIR}/getssl -f $GETSSL_HOST | |||
| assert_success | |||
| cleanup_environment | |||
| } | |||
| @ -0,0 +1,39 @@ | |||
| #! /usr/bin/env bats | |||
| load '/bats-support/load.bash' | |||
| load '/bats-assert/load.bash' | |||
| load '/getssl/test/test_helper.bash' | |||
| # This is run for every test | |||
| setup() { | |||
| export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt | |||
| } | |||
| @test "Create certificates for more than 10 hosts using HTTP-01 verification" { | |||
| CONFIG_FILE="getssl-http01-10-hosts.cfg" | |||
| setup_environment | |||
| # Add 11 hosts to DNS (also need to be added as aliases in docker-compose.yml) | |||
| for prefix in a b c d e f g h i j k; do | |||
| curl -X POST -d '{"host":"'$prefix.$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/add-a | |||
| done | |||
| init_getssl | |||
| create_certificate | |||
| assert_success | |||
| } | |||
| @test "Force renewal of more than 10 certificates using HTTP-01" { | |||
| #!FIXME test certificate has been updated | |||
| run ${CODE_DIR}/getssl -f $GETSSL_HOST | |||
| assert_success | |||
| # Remove all the dns aliases | |||
| cleanup_environment | |||
| for prefix in a b c d e f g h i j k; do | |||
| curl -X POST -d '{"host":"'$prefix.$GETSSL_HOST'", "addresses":["'$GETSSL_IP'"]}' http://10.30.50.3:8055/del-a | |||
| done | |||
| } | |||
| @ -0,0 +1,22 @@ | |||
| FROM centos:centos6 | |||
| # Update and install required software | |||
| RUN yum -y update | |||
| RUN yum -y install epel-release | |||
| RUN yum -y install git curl dnsutils wget nginx | |||
| WORKDIR /root | |||
| RUN mkdir /etc/nginx/pki | |||
| RUN mkdir /etc/nginx/pki/private | |||
| COPY ./test/test-config/nginx-ubuntu-no-ssl /etc/nginx/conf.d/default.conf | |||
| # BATS (Bash Automated Testings) | |||
| RUN git clone https://github.com/bats-core/bats-core.git /bats-core | |||
| RUN git clone https://github.com/jasonkarns/bats-support /bats-support | |||
| RUN git clone https://github.com/jasonkarns/bats-assert-1 /bats-assert | |||
| RUN /bats-core/install.sh /usr/local | |||
| EXPOSE 80 443 | |||
| # Run eternal loop - for testing | |||
| CMD ["/bin/bash", "-c", "while :; do sleep 10; done"] | |||
| @ -1,22 +0,0 @@ | |||
| FROM roboxes/rhel6 | |||
| # FROM centos:centos6 | |||
| # bionic = latest 18 version | |||
| # Update and install required software | |||
| RUN yum -y update | |||
| RUN yum -y install epel-release | |||
| RUN yum -y install git curl dnsutils wget # nginx-light | |||
| WORKDIR /root | |||
| #RUN mkdir /etc/nginx/pki | |||
| #RUN mkdir /etc/nginx/pki/private | |||
| #COPY ./test/test-config/nginx-ubuntu-sites-enabled-default /etc/nginx/sites-enabled/default | |||
| # BATS (Bash Automated Testings) | |||
| # RUN git clone https://github.com/bats-core/bats-core.git | |||
| # RUN bats-core/install.sh /usr/local | |||
| EXPOSE 80 443 | |||
| # Run eternal loop - for testing | |||
| CMD ["/bin/bash", "-c", "while :; do sleep 10; done"] | |||
| @ -1,43 +1,14 @@ | |||
| #! /bin/bash | |||
| #!/usr/bin/env bash | |||
| set -e | |||
| # This runs getssl outside of the BATS framework for debugging, etc, against pebble | |||
| # Usage: /getssl/test/run-test.sh getssl-http01.cfg | |||
| # Test setup | |||
| if [[ -d /root/.getssl ]]; then | |||
| rm -r /root/.getssl | |||
| fi | |||
| CONFIG_FILE=$1 | |||
| source /getssl/test/test_helper.bash | |||
| wget --no-clobber https://raw.githubusercontent.com/letsencrypt/pebble/master/test/certs/pebble.minica.pem | |||
| # cat /etc/pki/tls/certs/ca-bundle.crt /root/pebble.minica.pem > /root/pebble-ca-bundle.crt | |||
| cat /etc/ssl/certs/ca-certificates.crt /root/pebble.minica.pem > /root/pebble-ca-bundle.crt | |||
| setup_environment 3>&1 | |||
| export CURL_CA_BUNDLE=/root/pebble-ca-bundle.crt | |||
| curl -X POST -d '{"host":"getssl", "addresses":["10.30.50.4"]}' http://10.30.50.3:8055/add-a | |||
| # Test #1 - http-01 verification | |||
| echo Test \#1 - http-01 verification | |||
| cp /getssl/test/test-config/nginx-ubuntu-no-ssl /etc/nginx/sites-enabled/default | |||
| service nginx restart | |||
| /getssl/getssl -c getssl | |||
| cp /getssl/test/test-config/getssl-http01.cfg /root/.getssl/getssl/getssl.cfg | |||
| /getssl/getssl -f getssl | |||
| # Test #2 - http-01 forced renewal | |||
| echo Test \#2 - http-01 forced renewal | |||
| /getssl/getssl getssl -f | |||
| # Test cleanup | |||
| rm -r /root/.getssl | |||
| # Test #3 - dns-01 verification | |||
| echo Test \#3 - dns-01 verification | |||
| cp /getssl/test/test-config/nginx-ubuntu-no-ssl /etc/nginx/sites-enabled/default | |||
| service nginx restart | |||
| /getssl/getssl -c getssl | |||
| cp /getssl/test/test-config/getssl-dns01.cfg /root/.getssl/getssl/getssl.cfg | |||
| /getssl/getssl getssl | |||
| # Test #4 - dns-01 forced renewal | |||
| echo Test \#4 - dns-01 forced renewal | |||
| /getssl/getssl getssl -f | |||
| "${CODE_DIR}/getssl" -c "$GETSSL_HOST" 3>&1 | |||
| cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_HOST}/getssl.cfg" | |||
| "${CODE_DIR}/getssl" -f -d "$GETSSL_HOST" 3>&1 | |||
| @ -0,0 +1,28 @@ | |||
| # Uncomment and modify any variables you need | |||
| # see https://github.com/srvrco/getssl/wiki/Config-variables for details | |||
| # see https://github.com/srvrco/getssl/wiki/Example-config-files for example configs | |||
| CA="https://pebble:14000/dir" | |||
| # Additional domains - this could be multiple domains / subdomains in a comma separated list | |||
| # Note: this is Additional domains - so should not include the primary domain. | |||
| SANS="a.${GETSSL_HOST},b.${GETSSL_HOST},c.${GETSSL_HOST},d.${GETSSL_HOST},e.${GETSSL_HOST},f.${GETSSL_HOST},g.${GETSSL_HOST},h.${GETSSL_HOST},i.${GETSSL_HOST},j.${GETSSL_HOST},k.${GETSSL_HOST}" | |||
| # Acme Challenge Location. | |||
| ACL=('/var/www/html/.well-known/acme-challenge') | |||
| # Use a single ACL for all checks | |||
| USE_SINGLE_ACL="true" | |||
| # Location for all your certs, these can either be on the server (full path name) | |||
| DOMAIN_CERT_LOCATION="/etc/nginx/pki/server.crt" | |||
| DOMAIN_KEY_LOCATION="/etc/nginx/pki/private/server.key" | |||
| CA_CERT_LOCATION="/etc/nginx/pki/chain.crt" | |||
| DOMAIN_CHAIN_LOCATION="" # this is the domain cert and CA cert | |||
| DOMAIN_PEM_LOCATION="" # this is the domain_key, domain cert and CA cert | |||
| # The command needed to reload apache / nginx or whatever you use | |||
| RELOAD_CMD="cp /getssl/test/test-config/nginx-ubuntu-ssl ${NGINX_CONFIG} && service nginx restart >&3-" | |||
| #SERVER_TYPE="https" | |||
| #CHECK_REMOTE="true" | |||
| @ -0,0 +1,44 @@ | |||
| INSTALL_DIR=/root | |||
| CODE_DIR=/getssl | |||
| setup_environment() { | |||
| # One-off test setup | |||
| if [[ -d ${INSTALL_DIR}/.getssl ]]; then | |||
| rm -r ${INSTALL_DIR}/.getssl | |||
| fi | |||
| if [ ! -f ${INSTALL_DIR}/pebble.minica.pem ]; then | |||
| wget --no-clobber https://raw.githubusercontent.com/letsencrypt/pebble/master/test/certs/pebble.minica.pem 2>&1 | |||
| CERT_FILE=/etc/ssl/certs/ca-certificates.crt | |||
| if [ ! -f $CERT_FILE ]; then | |||
| CERT_FILE=/etc/pki/tls/certs/ca-bundle.crt | |||
| fi | |||
| cat $CERT_FILE ${INSTALL_DIR}/pebble.minica.pem > ${INSTALL_DIR}/pebble-ca-bundle.crt | |||
| fi | |||
| curl -X POST -d '{"host":"'"$GETSSL_HOST"'", "addresses":["'"$GETSSL_IP"'"]}' http://10.30.50.3:8055/add-a | |||
| cp ${CODE_DIR}/test/test-config/nginx-ubuntu-no-ssl ${NGINX_CONFIG} | |||
| service nginx restart >&3- | |||
| } | |||
| cleanup_environment() { | |||
| curl -X POST -d '{"host":"'"$GETSSL_HOST"'", "addresses":["'"$GETSSL_IP"'"]}' http://10.30.50.3:8055/del-a | |||
| } | |||
| init_getssl() { | |||
| # Run initialisation (create account key, etc) | |||
| run ${CODE_DIR}/getssl -c "$GETSSL_HOST" | |||
| assert_success | |||
| [ -d "$INSTALL_DIR/.getssl" ] | |||
| } | |||
| create_certificate() { | |||
| # Create certificate | |||
| cp "${CODE_DIR}/test/test-config/${CONFIG_FILE}" "${INSTALL_DIR}/.getssl/${GETSSL_HOST}/getssl.cfg" | |||
| run ${CODE_DIR}/getssl "$GETSSL_HOST" | |||
| #!FIXME test certificate has been placed in the expected location | |||
| } | |||