|
| 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 | +# Test that PATCH with DELETE WHERE that matches no triples does NOT delete the entire graph |
| 19 | +# This is a regression test for bug where changedModel.isEmpty() incorrectly triggered graph deletion |
| 20 | + |
| 21 | +# Create test graph URI |
| 22 | +test_graph_uri="${ADMIN_BASE_URL}test-graph-$(date +%s)/" |
| 23 | + |
| 24 | +# Create test graph with multiple triples using bin/put.sh |
| 25 | +echo "<http://example.org/resource1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/TestClass> . |
| 26 | +<http://example.org/resource1> <http://example.org/property1> \"value1\" . |
| 27 | +<http://example.org/resource1> <http://example.org/property2> \"value2\" . |
| 28 | +<http://example.org/resource2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/OtherClass> . |
| 29 | +<http://example.org/resource2> <http://example.org/property3> \"value3\" ." | \ |
| 30 | + put.sh \ |
| 31 | + -f "$OWNER_CERT_FILE" \ |
| 32 | + -p "$OWNER_CERT_PWD" \ |
| 33 | + -t "application/n-triples" \ |
| 34 | + "$test_graph_uri" |
| 35 | + |
| 36 | +# Execute PATCH with DELETE WHERE that matches nothing (non-existent triple) |
| 37 | +echo "PREFIX ex: <http://example.org/> |
| 38 | +PREFIX owl: <http://www.w3.org/2002/07/owl#> |
| 39 | +
|
| 40 | +DELETE WHERE { ex:nonExistentResource owl:imports ex:nonExistentOntology }" | \ |
| 41 | + patch.sh \ |
| 42 | + -f "$OWNER_CERT_FILE" \ |
| 43 | + -p "$OWNER_CERT_PWD" \ |
| 44 | + "$test_graph_uri" |
| 45 | + |
| 46 | +# Verify graph still exists and contains original triples |
| 47 | +graph_content=$(get.sh \ |
| 48 | + -f "$OWNER_CERT_FILE" \ |
| 49 | + -p "$OWNER_CERT_PWD" \ |
| 50 | + --accept "application/n-triples" \ |
| 51 | + "$test_graph_uri") |
| 52 | + |
| 53 | +# Verify essential triples are still present (grep for exact n-triples format) |
| 54 | +echo "$graph_content" | grep -q "<http://example.org/resource1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/TestClass>" |
| 55 | +echo "$graph_content" | grep -q "<http://example.org/resource1> <http://example.org/property1> \"value1\"" |
| 56 | +echo "$graph_content" | grep -q "<http://example.org/resource2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/OtherClass>" |
| 57 | +echo "$graph_content" | grep -q "<http://example.org/resource2> <http://example.org/property3> \"value3\"" |
0 commit comments