Skip to content

Commit 59dd0ac

Browse files
committed
Release version 5.0.22
2 parents e48c10e + 6267db3 commit 59dd0ac

51 files changed

Lines changed: 1578 additions & 314 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ It takes a few clicks and filling out a form to install the product into your ow
6060
./bin/server-cert-gen.sh .env nginx ssl
6161
```
6262
The script will create an `ssl` sub-folder where the SSL certificates and/or public keys will be placed.
63-
4. Create the following secrets with certificate passwords:
63+
4. Create the following secrets with certificate/truststore passwords:
6464
- `secrets/client_truststore_password.txt`
6565
- `secrets/owner_cert_password.txt`
6666
- `secrets/secretary_cert_password.txt`
67+
The one you will need to remember in order to authenticate with LinkedDataHub using WebID client certificate is `owner_cert_password`.
6768
5. Launch the application services by running this from command line:
6869
```shell
6970
docker-compose up --build

bin/patch.sh

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
3+
print_usage()
4+
{
5+
printf "Patches an RDF document using SPARQL update.\n"
6+
printf "\n"
7+
printf "Usage: cat update.rq | %s options TARGET_URI\n" "$0"
8+
printf "\n"
9+
printf "Options:\n"
10+
printf " -f, --cert-pem-file CERT_FILE .pem file with the WebID certificate of the agent\n"
11+
printf " -p, --cert-password CERT_PASSWORD Password of the WebID certificate\n"
12+
printf " --proxy PROXY_URL The host this request will be proxied through (optional)\n"
13+
}
14+
15+
hash turtle 2>/dev/null || { echo >&2 "turtle not on \$PATH. Aborting."; exit 1; }
16+
hash curl 2>/dev/null || { echo >&2 "curl not on \$PATH. Aborting."; exit 1; }
17+
18+
unknown=()
19+
while [[ $# -gt 0 ]]
20+
do
21+
key="$1"
22+
23+
case $key in
24+
-f|--cert-pem-file)
25+
cert_pem_file="$2"
26+
shift # past argument
27+
shift # past value
28+
;;
29+
-p|--cert-password)
30+
cert_password="$2"
31+
shift # past argument
32+
shift # past value
33+
;;
34+
--proxy)
35+
proxy="$2"
36+
shift # past argument
37+
shift # past value
38+
;;
39+
*) # unknown option
40+
unknown+=("$1") # save it in an array for later
41+
shift # past argument
42+
;;
43+
esac
44+
done
45+
set -- "${unknown[@]}" # restore args
46+
47+
if [ -z "$cert_pem_file" ] ; then
48+
print_usage
49+
exit 1
50+
fi
51+
if [ -z "$cert_password" ] ; then
52+
print_usage
53+
exit 1
54+
fi
55+
if [ "$#" -ne 1 ]; then
56+
print_usage
57+
exit 1
58+
fi
59+
60+
url="$1"
61+
62+
if [ -n "$proxy" ]; then
63+
# rewrite target hostname to proxy hostname
64+
url_host=$(echo "$url" | cut -d '/' -f 1,2,3)
65+
proxy_host=$(echo "$proxy" | cut -d '/' -f 1,2,3)
66+
final_url="${url/$url_host/$proxy_host}"
67+
else
68+
final_url="$url"
69+
fi
70+
71+
# resolve SPARQL update from stdin against base URL and PATCH it to the server
72+
# uparse currently does not support --base: https://github.com/apache/jena/issues/3296
73+
cat - | curl -v -k -E "$cert_pem_file":"$cert_password" --data-binary @- -H "Content-Type: application/sparql-update" -X PATCH -o /dev/null "$final_url"

docker-compose.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ configs:
154154
server varnish-frontend:6060;
155155
}
156156
157-
limit_req_zone $$binary_remote_addr zone=linked_data:10m rate=6r/s;
157+
limit_req_zone $$binary_remote_addr zone=linked_data:10m rate=15r/s;
158158
limit_req_zone $$binary_remote_addr zone=static_files:10m rate=20r/s;
159159
limit_req_status 429;
160160
@@ -173,7 +173,7 @@ configs:
173173
location / {
174174
proxy_pass http://linkeddatahub;
175175
#proxy_cache backcache;
176-
limit_req zone=linked_data burst=20 nodelay;
176+
limit_req zone=linked_data burst=30 nodelay;
177177
178178
proxy_set_header Client-Cert '';
179179
proxy_set_header Client-Cert $$ssl_client_escaped_cert;
@@ -212,7 +212,7 @@ configs:
212212
location / {
213213
proxy_pass http://linkeddatahub;
214214
#proxy_cache backcache;
215-
limit_req zone=linked_data burst=20 nodelay;
215+
limit_req zone=linked_data burst=30 nodelay;
216216
217217
proxy_set_header Client-Cert '';
218218
proxy_set_header Client-Cert $$ssl_client_escaped_cert;
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
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+
# create a new document with PUT to establish initial state
19+
20+
slug="post-metadata-test-item"
21+
item="${END_USER_BASE_URL}${slug}/"
22+
23+
(
24+
curl -k -w "%{http_code}\n" -o /dev/null -s \
25+
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
26+
-X PUT \
27+
-H "Accept: application/n-triples" \
28+
-H "Content-Type: application/n-triples" \
29+
--data-binary @- \
30+
"$item" <<EOF
31+
<${item}> <http://purl.org/dc/terms/title> "POST Metadata Test Item" .
32+
<${item}> <http://example.com/initial-predicate> "initial value" .
33+
EOF
34+
) \
35+
| grep -q "$STATUS_CREATED"
36+
37+
# get initial state and verify cardinalities after PUT
38+
39+
item_ntriples=$(get.sh \
40+
-f "$AGENT_CERT_FILE" \
41+
-p "$AGENT_CERT_PWD" \
42+
--accept 'application/n-triples' \
43+
"$item"
44+
)
45+
46+
# check that exactly one dct:created exists and no dct:modified yet
47+
created_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/created> " || true)
48+
if [ "$created_count" -ne 1 ]; then
49+
echo "Expected exactly 1 dct:created property after creation, found $created_count"
50+
exit 1
51+
fi
52+
53+
modified_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/modified> " || true)
54+
if [ "$modified_count" -ne 0 ]; then
55+
echo "Expected no dct:modified property after creation, found $modified_count"
56+
exit 1
57+
fi
58+
59+
# perform first POST operation
60+
61+
(
62+
curl -k -w "%{http_code}\n" -o /dev/null -f -s \
63+
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
64+
-H "Accept: application/n-triples" \
65+
-H "Content-Type: application/n-triples" \
66+
--data-binary @- \
67+
"$item" <<EOF
68+
<${item}> <http://example.com/post-predicate-1> "first POST value" .
69+
EOF
70+
) \
71+
| grep -q "$STATUS_NO_CONTENT"
72+
73+
# get state after first POST and verify cardinalities
74+
75+
item_ntriples=$(get.sh \
76+
-f "$AGENT_CERT_FILE" \
77+
-p "$AGENT_CERT_PWD" \
78+
--accept 'application/n-triples' \
79+
"$item"
80+
)
81+
82+
# check that exactly one dct:created and one dct:modified exist
83+
created_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/created> " || true)
84+
if [ "$created_count" -ne 1 ]; then
85+
echo "Expected exactly 1 dct:created property after first POST, found $created_count"
86+
exit 1
87+
fi
88+
89+
modified_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/modified> " || true)
90+
if [ "$modified_count" -ne 1 ]; then
91+
echo "Expected exactly 1 dct:modified property after first POST, found $modified_count"
92+
exit 1
93+
fi
94+
95+
# perform second POST operation (this is the key test for accumulation bug)
96+
97+
(
98+
curl -k -w "%{http_code}\n" -o /dev/null -f -s \
99+
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
100+
-H "Accept: application/n-triples" \
101+
-H "Content-Type: application/n-triples" \
102+
--data-binary @- \
103+
"$item" <<EOF
104+
<${item}> <http://example.com/post-predicate-2> "second POST value" .
105+
EOF
106+
) \
107+
| grep -q "$STATUS_NO_CONTENT"
108+
109+
# get final state and verify cardinalities (key test for the fix)
110+
111+
item_ntriples=$(get.sh \
112+
-f "$AGENT_CERT_FILE" \
113+
-p "$AGENT_CERT_PWD" \
114+
--accept 'application/n-triples' \
115+
"$item"
116+
)
117+
118+
# check that exactly one dct:created and one dct:modified still exist
119+
created_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/created> " || true)
120+
if [ "$created_count" -ne 1 ]; then
121+
echo "Expected exactly 1 dct:created property after second POST, found $created_count"
122+
exit 1
123+
fi
124+
125+
modified_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/modified> " || true)
126+
if [ "$modified_count" -ne 1 ]; then
127+
echo "Expected exactly 1 dct:modified property after second POST, found $modified_count"
128+
echo "This indicates the fix for accumulating dct:modified values in Graph::post() is not working"
129+
exit 1
130+
fi
131+
132+
# verify that all POST content was added (ensure POST operations work correctly)
133+
echo "$item_ntriples" | grep "\"first POST value\"" > /dev/null
134+
echo "$item_ntriples" | grep "\"second POST value\"" > /dev/null

http-tests/document-hierarchy/PUT-item-metadata.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,18 @@ echo "$item_ntriples" | grep "<${item}> <http://purl.org/dc/terms/created> \""
100100

101101
echo "$item_ntriples" | grep "<${item}> <http://purl.org/dc/terms/modified> \""
102102

103+
# check that exactly one dct:created and one dct:modified exist (no accumulation)
104+
105+
created_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/created> " || true)
106+
if [ "$created_count" -ne 1 ]; then
107+
echo "Expected exactly 1 dct:created property after PUT, found $created_count"
108+
exit 1
109+
fi
110+
111+
modified_count=$(echo "$item_ntriples" | grep -c "<${item}> <http://purl.org/dc/terms/modified> " || true)
112+
if [ "$modified_count" -ne 1 ]; then
113+
echo "Expected exactly 1 dct:modified property after PUT, found $modified_count"
114+
exit 1
115+
fi
116+
103117
# write the same data again into the existing graph

http-tests/proxy/HEAD-proxied-accept.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ content_type=$(curl -G --head -k -w "%{content_type}\n" -f -s -o /dev/null \
2424
--data-urlencode "accept=text/turtle" \
2525
"$END_USER_BASE_URL")
2626

27-
[ "$content_type" = 'text/turtle' ] || exit 1
27+
[ "$content_type" = 'text/turtle;charset=UTF-8' ] || exit 1
2828

2929
# check that ?accept URL param overrides Accept header and returns RDF/XML (use Chrome's default Accept value)
3030

@@ -35,6 +35,6 @@ content_type=$(curl -G --head -k -w "%{content_type}\n" -f -s -o /dev/null \
3535
--data-urlencode "accept=application/rdf+xml" \
3636
"$END_USER_BASE_URL")
3737

38-
[ "$content_type" = 'application/rdf+xml' ] || exit 1
38+
[ "$content_type" = 'application/rdf+xml;charset=UTF-8' ] || exit 1
3939

4040
# TO-DO: try to actually parse the response as Turtle and RDF/XML?
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 - POST requests count as write operations
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+
# execute SPARQL query using LDH as a proxy to query DBpedia
19+
20+
response_body=$(curl -k -s \
21+
-X POST \
22+
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
23+
-H 'Content-Type: application/sparql-query' \
24+
-H 'Accept: application/sparql-results+xml' \
25+
--url-query "uri=https://dbpedia.org/sparql" \
26+
--data 'SELECT ?title WHERE { <https://dbpedia.org/resource/Copenhagen> <http://purl.org/dc/elements/1.1/title> ?title } LIMIT 1' \
27+
"$END_USER_BASE_URL")
28+
29+
http_code=$(curl -k -s -o /dev/null -w "%{http_code}" \
30+
-X POST \
31+
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
32+
-H 'Content-Type: application/sparql-query' \
33+
-H 'Accept: application/sparql-results+xml' \
34+
--url-query "uri=https://dbpedia.org/sparql" \
35+
--data 'SELECT ?title WHERE { <https://dbpedia.org/resource/Copenhagen> <http://purl.org/dc/elements/1.1/title> ?title } LIMIT 1' \
36+
"$END_USER_BASE_URL")
37+
38+
# verify response has non-empty body and successful status
39+
if [ "$http_code" -ne 200 ] || [ -z "$response_body" ]; then
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)