Test using Dynu.com as well as Duckdns.orgpull/619/head
| @ -0,0 +1,25 @@ | |||
| name: Run all tests using DuckDNS | |||
| on: | |||
| push: | |||
| branches: | |||
| - master | |||
| pull_request: | |||
| branches: | |||
| - master | |||
| jobs: | |||
| test-centos7-duckdns: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v1 | |||
| - name: Build the docker-compose stack | |||
| run: docker-compose up -d --build | |||
| - name: Run test suite on CentOS7 against Staging using DuckDNS | |||
| run: test/run-test.sh centos7-duckdns | |||
| test-ubuntu-duckdns: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v1 | |||
| - name: Build the docker-compose stack | |||
| run: docker-compose up -d --build | |||
| - name: Run test suite on Ubuntu against Staging using DuckDNS | |||
| run: test/run-test.sh ubuntu-duckdns | |||
| @ -0,0 +1,25 @@ | |||
| name: Run all tests using Dynu | |||
| on: | |||
| push: | |||
| branches: | |||
| - master | |||
| pull_request: | |||
| branches: | |||
| - master | |||
| jobs: | |||
| test-centos7-dynu: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v1 | |||
| - name: Build the docker-compose stack | |||
| run: docker-compose up -d --build | |||
| - name: Run test suite on CentOS7 against Staging using Dynu | |||
| run: test/run-test.sh centos7-dynu | |||
| test-ubuntu-dynu: | |||
| runs-on: ubuntu-latest | |||
| steps: | |||
| - uses: actions/checkout@v1 | |||
| - name: Build the docker-compose stack | |||
| run: docker-compose up -d --build | |||
| - name: Run test suite on Ubuntu against Staging using Dynu | |||
| run: test/run-test.sh ubuntu-dynu | |||
| @ -0,0 +1,72 @@ | |||
| #!/usr/bin/env bash | |||
| # Need to add your API key below or set as env variable | |||
| apikey=${DYNU_API_KEY:-''} | |||
| # This script adds a token to dynu.com DNS for the ACME challenge | |||
| # usage dns_add_dynu "domain name" "token" | |||
| # return codes are; | |||
| # 0 - success | |||
| # 1 - error in input | |||
| # 2 - error within internal processing | |||
| # 3 - error in result ( domain not found in dynu.com etc) | |||
| fulldomain="${1}" | |||
| token="${2}" | |||
| API='https://api.dynu.com/v2/dns' | |||
| # Check initial parameters | |||
| if [[ -z "$fulldomain" ]]; then | |||
| echo "DNS script requires full domain name as first parameter" | |||
| exit 1 | |||
| fi | |||
| if [[ -z "$token" ]]; then | |||
| echo "DNS script requires challenge token as second parameter" | |||
| exit 1 | |||
| fi | |||
| curl_params=( -H "accept: application/json" -H "API-Key: $apikey" -H 'Content-Type: application/json' ) | |||
| # Get domain id | |||
| # curl -X GET https://api.dynu.com/v2/dns/getroot/ubuntu-getssl.freeddns.org | |||
| resp=$(curl --silent "${curl_params[@]}" -X GET "$API/getroot/${fulldomain}") | |||
| # Match domain id | |||
| re="\"id\":([^,]*),\"domainName\":\"${fulldomain}\"" | |||
| if [[ "$resp" =~ $re ]]; then | |||
| domain_id="${BASH_REMATCH[1]}" | |||
| fi | |||
| if [[ -z "$domain_id" ]]; then | |||
| echo 'Domain name not found on your Dynu account' | |||
| exit 3 | |||
| fi | |||
| # Check for existing _acme-challenge TXT record | |||
| # curl -X GET "https://api.dynu.com/v2/dns/record/_acme-challenge.ubuntu-getssl.freeddns.org?recordType=TXT" | |||
| resp=$(curl --silent "${curl_params[@]}" -X GET "${API}/record/_acme-challenge.${fulldomain}?recordType=TXT") | |||
| re="\"id\":([^,]*)" | |||
| if [[ "$resp" =~ $re ]]; then | |||
| record_id="${BASH_REMATCH[1]}" | |||
| fi | |||
| if [[ -z "$record_id" ]]; then | |||
| # Add new TXT challenge record | |||
| resp=$(curl --silent \ | |||
| "${curl_params[@]}" \ | |||
| -X POST "${API}/${domain_id}/record" \ | |||
| --data "{\"nodeName\":\"_acme-challenge\",\"recordType\":\"TXT\",\"state\":\"true\",\"textData\":\"$token\"}") | |||
| else | |||
| # Update existing record | |||
| # curl -X POST https://api.dynu.com/v2/dns/9329328/record/7082063 -d "{\"nodeName\":\"_acme-challenge\",\"recordType\":\"TXT\",\"state\":\"true\",\"textData\":\"Test2\"}" | |||
| resp=$(curl --silent \ | |||
| "${curl_params[@]}" \ | |||
| -X POST "${API}/${domain_id}/record/${record_id}" \ | |||
| --data "{\"nodeName\":\"_acme-challenge\",\"recordType\":\"TXT\",\"state\":\"true\",\"textData\":\"$token\"}") | |||
| fi | |||
| # If adding record failed (exception:) then print error message | |||
| if [[ "$resp" != *"\"statusCode\":200"* ]]; then | |||
| echo "Error: DNS challenge not added: unknown error - ${resp}" | |||
| exit 3 | |||
| fi | |||
| @ -0,0 +1,71 @@ | |||
| #!/usr/bin/env bash | |||
| # Need to add your API key below or set as env variable | |||
| apikey=${DYNU_API_KEY:-''} | |||
| # This script deletes the _acme-challenge TXT record from the dynu.com DNS entry for the domain | |||
| # usage dns_del_dynu "domain name" | |||
| # return codes are; | |||
| # 0 - success | |||
| # 1 - error in input | |||
| # 2 - error within internal processing | |||
| # 3 - error in result ( domain not found in dynu.com etc) | |||
| # After deleting the TXT record from Dynu.com it takes over 30 minutes to add a new TXT record! | |||
| # This doesn't happen when updating the TXT record, just for delete then add | |||
| # As this is used for testing, changed the delete to a no-op. | |||
| exit 0 | |||
| fulldomain="${1}" | |||
| API='https://api.dynu.com/v2/dns' | |||
| # Check initial parameters | |||
| if [[ -z "$fulldomain" ]]; then | |||
| echo "DNS script requires full domain name as first parameter" | |||
| exit 1 | |||
| fi | |||
| if [[ -z "$apikey" ]]; then | |||
| echo "DNS script requires apikey environment variable to be set" | |||
| exit 1 | |||
| fi | |||
| curl_params=( -H "accept: application/json" -H "API-Key: $apikey" -H 'Content-Type: application/json' ) | |||
| # Get domain id | |||
| # curl -X GET https://api.dynu.com/v2/dns/getroot/ubuntu-getssl.freeddns.org | |||
| resp=$(curl --silent "${curl_params[@]}" -X GET "$API/getroot/${fulldomain}") | |||
| # Match domain id | |||
| re="\"id\":([^,]*),\"domainName\":\"${fulldomain}\"" | |||
| if [[ "$resp" =~ $re ]]; then | |||
| domain_id="${BASH_REMATCH[1]}" | |||
| fi | |||
| if [[ -z "$domain_id" ]]; then | |||
| echo 'Domain name not found on your Dynu account' | |||
| exit 3 | |||
| fi | |||
| # Check for existing _acme-challenge TXT record | |||
| # curl -X GET "https://api.dynu.com/v2/dns/record/_acme-challenge.ubuntu-getssl.freeddns.org?recordType=TXT" | |||
| resp=$(curl --silent "${curl_params[@]}" -X GET "${API}/record/_acme-challenge.${fulldomain}?recordType=TXT") | |||
| re="\"id\":([^,]*)" | |||
| if [[ "$resp" =~ $re ]]; then | |||
| record_id="${BASH_REMATCH[1]}" | |||
| fi | |||
| if [[ -z "$record_id" ]]; then | |||
| echo "No _acme-challenge.${fulldomain} TXT record found" | |||
| exit 0 | |||
| fi | |||
| resp=$(curl --silent \ | |||
| "${curl_params[@]}" \ | |||
| -X DELETE "${API}/${domain_id}/record/${record_id}") | |||
| # If adding record failed (exception:) then print error message | |||
| if [[ "$resp" != *"\"statusCode\":200"* ]]; then | |||
| echo "Error: DNS challenge not added: unknown error - ${resp}" | |||
| exit 3 | |||
| fi | |||
| @ -0,0 +1,29 @@ | |||
| FROM centos:centos7 | |||
| # Note this image uses gawk | |||
| # Update and install required software | |||
| RUN yum -y update | |||
| RUN yum -y install epel-release | |||
| RUN yum -y install git curl bind-utils ldns wget which nginx | |||
| ENV staging "true" | |||
| ENV dynamic_dns "duckdns" | |||
| ENV DYNU_API_KEY 65cXefd35XbYf36546eg5dYcZT6X52Y2 | |||
| 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 | |||
| COPY ./test/test-config/nginx-centos7.conf /etc/nginx/nginx.conf | |||
| # BATS (Bash Automated Testings) | |||
| RUN git clone https://github.com/bats-core/bats-core.git /bats-core --branch v1.2.1 | |||
| RUN git clone https://github.com/bats-core/bats-support /bats-support | |||
| RUN git clone https://github.com/bats-core/bats-assert /bats-assert | |||
| RUN /bats-core/install.sh /usr/local | |||
| EXPOSE 80 443 | |||
| # Run eternal loop - for testing | |||
| CMD tail -f /dev/null | |||
| @ -0,0 +1,30 @@ | |||
| FROM ubuntu:latest | |||
| # Note this image uses mawk1.3 | |||
| # Set noninteractive otherwise tzdata hangs | |||
| ENV DEBIAN_FRONTEND noninteractive | |||
| # Ensure tests in this image use the staging server | |||
| ENV staging "true" | |||
| ENV dynamic_dns "dynu" | |||
| ENV DYNU_API_KEY 65cXefd35XbYf36546eg5dYcZT6X52Y2 | |||
| # Update and install required software | |||
| RUN apt-get update --fix-missing | |||
| RUN apt-get install -y git curl dnsutils ldnsutils wget nginx-light | |||
| RUN apt-get install -y vim dos2unix # for debugging | |||
| WORKDIR /root | |||
| # Prevent "Can't load /root/.rnd into RNG" error from openssl | |||
| RUN touch /root/.rnd | |||
| # BATS (Bash Automated Testings) | |||
| RUN git clone https://github.com/bats-core/bats-core.git /bats-core --branch v1.2.1 | |||
| RUN git clone https://github.com/bats-core/bats-support /bats-support | |||
| RUN git clone https://github.com/bats-core/bats-assert /bats-assert | |||
| RUN /bats-core/install.sh /usr/local | |||
| # Run eternal loop - for testing | |||
| CMD tail -f /dev/null | |||
| @ -0,0 +1,6 @@ | |||
| #!/bin/bash | |||
| # Special test script which will always fail to update dns | |||
| echo "This is a test script to check retry works if DNS isn't updated" | |||
| exit 0 | |||
| @ -1,19 +0,0 @@ | |||
| #!/bin/bash | |||
| # Special test script which will always fail to update dns | |||
| token=${DUCKDNS_TOKEN:-} | |||
| if [ -z "$token" ]; then | |||
| echo "DUCKDNS_TOKEN not set" | |||
| exit 1 | |||
| fi | |||
| domain="$1" | |||
| response=$(curl --retry 5 --silent "https://www.duckdns.org/update?domains=${domain}&token=${token}&txt=FAIL") | |||
| if [ "$response" != "OK" ]; then | |||
| echo "Failed to update TXT record for ${domain} at duckdns.org (is the TOKEN valid?)" | |||
| echo "Response: $response" | |||
| exit 1 | |||
| fi | |||
| @ -1,33 +0,0 @@ | |||
| # Special config to test that the retry dns_add_command logic works | |||
| # | |||
| CA="https://acme-staging-v02.api.letsencrypt.org/directory" | |||
| # Generic staging config | |||
| VALIDATE_VIA_DNS=true | |||
| DNS_DEL_COMMAND="/getssl/dns_scripts/dns_del_duckdns" | |||
| PUBLIC_DNS_SERVER=ns2.duckdns.org | |||
| CHECK_ALL_AUTH_DNS=true | |||
| # Test that the retry works (dns_add_command will always fail) | |||
| DNS_WAIT_RETRY_ADD="true" | |||
| DNS_ADD_COMMAND="/getssl/test/dns_fail_add_duckdns" | |||
| # Speed up the test by reducing the number or retries and the wait between retries. | |||
| DNS_WAIT=2 | |||
| DNS_WAIT_COUNT=11 | |||
| DNS_EXTRA_WAIT=0 | |||
| # Standard config | |||
| ACCOUNT_KEY_TYPE="rsa" | |||
| PRIVATE_KEY_ALG="rsa" | |||
| SANS="" | |||
| ACL=('/var/www/html/.well-known/acme-challenge') | |||
| USE_SINGLE_ACL="false" | |||
| 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 | |||
| RELOAD_CMD="cp /getssl/test/test-config/nginx-ubuntu-ssl ${NGINX_CONFIG} && /getssl/test/restart-nginx" | |||
| SERVER_TYPE="https" | |||
| CHECK_REMOTE="true" | |||
| @ -1,36 +0,0 @@ | |||
| # Test that the script works with external dns provider and staging server | |||
| # | |||
| CA="https://acme-staging-v02.api.letsencrypt.org" | |||
| VALIDATE_VIA_DNS=true | |||
| DNS_ADD_COMMAND="/getssl/dns_scripts/dns_add_duckdns" | |||
| DNS_DEL_COMMAND="/getssl/dns_scripts/dns_del_duckdns" | |||
| PUBLIC_DNS_SERVER=ns2.duckdns.org | |||
| CHECK_ALL_AUTH_DNS=true | |||
| DNS_EXTRA_WAIT=120 | |||
| # Speed up the test by reducing the number or retries and the wait between retries. | |||
| DNS_WAIT=2 | |||
| DNS_WAIT_COUNT=11 | |||
| DNS_WAIT_RETRY_ADD="true" | |||
| ACCOUNT_KEY_TYPE="rsa" | |||
| PRIVATE_KEY_ALG="rsa" | |||
| # Additional domains - this could be multiple domains / subdomains in a comma separated list | |||
| SANS="" | |||
| # Location for all your certs, these can either be on the server (full path name) | |||
| # or using ssh /sftp as for the ACL | |||
| 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} && /getssl/test/restart-nginx" | |||
| # Define the server type and confirm correct certificate is installed (using a custom port) | |||
| SERVER_TYPE="https" | |||
| CHECK_REMOTE="true" | |||