Skip to content

Commit

Permalink
Add Auth to Curl in Integration Test
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianschaffer committed Nov 22, 2024
1 parent 463c016 commit 0f4f3ab
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/integration-test/basic-auth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Image is uses as base for a dummy container from which curl can request data within the same network as the other containers
FROM alpine
RUN apk add --no-cache curl
CMD ["sh", "-c", "while true; do sleep 3600; done"]
4 changes: 4 additions & 0 deletions .github/integration-test/basic-auth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ services:
volumes:
- "${FDE_INPUT_MEASURE:-../Documentation/example-measures/example-measure-kds.json}:/app/measure.json"
- "${FDE_OUTPUT_DIR:-../output}:/app/output"
curl-tester: # dummy container from which curl can request data within the same network as the other containers
build: .
entrypoint: [ "tail", "-f", "/dev/null" ]
command: ""
volumes:
data-store-data:
58 changes: 54 additions & 4 deletions .github/integration-test/evaluate-and-post-report.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash -e

AUTH="$1"
DOCKER_COMPOSE_FILE=.github/integration-test/"$1"/docker-compose.yml
PROJECT_IDENTIFIER_VALUE="$2"
export FDE_INPUT_MEASURE=/${PWD}/.github/integration-test/measures/icd10-measure.json
Expand All @@ -14,12 +15,61 @@ export FDE_SEND_REPORT_TO_SERVER=true
mkdir "$FDE_OUTPUT_DIR"
docker compose -f "$DOCKER_COMPOSE_FILE" run -e TZ="$(cat /etc/timezone)" fhir-data-evaluator

report_response=$(curl -s "http://localhost:8082/fhir/MeasureReport" \
-H "Content-Type: application/fhir+json")
get_response() {
URL="$1"
CURL_TESTER_ID=$(docker ps --filter "name=$AUTH-curl-tester-1" --format "{{.ID}}")
if [ "$AUTH" == "no-auth" ]; then
#response=$(curl -s "http://localhost:8080/fhir/$URL" \
# -H "Content-Type: application/fhir+json")
response=$(docker exec "$CURL_TESTER_ID" sh -c "
curl -s 'http://fhir-server:8080/fhir/$URL' -H 'Content-Type: application/fhir+json'")
echo "$response"
elif [ "$AUTH" == "basic-auth" ]; then
#response=$(curl -s "http://proxy:8080/fhir/$URL" \
# -H "Content-Type: application/fhir+json" \
# -u "test:bar")
response=$(docker exec "$CURL_TESTER_ID" sh -c "
curl -s 'http://proxy:8080/fhir/$URL' \
-H 'Content-Type: application/fhir+json' \
-u 'test:bar'")
echo "$response"
else
#oauth_response=$(curl -s -X POST "https://secure-keycloak:8443/realms/test/token" \
# -H "Content-Type: application/x-www-form-urlencoded" \
# -d "grant_type=client_credentials" \
# -d "client_id=account" \
# -d "client_secret=test")
oauth_response=$(docker exec "$CURL_TESTER_ID" sh -c "
curl -s -X POST 'https://secure-keycloak:8443/realms/test/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'grant_type=client_credentials' \
-d 'client_id=account' \
-d 'client_secret=test'")
FHIR_DESTINATION_BEARER_TOKEN=$(echo "$oauth_response" | jq -r '.access_token')
#echo "oauth response: $oauth_response"

#response=$(curl -s "https://secure-fhir-server:8443/fhir/$URL" \
# -H "Content-Type: application/fhir+json" \
# -H "Authorization: Bearer $FHIR_DESTINATION_BEARER_TOKEN")

response=$(docker exec "$CURL_TESTER_ID" sh -c "
curl -s 'https://secure-fhir-server:8443/fhir/$URL' \
-H 'Content-Type: application/fhir+json' \
-H 'Authorization: Bearer $FHIR_DESTINATION_BEARER_TOKEN'")

echo "$response"
fi
}


#report_response=$(curl -s "http://localhost:8082/fhir/MeasureReport" \
# -H "Content-Type: application/fhir+json")
report_response=$(get_response "MeasureReport")
echo "report response: $report_response"

reference_response=$(curl -s "http://localhost:8082/fhir/DocumentReference" \
-H "Content-Type: application/fhir+json")
#reference_response=$(curl -s "http://localhost:8082/fhir/DocumentReference" \
# -H "Content-Type: application/fhir+json")
reference_response=$(get_response "DocumentReference")
echo "reference response: $reference_response"

report_url=MeasureReport/$(echo "$report_response" | jq -r '.entry[0].resource.id')
Expand Down
4 changes: 4 additions & 0 deletions .github/integration-test/no-auth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Image is uses as base for a dummy container from which curl can request data within the same network as the other containers
FROM alpine
RUN apk add --no-cache curl
CMD ["sh", "-c", "while true; do sleep 3600; done"]
4 changes: 4 additions & 0 deletions .github/integration-test/no-auth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ services:
volumes:
- "${FDE_INPUT_MEASURE:-../Documentation/example-measures/example-measure-kds.json}:/app/measure.json"
- "${FDE_OUTPUT_DIR:-../output}:/app/output"
curl-tester: # dummy container from which curl can request data within the same network as the other containers
build: .
entrypoint: ["tail", "-f", "/dev/null"]
command: ""

volumes:
data-store-data:
4 changes: 4 additions & 0 deletions .github/integration-test/oauth/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Image is uses as base for a dummy container from which curl can request data within the same network as the other containers
FROM alpine
RUN apk add --no-cache curl
CMD ["sh", "-c", "while true; do sleep 3600; done"]
4 changes: 4 additions & 0 deletions .github/integration-test/oauth/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ services:
- "${FDE_INPUT_MEASURE:-../Documentation/example-measures/example-measure-kds.json}:/app/measure.json"
- "${FDE_OUTPUT_DIR:-../output}:/app/output"
- "certs:/app/certs"
curl-tester: # dummy container from which curl can request data within the same network as the other containers
build: .
entrypoint: [ "tail", "-f", "/dev/null" ]
command: ""
volumes:
data-store-data:
certs:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,11 @@ jobs:
- name: Run Integration Test for Posting the MeasureReport to the FHIR server
run: .github/integration-test/evaluate-and-post-report.sh ${{ matrix.test }} Test_PROJECT_Evaluation_1

- name: Run Integration Test for Posting the MeasureReport to the FHIR server with the Same Project Identifier
run: .github/integration-test/evaluate-and-post-update.sh ${{ matrix.test }} Test_PROJECT_Evaluation_1
#- name: Run Integration Test for Posting the MeasureReport to the FHIR server with the Same Project Identifier
# run: .github/integration-test/evaluate-and-post-update.sh ${{ matrix.test }} Test_PROJECT_Evaluation_1

- name: Run Integration Test for Posting the MeasureReport to the FHIR server with a Different Project Identifier
run: .github/integration-test/evaluate-and-post-different-doc-ref.sh ${{ matrix.test }} Test_PROJECT_Evaluation_2
#- name: Run Integration Test for Posting the MeasureReport to the FHIR server with a Different Project Identifier
# run: .github/integration-test/evaluate-and-post-different-doc-ref.sh ${{ matrix.test }} Test_PROJECT_Evaluation_2

- name: Remove Blaze volumes
run: docker compose -f .github/integration-test/${{ matrix.test }}/docker-compose.yml down -v
Expand Down

0 comments on commit 0f4f3ab

Please sign in to comment.