Skip to content

Commit

Permalink
fix e2e test to use existing secrets files
Browse files Browse the repository at this point in the history
  • Loading branch information
igor47 committed Dec 11, 2023
1 parent 393104d commit 4d0a3d9
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 30 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.direnv

docker-compose.yml
e2e/
example/
justfile
README.md
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.direnv

example/templates
e2e/secrets
e2e/templates
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ services:

tester:
image: bash:latest
command: ["bash", "/templates/confirm.sh"]
command: ["bash", "/example/confirm.sh"]
depends_on:
dcsm:
condition: service_completed_successfully
volumes:
- ./templates:/templates
- ./example:/example
2 changes: 1 addition & 1 deletion example/confirm.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Path to the file to check
file_path="/templates/test"
file_path="/example/templates/test"

# The expected content
expected_content="expected string"
Expand Down
Binary file modified example/secrets.encrypted
Binary file not shown.
1 change: 1 addition & 0 deletions example/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ LONG_SECRET: |
this is a very long secret.
like, a paragraph.
or maybe an essay.
TEST: "expected string"
30 changes: 6 additions & 24 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,13 @@ encrypt:
decrypt:
docker compose run --build --rm dcsm decrypt

test-run:
#!/usr/bin/env bash
set -euo pipefail
export DCSM_KEYFILE=example/key.private
export DCSM_SECRETS_FILE=example/secrets.encrypted
export DCSM_TEMPLATE_DIR1=example/templates
python3 ./dcsn.py decrypt
docker-decrypt: build
docker run --rm --env DCSM_KEYFILE=/run/secrets/key.private --env DCSM_SECRET_FILE=/run/secrets/secrets.encrypted --env DCSM_TEMPLATE_DIR1=/run/secrets/templates --volume ${PWD}/example:/run/secrets dcsn:latest
run:
docker compose run --build --rm dcsm

docker-e2e:
test:
#!/usr/bin/env bash
set -euo pipefail
cd e2e
#
# remove any dangling files from previous test
rm -rf templates/test secrets
#
# make a secrets directory with key and encrypted secrets file
mkdir -p secrets
age-keygen -o secrets/key.private
echo 'TEST: "expected string"' > secrets/secrets.yaml
age --encrypt --armor --identity secrets/key.private --output secrets/secrets.encrypted secrets/secrets.yaml
rm secrets/secrets.yaml
#
# remove dangling result from previous test
rm -rf example/templates/test
# now run the test
docker compose up
docker compose up --build --remove-orphans --force-recreate

0 comments on commit 4d0a3d9

Please sign in to comment.