Skip to content

Commit

Permalink
fix ordering of DID document context (#3375)
Browse files Browse the repository at this point in the history
* fix ordering of DID document context

* add e2e-test to check all generated DID documents have the correct 0-th context

---------

Co-authored-by: Gerard Snaauw <gerard.snaauw@nedap.com>
  • Loading branch information
woutslakhorst and gerardsn committed Sep 16, 2024
1 parent b66f65d commit 3a20c44
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 2 deletions.
11 changes: 11 additions & 0 deletions e2e-tests/ops/create-subject/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
services:
nodeA:
image: "${IMAGE_NODE_A:-nutsfoundation/nuts-node:master}"
ports:
- "18081:8081"
environment:
NUTS_CONFIGFILE: /opt/nuts/nuts.yaml
volumes:
- "./nuts.yaml:/opt/nuts/nuts.yaml:ro"
healthcheck:
interval: 1s # Make test run quicker by checking health status more often
39 changes: 39 additions & 0 deletions e2e-tests/ops/create-subject/run-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
source ../../util.sh

echo "------------------------------------"
echo "Cleaning up running Docker containers and volumes, and key material..."
echo "------------------------------------"
docker compose down
docker compose rm -f -v

echo "------------------------------------"
echo "Starting Docker containers..."
echo "------------------------------------"
docker compose up -d --remove-orphans
docker compose up --wait nodeA

echo "------------------------------------"
echo "Registering vendors..."
echo "------------------------------------"

# Create Subject
DID_DOCS=$(curl -s -X POST http://localhost:18081/internal/vdr/v2/subject)
# Get @context at index 0 from all DID Documents
FIRST_CONTEXT=$(echo ${DID_DOCS} | jq -r '.documents[]["@context"][0]')
COUNTER=0
for row in ${FIRST_CONTEXT}; do
if [ "$row" != "https://www.w3.org/ns/did/v1" ]; then
FAILING_DID=$(echo ${DID_DOCS} | jq -r ".documents[${COUNTER}].id")
echo "First Context in DID Document '${FAILING_DID}' ($row) is not equal to https://www.w3.org/ns/did/v1"
echo ${DID_DOCS} | jq -r .documents[${COUNTER}]
docker compose stop
exit 1
fi
COUNTER=$((COUNTER + 1))
done

echo "------------------------------------"
echo "Stopping Docker containers..."
echo "------------------------------------"
docker compose stop
7 changes: 7 additions & 0 deletions e2e-tests/ops/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
#pushd key-rotation
#./run-test.sh
#popd

echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!! Running test: Create Subject !!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
pushd create-subject
./run-test.sh
popd
3 changes: 2 additions & 1 deletion storage/orm/did_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ func (sqlDoc DidDocument) GenerateDIDDocument() (did.Document, error) {
document := did.Document{
AlsoKnownAs: others,
Context: []interface{}{
jsonld.JWS2020ContextV1URI(), did.DIDContextV1URI(),
did.DIDContextV1URI(),
jsonld.JWS2020ContextV1URI(),
},
ID: *id,
}
Expand Down
2 changes: 1 addition & 1 deletion vdr/didnuts/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const MethodName = "nuts"
// CreateDocument creates an empty DID document with baseline properties set.
func CreateDocument() did.Document {
return did.Document{
Context: []interface{}{jsonld.JWS2020ContextV1URI(), did.DIDContextV1URI()},
Context: []interface{}{did.DIDContextV1URI(), jsonld.JWS2020ContextV1URI()},
}
}

Expand Down

0 comments on commit 3a20c44

Please sign in to comment.