Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
2b1c01b
Attempt to handle 429 responses by respecting `Retry-After` headers
namedgraph Feb 13, 2025
dda21ee
Attempt to handle 429 responses in LinkedDataClient using RetryAfterH…
namedgraph Feb 13, 2025
2b5c628
Wrap `LinkedDataClient` methods into `RetryAfterHelper`
namedgraph Feb 14, 2025
2282556
Comment
namedgraph Feb 14, 2025
f8d503b
Comment
namedgraph Feb 14, 2025
d2f6810
Max retry count support in RetryAfterHelper
namedgraph Feb 15, 2025
904ff4b
Replaced HEAD requests with PUT If-None-Match: *
namedgraph Feb 16, 2025
39a1590
Fixed if/else condition
namedgraph Feb 16, 2025
469f300
SNAPSHOT bump
namedgraph Feb 16, 2025
e5791c6
Evaluate preconditions as soon as we have the `existingModel`
namedgraph Feb 16, 2025
bf46cc5
Comment
namedgraph Feb 16, 2025
ea4157d
Simplified pre-condition evaluation
namedgraph Feb 16, 2025
113c45d
Fixed `lastModified` NPEs
namedgraph Feb 17, 2025
94cfca9
HTTP tests for conditional `PUT` requests
namedgraph Feb 17, 2025
83d0e6f
HTTP test fixes
namedgraph Feb 17, 2025
0de1c32
Web-Client bump
namedgraph Feb 19, 2025
8ab1952
Fixed `getVariants()` call
namedgraph Feb 19, 2025
815425f
Use HTMLMediaTypePredicate
namedgraph Feb 19, 2025
ac66512
Use getInternalResponse() to evaluate the preconditions
namedgraph Feb 20, 2025
54343e1
Override getResponseBuilder
namedgraph Feb 20, 2025
42465fa
Fixed test
namedgraph Feb 20, 2025
34c1c87
New HTTP scripts for conditional requests
namedgraph Feb 20, 2025
7019d90
More HTTP tests for conditional requests
namedgraph Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions http-tests/document-hierarchy/DELETE-conditional-412.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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"

# create container

slug="test"

container=$(create-container.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
-b "$END_USER_BASE_URL" \
--title "Test" \
--slug "$slug" \
--parent "$END_USER_BASE_URL")

# add an explicit read/write authorization for the owner because add-agent-to-group.sh won't work non-existing URI

create-authorization.sh \
-b "$ADMIN_BASE_URL" \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
--label "Write base" \
--agent "$AGENT_URI" \
--to "$container" \
--read \
--write

# attempt to delete the graph using a random ETag value

(
curl -k -w "%{http_code}\n" -o /dev/null -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
-X DELETE \
-H "If-Match: \"random-etag\"" \
"$container"
) \
| grep -q "$STATUS_PRECONDITION_FAILED"
55 changes: 55 additions & 0 deletions http-tests/document-hierarchy/DELETE-conditional.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/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"

# create container

slug="test"

container=$(create-container.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
-b "$END_USER_BASE_URL" \
--title "Test" \
--slug "$slug" \
--parent "$END_USER_BASE_URL")

# add an explicit read/write authorization for the owner because add-agent-to-group.sh won't work non-existing URI

create-authorization.sh \
-b "$ADMIN_BASE_URL" \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
--label "Write base" \
--agent "$AGENT_URI" \
--to "$container" \
--read \
--write

# store the ETag value

etag_before=$(
curl -k -i -f -s -G \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
"$container" \
| grep 'ETag' \
| tr -d '\r' \
| sed -En 's/^ETag: (.*)$/\1/p')

# delete the graph only if the ETag value matches

(
curl -k -w "%{http_code}\n" -o /dev/null -f -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
-X DELETE \
-H "If-Match: ${etag_before}" \
"$container"
) \
| grep -q "$STATUS_NO_CONTENT"
25 changes: 25 additions & 0 deletions http-tests/document-hierarchy/GET-conditional-412.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/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 readers group

add-agent-to-group.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
--agent "$AGENT_URI" \
"${ADMIN_BASE_URL}acl/groups/readers/"

# attempt to read the graph using a random ETag value

curl -k -w "%{http_code}\n" -o /dev/null -s -G \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
"$END_USER_BASE_URL" \
-H "If-Match: \"random-etag\"" \
| grep -q "$STATUS_PRECONDITION_FAILED"
1 change: 0 additions & 1 deletion http-tests/document-hierarchy/HEAD-accept-lang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ content_lang=$(curl -G --head -k -f -s -o /dev/null -D - \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \
-H 'Accept-Language: es-ES,es;q=0.9,en-US;q=0.8,en;q=0.7' \
--data-urlencode "accept=text/turtle" \
"$END_USER_BASE_URL"\
| tr -d '\r' | sed -En 's/^Content-Language: (.*)$/\1/p')

Expand Down
35 changes: 35 additions & 0 deletions http-tests/document-hierarchy/POST-conditional-412.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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/"

# attempt to replace the graph with a random ETag value

(
curl -k -w "%{http_code}\n" -o /dev/null -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-X POST \
-H "Accept: application/n-triples" \
-H "Content-Type: application/n-triples" \
-H "If-Match: \"random-etag\"" \
--data-binary @- \
"$END_USER_BASE_URL" <<EOF
<${END_USER_BASE_URL}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/atomgraph/linkeddatahub/default#Root> .
<${END_USER_BASE_URL}> <http://purl.org/dc/terms/title> "Root" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/default-predicate> "named object PUT" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/another-predicate> "another named object PUT" .
EOF
) \
| grep -q "$STATUS_PRECONDITION_FAILED"
46 changes: 46 additions & 0 deletions http-tests/document-hierarchy/POST-conditional.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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/"

# store the ETag value

etag_before=$(
curl -k -i -f -s -G \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
"$END_USER_BASE_URL" \
| grep 'ETag' \
| tr -d '\r' \
| sed -En 's/^ETag: (.*)$/\1/p')

# append to the graph only if the ETag value matches

(
curl -k -w "%{http_code}\n" -o /dev/null -f -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-X POST \
-H "Accept: application/n-triples" \
-H "Content-Type: application/n-triples" \
-H "If-Match: ${etag_before}" \
--data-binary @- \
"$END_USER_BASE_URL" <<EOF
<${END_USER_BASE_URL}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/atomgraph/linkeddatahub/default#Root> .
<${END_USER_BASE_URL}> <http://purl.org/dc/terms/title> "Root" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/default-predicate> "named object PUT" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/another-predicate> "another named object PUT" .
EOF
) \
| grep -q "$STATUS_NO_CONTENT"
11 changes: 0 additions & 11 deletions http-tests/document-hierarchy/POST-ntriples-etag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ add-agent-to-group.sh \
--agent "$AGENT_URI" \
"${ADMIN_BASE_URL}acl/groups/writers/"

# create public authorization

create-authorization.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
-b "$ADMIN_BASE_URL" \
--label "Public access authorization" \
--agent-class 'http://xmlns.com/foaf/0.1/Agent' \
--to "$END_USER_BASE_URL" \
--read

etag_before=$(
curl -k -i -f -s -G \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
Expand Down
35 changes: 35 additions & 0 deletions http-tests/document-hierarchy/PUT-conditional-412.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/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/"

# attempt to replace the graph with a random ETag value

(
curl -k -w "%{http_code}\n" -o /dev/null -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-X PUT \
-H "Accept: application/n-triples" \
-H "Content-Type: application/n-triples" \
-H "If-Match: \"random-etag\"" \
--data-binary @- \
"$END_USER_BASE_URL" <<EOF
<${END_USER_BASE_URL}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/atomgraph/linkeddatahub/default#Root> .
<${END_USER_BASE_URL}> <http://purl.org/dc/terms/title> "Root" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/default-predicate> "named object PUT" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/another-predicate> "another named object PUT" .
EOF
) \
| grep -q "$STATUS_PRECONDITION_FAILED"
46 changes: 46 additions & 0 deletions http-tests/document-hierarchy/PUT-conditional.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/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/"

# store the ETag value

etag_before=$(
curl -k -i -f -s -G \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-H "Accept: application/n-triples" \
"$END_USER_BASE_URL" \
| grep 'ETag' \
| tr -d '\r' \
| sed -En 's/^ETag: (.*)$/\1/p')

# replace the graph only if the ETag value matches

(
curl -k -w "%{http_code}\n" -o /dev/null -f -s \
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
-X PUT \
-H "Accept: application/n-triples" \
-H "Content-Type: application/n-triples" \
-H "If-Match: ${etag_before}" \
--data-binary @- \
"$END_USER_BASE_URL" <<EOF
<${END_USER_BASE_URL}> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/atomgraph/linkeddatahub/default#Root> .
<${END_USER_BASE_URL}> <http://purl.org/dc/terms/title> "Root" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/default-predicate> "named object PUT" .
<${END_USER_BASE_URL}named-subject-put> <http://example.com/another-predicate> "another named object PUT" .
EOF
) \
| grep -q "$STATUS_OK"
11 changes: 0 additions & 11 deletions http-tests/document-hierarchy/PUT-ntriples-etag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,6 @@ add-agent-to-group.sh \
--agent "$AGENT_URI" \
"${ADMIN_BASE_URL}acl/groups/writers/"

# create public authorization

create-authorization.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
-b "$ADMIN_BASE_URL" \
--label "Public access authorization" \
--agent-class 'http://xmlns.com/foaf/0.1/Agent' \
--to "$END_USER_BASE_URL" \
--read

# store the ETag value

etag_before=$(
Expand Down
4 changes: 2 additions & 2 deletions http-tests/proxy/HEAD-proxied-accept.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ purge_cache "$END_USER_VARNISH_SERVICE"
purge_cache "$ADMIN_VARNISH_SERVICE"
purge_cache "$FRONTEND_VARNISH_SERVICE"

# add agent to the writers group to be able to read/write documents
# add agent to the readers group to be able to read documents

add-agent-to-group.sh \
-f "$OWNER_CERT_FILE" \
-p "$OWNER_CERT_PWD" \
--agent "$AGENT_URI" \
"${ADMIN_BASE_URL}acl/groups/writers/"
"${ADMIN_BASE_URL}acl/groups/readers/"

# check that ?accept URL param overrides Accept header and returns Turtle (use Chrome's default Accept value)

Expand Down
1 change: 1 addition & 0 deletions http-tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export STATUS_FORBIDDEN=403
export STATUS_NOT_FOUND=404
export STATUS_METHOD_NOT_ALLOWED=405
export STATUS_NOT_ACCEPTABLE=406
export STATUS_PRECONDITION_FAILED=412
export STATUS_REQUEST_ENTITY_TOO_LARGE=413
export STATUS_UNSUPPORTED_MEDIA=415
export STATUS_UNPROCESSABLE_ENTITY=422
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>com.atomgraph</groupId>
<artifactId>linkeddatahub</artifactId>
<version>5.0.8-SNAPSHOT</version>
<version>5.0.9-SNAPSHOT</version>
<packaging>${packaging.type}</packaging>

<name>AtomGraph LinkedDataHub</name>
Expand Down Expand Up @@ -135,18 +135,18 @@
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>server</artifactId>
<version>4.1.10-SNAPSHOT</version>
<version>4.1.11-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>client</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
<classifier>classes</classifier>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>client</artifactId>
<version>4.2.0-SNAPSHOT</version>
<version>4.2.1-SNAPSHOT</version>
<type>war</type>
</dependency>
<!-- required by jsonld-java - version same as Jersey's HTTP Client -->
Expand Down
Loading