Skip to content

Commit

Permalink
Some minority fixes in test environment, new test and wrong placement…
Browse files Browse the repository at this point in the history
… of debug message
  • Loading branch information
rvojcik committed Nov 9, 2021
1 parent 6c5ce7f commit a903dc5
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 1 deletion.
11 changes: 11 additions & 0 deletions dev/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3.3'

services:
test:
image: 'python:3.9'
volumes:
- ../:/workdir
- ./:/develop
command:
- /develop/run-tests.sh
- /workdir
12 changes: 12 additions & 0 deletions dev/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

echo "Entering directory $1"
cd $1/

apt-get update
apt-get install -y $(cat tests/system-requirements.txt)
pip install -r requirements.txt
python setup.py install
run-parts --exit-on-error --regex '^[0-9]+.*\.sh$' ./tests/
2 changes: 1 addition & 1 deletion scripts/vault-certificate-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ if __name__ == '__main__':
for cert_name in cert_list:
base.pdeb("Retrieving secret " + cert_name, args.debug)
secret = vault.read(vault_mount_point + "/" + cert_name)
base.pdeb("Secret: %s with keys %s" % (str(secret), str(secret.keys())), args.debug)

if secret is not None:
base.pdeb("Secret: %s with keys %s" % (str(secret), str(secret.keys())), args.debug)
certificates.append((cert_name, secret))
Expand Down
5 changes: 5 additions & 0 deletions tests/01-prepare-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ cat > deploy3.conf <<EOF
invalid-cert
EOF

echo "Prepair deploy config4"
cat > deploy4.conf <<EOF
_cert.that.not-exists
EOF

echo "Prepair client deploy"
cat > client_cert.conf << EOF
test1.test.intra
Expand Down
File renamed without changes.
33 changes: 33 additions & 0 deletions tests/13-deploy4-noexist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

cat <<EOF
=======================================
Non existent cert DEPLOY (good to fail)
---------------------------------------
Check fail states and correct exitcodes
for certs that non exists
=======================================
EOF

if [[ -f ./vault.env ]] ; then
. ./vault.env
else
echo "Unable to find vault.env file from previous step"
exit 1
fi

# Test fail deploy
if $script -c ./script.conf --cert-list deploy4.conf ; then
echo "ERROR: Deploy success when certificate was bad." >&2
exit 1
else
echo "It's OK to fail, looks good :)"
fi

if [[ $(find $cert_destination -type f -name '*.crt' | wc -l) -gt 0 ]] ; then
echo "ERROR: There should be no certificates in this step" >&2
exit 1
else
echo "Success, no certificates left in this step"
fi

0 comments on commit a903dc5

Please sign in to comment.