|
| 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 readers group to be able to read documents |
| 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/readers/" |
| 17 | + |
| 18 | +# use a made-up hash-based namespace: not mapped as a static file, not a registered app |
| 19 | +namespace_uri="http://made-up-test-ns.example/ns" |
| 20 | +class1="${namespace_uri}#ClassOne" |
| 21 | +class2="${namespace_uri}#ClassTwo" |
| 22 | +ontology_doc="${ADMIN_BASE_URL}ontologies/namespace/" |
| 23 | +namespace="${END_USER_BASE_URL}ns#" |
| 24 | + |
| 25 | +# add two classes with URIs in the made-up namespace to the app's ontology |
| 26 | + |
| 27 | +add-class.sh \ |
| 28 | + -f "$OWNER_CERT_FILE" \ |
| 29 | + -p "$OWNER_CERT_PWD" \ |
| 30 | + -b "$ADMIN_BASE_URL" \ |
| 31 | + --uri "$class1" \ |
| 32 | + --label "Class One" \ |
| 33 | + "$ontology_doc" |
| 34 | + |
| 35 | +add-class.sh \ |
| 36 | + -f "$OWNER_CERT_FILE" \ |
| 37 | + -p "$OWNER_CERT_PWD" \ |
| 38 | + -b "$ADMIN_BASE_URL" \ |
| 39 | + --uri "$class2" \ |
| 40 | + --label "Class Two" \ |
| 41 | + "$ontology_doc" |
| 42 | + |
| 43 | +# clear the in-memory ontology so the new classes are present on next request |
| 44 | + |
| 45 | +clear-ontology.sh \ |
| 46 | + -f "$OWNER_CERT_FILE" \ |
| 47 | + -p "$OWNER_CERT_PWD" \ |
| 48 | + -b "$ADMIN_BASE_URL" \ |
| 49 | + --ontology "$namespace" |
| 50 | + |
| 51 | +# request the namespace document URI (without fragment) via ?uri= proxy. |
| 52 | +# the namespace document is not DataManager-mapped and not a registered app, |
| 53 | +# so ProxyRequestFilter falls through to the OntModel DESCRIBE path, which |
| 54 | +# returns descriptions of all #-fragment terms in that namespace. |
| 55 | + |
| 56 | +response=$(curl -k -f -s \ |
| 57 | + -G \ |
| 58 | + -E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \ |
| 59 | + -H "Accept: application/n-triples" \ |
| 60 | + --data-urlencode "uri=${namespace_uri}" \ |
| 61 | + "$END_USER_BASE_URL") |
| 62 | + |
| 63 | +# verify both class descriptions are present in the response |
| 64 | + |
| 65 | +echo "$response" | grep -q "$class1" |
| 66 | +echo "$response" | grep -q "$class2" |
0 commit comments