Skip to content

Commit

Permalink
fixup! integration test: overhaul read-binary-content test
Browse files Browse the repository at this point in the history
  • Loading branch information
allentiak committed Nov 20, 2024
1 parent 491b346 commit 2bb415f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions .github/scripts/read-binary-content.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ BASE="http://localhost:8080/fhir"
# 10 KiB of random data, base64 encoded
DATA="$(openssl rand -base64 10240 | tr -d '\n')"

echo "Ramdom Data: $DATA"

binary() {
cat <<END
{
Expand All @@ -21,20 +23,16 @@ cat <<END
END
}

# Create Binary resource and get its ID
# Create a Binary resource that contains that data, and get its ID
ID=$(curl -s -H 'Content-Type: application/fhir+json' -d "$(binary)" "$BASE/Binary" | jq -r .id)

echo "Created Binary resource with ID: $ID"

# Retrieve the Binary resource
BINARY_RESULT=$(curl -s -H 'Accept: application/pdf' "$BASE/Binary/$ID")

echo "Binary Result: $BINARY_RESULT"
echo "Created Binary resource that contains the Random Data, with ID: $ID"

BASE64_RESULT=$(echo "$BINARY_RESULT" | base64 | tr -d '\n')
# Retrieve the Binary resource, and Base64 encode it so it can be safely handled by Bash
BASE64_ENCODED_BINARY_RESOURCE=$(curl -s -H 'Accept: application/pdf' "$BASE/Binary/$ID" | base64 | tr -d '\n')

echo "Base 64 Result: $BASE64_RESULT"
echo "Binary Result, Base 64 encoded: $BASE64_ENCODED_BINARY_RESOURCE"

echo "Binary data retrieved. Verifying content..."

test "Base64 encoding of Resource data" "$DATA" "$BASE64_RESULT"
test "Base64 encoding of Resource data" "$DATA" "$BASE64_ENCODED_BINARY_RESOURCE"

0 comments on commit 2bb415f

Please sign in to comment.