forked from dydra/http-api-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinitialize-minimal.sh
More file actions
executable file
·120 lines (100 loc) · 6.46 KB
/
initialize-minimal.sh
File metadata and controls
executable file
·120 lines (100 loc) · 6.46 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#! /bin/bash
# create one account/repository for each of various authorization combinations
#
# $STORE_ACCOUNT : the base account
# $STORE_ACCOUNT/$STORE_REPOSITORY : owner authorization for read/write - the normal case
# $STORE_ACCOUNT/$STORE_REPOSITORY-write : owner authorization for read/write - the normal case (this one is modified)
# $STORE_ACCOUNT/$STORE_REPOSITORY_PUBLIC : owner plus anonymous (agent) read
# $STORE_ACCOUNT/collation
# $STORE_ACCOUNT/inference
# $STORE_ACCOUNT/ldp
# $STORE_ACCOUNT/tpf
#
# n.b. creation requires admin priviledges
# the general process is
# unset STORE_URL
# unset STORE_TOKEN
# unset STORE_TOKEN_COLLABORATOR
# unset STORE_TOKEN_ADMIN
# export STORE_HOST=<host>.dydra.com
# bash initialize-minimal.sh
# http api tests : repository creation and content initialization
set -e
if [[ "" == "${STORE_TOKEN}" ]]
then source ./define.sh
fi
for account in ${STORE_ACCOUNT} jhacker test; do create_account $account; done
for repository in ${STORE_REPOSITORY} ${STORE_REPOSITORY_WRITABLE} ${STORE_REPOSITORY_PUBLIC} ${STORE_REPOSITORY_PROVENANCE} \
foaf collation inference ldp public tpf; do
create_repository --repository $repository --class ${STORE_REPOSITORY_CLASS}
done
create_repository --account test --repository test --class ${STORE_REPOSITORY_CLASS}
create_repository --account test --repository foaf --class ${STORE_REPOSITORY_CLASS}
create_repository --account system --repository null --class ${STORE_REPOSITORY_CLASS}
# authorization and metadata :
# add authorization for authenticated users to read the repository list either from both accounts-api and the sesame resources
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN_ADMIN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| tee ${ECHO_OUTPUT} | egrep -q "${STATUS_POST_SUCCESS}"
_:aclBase1 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase1 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase1 <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase1 <http://www.w3.org/ns/auth/acl#agent> <urn:dydra:User> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
_:aclBase2 <http://www.w3.org/ns/auth/acl#agent> <http://xmlns.com/foaf/0.1/Agent> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}> .
EOF
# twice, in order to get a second revision
initialize_repository_content
initialize_repository_content
initialize_repository_public
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: text/turtle" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/foaf/service <<EOF \
| tee ${ECHO_OUTPUT} | egrep -q "${STATUS_POST_SUCCESS}"
@base <http://dydra.com/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://www.setf.de/#self>
a <http://xmlns.com/foaf/0.1/Project> ;
<http://xmlns.com/foaf/0.1/homepage> <https://rdf4j.org> ;
<http://xmlns.com/foaf/0.1/mbox> <rdf4j-dev@eclipse.org> ;
<http://xmlns.com/foaf/0.1/name> "Eclipse RDF4J" .
EOF
# ${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC} : owner plus anonymous (agent) read
# metadata w/ anonymous read access
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/${STORE_ACCOUNT}/system/service <<EOF \
| tee ${ECHO_OUTPUT} | egrep -q "${STATUS_POST_SUCCESS}"
_:aclAnon <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC}> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#accessTo> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#mode> <http://www.w3.org/ns/auth/acl#Read> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
_:aclAnon <http://www.w3.org/ns/auth/acl#agent> <http://xmlns.com/foaf/0.1/Agent> <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
<http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> <http://purl.org/dc/elements/1.1/description> "An account to test anonymous access to its content" <http://${STORE_SITE}/accounts/${STORE_ACCOUNT}/repositories/${STORE_REPOSITORY_PUBLIC}> .
EOF
# and minimal data
${CURL} -w "%{http_code}\n" -L -f -s -X PUT \
-H "Accept: application/n-quads" \
-H "Content-Type: application/n-quads" --data-binary @- \
-u "${STORE_TOKEN}:" \
${STORE_URL}/${STORE_ACCOUNT}/${STORE_REPOSITORY_PUBLIC}/service <<EOF \
| tee ${ECHO_OUTPUT} | egrep -q "${STATUS_PUT_SUCCESS}"
<http://example.com/subject> <http://example.com/predicate> "object" <${STORE_URL}>.
EOF
## also for the test/foaf repository
${CURL} -w "%{http_code}\n" -L -f -s -X POST \
-H "Content-Type: application/n-quads" --data-binary @- \
-u ":${STORE_TOKEN}" \
${STORE_URL}/test/foaf/service <<EOF \
| tee ${ECHO_OUTPUT} | egrep -q "${STATUS_POST_SUCCESS}"
<http://www.setf.de/#self> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Agent> .
<http://www.setf.de/#self> <http://xmlns.com/foaf/0.1/name> "test" .
<http://www.setf.de/#self> <http://xmlns.com/foaf/0.1/homepage> <http://dydra.com/test> .
<http://www.setf.de/#self> <http://xmlns.com/foaf/0.1/mbox> <mailto:test@dydra.com> .
EOF