Skip to content

Commit

Permalink
Add Write Permission Check
Browse files Browse the repository at this point in the history
Fixes: #31
  • Loading branch information
bastianschaffer committed Sep 17, 2024
1 parent 1196f0f commit 047cb9e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
16 changes: 16 additions & 0 deletions .github/integration-test/missing-permissions-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash -e

BASE_OUTPUT_DIR=$PWD/.github/integration-test/missing-permissions-test
mkdir "$BASE_OUTPUT_DIR"

OUTPUT=$(docker run -v "$PWD"/.github/integration-test/measures/code-measure.json:/app/measure.json \
-v "$BASE_OUTPUT_DIR":/app/output:ro --network integration-test_testing-network -e FHIR_SERVER=http://fhir-server:8080/fhir \
-it fhir-data-evaluator)
EXIT_CODE=$?

if [ "$OUTPUT" = "Missing writing permissions on output directory" ] && [ $EXIT_CODE = 1 ]; then
echo "OK 👍: docker container exited with code 1 and with the correct error message"
else
echo "Fail 😞: docker container did not exit with code 1 or with a different error message"
exit 1
fi
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ jobs:
- name: Run Integration Test for Unique Count with Components and with CSV
run: .github/integration-test/evaluate-unique-count-with-components-to-csv.sh /${PWD}/.github/integration-test/measures/unique-count-with-components-measure.json

- name: Run Integration Test to check if it correctly exits when there are insufficient writing permissions
run: .github/integration-test/missing-permissions-test.sh


push-image:
needs:
Expand Down
5 changes: 5 additions & 0 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#!/bin/bash -e

if [ ! -w /app/output ]; then
echo "Missing writing permissions on output directory" >&2
exit 1
fi

today=$(date +"%Y-%m-%d_%H-%M-%S")
measureName="$(jq -c --raw-output '.name' /app/measure.json)"
outputDir="$today-$measureName"
Expand Down

0 comments on commit 047cb9e

Please sign in to comment.