Skip to content

Commit d6ec654

Browse files
committed
HTTP test fixes
1 parent 4fca361 commit d6ec654

2 files changed

Lines changed: 54 additions & 20 deletions

File tree

http-tests/admin/acl/agent-acl-modes.sh

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,45 @@ purge_cache "$END_USER_VARNISH_SERVICE"
77
purge_cache "$ADMIN_VARNISH_SERVICE"
88
purge_cache "$FRONTEND_VARNISH_SERVICE"
99

10-
# test that the signed up agent accessing BASE_URL returns correct Link header with ACL modes (no Control)
10+
# add agent to the writers group
1111

12-
RESPONSE_HEADERS=$(mktemp)
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/"
1317

14-
curl -k -f \
18+
# create a new document to test ACL modes against
19+
20+
doc_url=$(create-item.sh \
21+
-b "$END_USER_BASE_URL" \
22+
-f "$AGENT_CERT_FILE" \
23+
-p "$AGENT_CERT_PWD" \
24+
--container "$END_USER_BASE_URL" \
25+
--title "ACL Test Document Agent" \
26+
--slug "acl-test-document-agent"
27+
)
28+
29+
# test that the signed up agent accessing the document returns correct Link header with ACL modes (no Control)
30+
31+
response_headers=$(mktemp)
32+
33+
curl -k -f -v \
1534
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
1635
-H "Accept: application/n-triples" \
17-
-D "$RESPONSE_HEADERS" \
36+
-D "$response_headers" \
1837
-o /dev/null \
19-
"$END_USER_BASE_URL"
38+
"$doc_url"
39+
40+
cat "$response_headers"
2041

2142
# check that each expected ACL mode is present in Link header (order independent)
2243
# signed up agents should have Read, Write, Append but NOT Control
23-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Read>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
24-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Write>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
25-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Append>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
44+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Read>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
45+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Write>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
46+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Append>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
2647

2748
# verify Control mode is NOT present for signed up agent
28-
! grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Control>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
49+
! grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Control>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
2950

30-
rm "$RESPONSE_HEADERS"
51+
rm "$response_headers"

http-tests/admin/acl/owner-acl-modes.sh

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,34 @@ purge_cache "$END_USER_VARNISH_SERVICE"
77
purge_cache "$ADMIN_VARNISH_SERVICE"
88
purge_cache "$FRONTEND_VARNISH_SERVICE"
99

10-
# test that the owner agent accessing BASE_URL returns correct Link header with all ACL modes
10+
# create a new document to test ACL modes against
1111

12-
RESPONSE_HEADERS=$(mktemp)
12+
doc_url=$(create-item.sh \
13+
-b "$END_USER_BASE_URL" \
14+
-f "$OWNER_CERT_FILE" \
15+
-p "$OWNER_CERT_PWD" \
16+
--container "$END_USER_BASE_URL" \
17+
--title "ACL Test Document" \
18+
--slug "acl-test-document"
19+
)
1320

14-
curl -k -f \
21+
# test that the owner agent accessing the document returns correct Link header with all ACL modes
22+
23+
response_headers=$(mktemp)
24+
25+
curl -k -f -v \
1526
-E "$OWNER_CERT_FILE":"$OWNER_CERT_PWD" \
1627
-H "Accept: application/n-triples" \
17-
-D "$RESPONSE_HEADERS" \
28+
-D "$response_headers" \
1829
-o /dev/null \
19-
"$END_USER_BASE_URL"
30+
"$doc_url"
31+
32+
cat "$response_headers"
2033

2134
# check that each ACL mode is present in Link header (order independent)
22-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Read>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
23-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Write>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
24-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Append>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
25-
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Control>; rel=http://www.w3.org/ns/auth/acl#mode" "$RESPONSE_HEADERS"
35+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Read>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
36+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Write>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
37+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Append>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
38+
grep -q "Link:.*<http://www.w3.org/ns/auth/acl#Control>; rel=http://www.w3.org/ns/auth/acl#mode" "$response_headers"
2639

27-
rm "$RESPONSE_HEADERS"
40+
rm "$response_headers"

0 commit comments

Comments
 (0)