|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +initialize_dataset "$END_USER_BASE_URL" "$TMP_END_USER_DATASET" "$END_USER_ENDPOINT_URL" |
| 5 | +initialize_dataset "$ADMIN_BASE_URL" "$TMP_ADMIN_DATASET" "$ADMIN_ENDPOINT_URL" |
| 6 | +purge_cache "$END_USER_VARNISH_SERVICE" |
| 7 | +purge_cache "$ADMIN_VARNISH_SERVICE" |
| 8 | +purge_cache "$FRONTEND_VARNISH_SERVICE" |
| 9 | + |
| 10 | +# add agent to the writers group |
| 11 | + |
| 12 | +add-agent-to-group.sh \ |
| 13 | + -f "$OWNER_CERT_FILE" \ |
| 14 | + -p "$OWNER_CERT_PWD" \ |
| 15 | + --agent "$AGENT_URI" \ |
| 16 | + "${ADMIN_BASE_URL}acl/groups/writers/" |
| 17 | + |
| 18 | +# PATCH the root with an INSERT that introduces a blank node. |
| 19 | +# Use rdf:_99 to avoid colliding with existing rdf:_1..rdf:_8 in the test dataset. |
| 20 | +# Expected: 204 No Content; the blank node is skolemized to a hash URI before persisting. |
| 21 | + |
| 22 | +update=$(cat <<EOF |
| 23 | +PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> |
| 24 | +PREFIX dct: <http://purl.org/dc/terms/> |
| 25 | +
|
| 26 | +INSERT |
| 27 | +{ |
| 28 | + <${END_USER_BASE_URL}> rdf:_99 _:bnode0 . |
| 29 | + _:bnode0 dct:title "Blank node title" |
| 30 | +} |
| 31 | +WHERE |
| 32 | +{} |
| 33 | +EOF |
| 34 | +) |
| 35 | + |
| 36 | +curl -k -w "%{http_code}\n" -o /dev/null -f -s \ |
| 37 | + -E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \ |
| 38 | + -X PATCH \ |
| 39 | + -H "Content-Type: application/sparql-update" \ |
| 40 | + "$END_USER_BASE_URL" \ |
| 41 | + --data-binary "$update" \ |
| 42 | +| grep -q "$STATUS_NO_CONTENT" |
| 43 | + |
| 44 | +# fetch the persisted graph and verify the blank node was skolemized to a hash URI |
| 45 | + |
| 46 | +response=$(curl -k -f -s -G \ |
| 47 | + -E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \ |
| 48 | + -H "Accept: application/n-triples" \ |
| 49 | + "$END_USER_BASE_URL") |
| 50 | + |
| 51 | +rdf_99_line=$(echo "$response" | grep -E "^<${END_USER_BASE_URL}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#_99>" || true) |
| 52 | + |
| 53 | +[ -n "$rdf_99_line" ] || exit 1 |
| 54 | + |
| 55 | +# object of rdf:_99 must be a URI (<...>), not a blank node label (_:...) |
| 56 | +! echo "$rdf_99_line" | grep -qE '_:[A-Za-z0-9]+ \.$' |
| 57 | +echo "$rdf_99_line" | grep -qE '<\S+> \.$' |
0 commit comments