-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathPATCH-empty-container.sh
More file actions
executable file
·58 lines (47 loc) · 1.35 KB
/
PATCH-empty-container.sh
File metadata and controls
executable file
·58 lines (47 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env bash
set -euo pipefail
initialize_dataset "$END_USER_BASE_URL" "$TMP_END_USER_DATASET" "$END_USER_ENDPOINT_URL"
initialize_dataset "$ADMIN_BASE_URL" "$TMP_ADMIN_DATASET" "$ADMIN_ENDPOINT_URL"
purge_cache "$END_USER_VARNISH_SERVICE"
purge_cache "$ADMIN_VARNISH_SERVICE"
purge_cache "$FRONTEND_VARNISH_SERVICE"
# add agent to the writers group
add-agent-to-group.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
--agent "$AGENT_URI" \
"${ADMIN_BASE_URL}acl/groups/writers/"
# create a container with random slug
slug=$(uuidgen | tr '[:upper:]' '[:lower:]')
container=$(create-container.sh \
-f "$AGENT_CERT_FILE" \
-p "$AGENT_CERT_PWD" \
-b "$END_USER_BASE_URL" \
--title "Test container" \
--slug "$slug" \
--parent "$END_USER_BASE_URL")
# PATCH with empty result (DELETE all triples) should succeed and delete the container
update=$(cat <<EOF
DELETE
{
?s ?p ?o
}
WHERE
{
?s ?p ?o
}
EOF
)
curl -k -w "%{http_code}\n" -o /dev/null -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-X PATCH \
-H "Content-Type: application/sparql-update" \
"$container" \
--data-binary "$update" \
| grep -q "$STATUS_NO_CONTENT"
# verify the container was deleted
curl -k -w "%{http_code}\n" -o /dev/null -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
"$container" \
| grep -q "$STATUS_NOT_FOUND"