Skip to content

Commit 21f2bbb

Browse files
committed
New HTTP test for the Add endpoint
1 parent c63626c commit 21f2bbb

File tree

7 files changed

+66
-24
lines changed

7 files changed

+66
-24
lines changed

http-tests/access/POST-request-access.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ initialize_dataset "$ADMIN_BASE_URL" "$TMP_ADMIN_DATASET" "$ADMIN_ENDPOINT_URL"
66
purge_cache "$END_USER_VARNISH_SERVICE"
77
purge_cache "$ADMIN_VARNISH_SERVICE"
88

9+
# submit requested authorization for the agent
10+
911
curl -w "%{http_code}\n" -o /dev/null -k -s \
1012
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
1113
-H "Accept: text/turtle" \

http-tests/add/POST-add.sh

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+
9+
# add agent to the writers group
10+
11+
add-agent-to-group.sh \
12+
-f "$OWNER_CERT_FILE" \
13+
-p "$OWNER_CERT_PWD" \
14+
--agent "$AGENT_URI" \
15+
"${ADMIN_BASE_URL}acl/groups/writers/"
16+
17+
# create container
18+
19+
slug="test"
20+
21+
container=$(create-container.sh \
22+
-f "$AGENT_CERT_FILE" \
23+
-p "$AGENT_CERT_PWD" \
24+
-b "$END_USER_BASE_URL" \
25+
--title "Test" \
26+
--slug "$slug" \
27+
--parent "$END_USER_BASE_URL")
28+
29+
# import data into the container
30+
31+
curl -w "%{http_code}\n" -o /dev/null -k -s \
32+
-E "$AGENT_CERT_FILE":"$AGENT_CERT_PWD" \
33+
-H "Content-Type: application/x-www-form-urlencoded" \
34+
--data-urlencode "rdf=" \
35+
--data-urlencode "sb=clone" \
36+
--data-urlencode "pu=http://purl.org/dc/terms/source" \
37+
--data-urlencode "ou=https://orcid.org/0000-0003-1750-9906" \
38+
--data-urlencode "pu=http://www.w3.org/ns/sparql-service-description#name" \
39+
--data-urlencode "ou=${container}" \
40+
"${END_USER_BASE_URL}add" \
41+
| grep -q "$STATUS_NO_CONTENT"

http-tests/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ download_dataset "$ADMIN_ENDPOINT_URL" > "$TMP_ADMIN_DATASET"
137137

138138
### Other tests ###
139139

140+
run_tests $(find ./add/ -type f -name '*.sh')
141+
(( error_count += $? ))
140142
run_tests $(find ./admin/ -type f -name '*.sh')
141143
(( error_count += $? ))
142144
run_tests $(find ./access/ -type f -name '*.sh')

platform/datasets/admin.trig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ WHERE
756756
rdfs:label "Full control" ;
757757
rdfs:comment "Allows full read/write access to all application resources" ;
758758
acl:accessToClass dh:Item, dh:Container, def:Root ;
759-
acl:accessTo <../sparql>, <../importer>, <../generate>, <../ns>, <clear>, <transform> ;
759+
acl:accessTo <../sparql>, <../importer>, <../add>, <../generate>, <../ns>, <clear>, <transform> ;
760760
acl:mode acl:Read, acl:Append, acl:Write, acl:Control ;
761761
acl:agentGroup <acl/groups/owners/#this> .
762762

@@ -776,7 +776,7 @@ WHERE
776776
rdfs:label "Write/append access" ;
777777
rdfs:comment "Allows write access to all documents and containers" ;
778778
acl:accessToClass dh:Item, dh:Container, def:Root ;
779-
acl:accessTo <../sparql>, <../importer>, <../generate>, <../ns> ;
779+
acl:accessTo <../sparql>, <../importer>, <../add>, <../generate>, <../ns> ;
780780
acl:mode acl:Write, acl:Append ;
781781
acl:agentGroup <acl/groups/owners/#this>, <acl/groups/writers/#this> .
782782

platform/datasets/end-user.trig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444

4545
}
4646

47+
<add>
48+
{
49+
50+
<add> a foaf:Document ;
51+
dct:title "Add data endpoint" .
52+
53+
}
54+
4755
<access>
4856
{
4957

src/main/java/com/atomgraph/linkeddatahub/resource/Add.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
*
6565
* @author {@literal Martynas Jusevičius <martynas@atomgraph.com>}
6666
*/
67-
@Deprecated
6867
public class Add extends GraphStoreImpl // TO-DO: does not need to extend GraphStore is the multipart/form-data is not RDF/POST. Replace with ProxyResourceBase?
6968
{
7069

src/main/java/com/atomgraph/linkeddatahub/server/model/impl/Dispatcher.java

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.atomgraph.client.vocabulary.AC;
2020
import com.atomgraph.linkeddatahub.apps.model.Dataset;
21+
import com.atomgraph.linkeddatahub.resource.Add;
2122
import com.atomgraph.linkeddatahub.resource.Generate;
2223
import com.atomgraph.linkeddatahub.resource.Namespace;
2324
import com.atomgraph.linkeddatahub.resource.Transform;
@@ -167,17 +168,6 @@ public Class getAccessRequest()
167168
{
168169
return getProxyClass().orElse(AccessRequest.class);
169170
}
170-
171-
// /**
172-
// * Returns the ACL access request endpoint.
173-
// *
174-
// * @return endpoint resource
175-
// */
176-
// @Path("request access")
177-
// public Class getRequestAccess()
178-
// {
179-
// return getProxyClass().orElse(RequestAccess.class);
180-
// }
181171

182172
/**
183173
* Returns content-addressed file item resource.
@@ -191,16 +181,16 @@ public Class getFileItem()
191181
return getProxyClass().orElse(com.atomgraph.linkeddatahub.resource.upload.sha1.Item.class);
192182
}
193183

194-
// /**
195-
// * Returns the endpoint for synchronous RDF imports.
196-
// *
197-
// * @return endpoint resource
198-
// */
199-
// @Path("add")
200-
// public Class getAddEndpoint()
201-
// {
202-
// return getProxyClass().orElse(Add.class);
203-
// }
184+
/**
185+
* Returns the endpoint for synchronous RDF imports.
186+
*
187+
* @return endpoint resource
188+
*/
189+
@Path("add")
190+
public Class getAddEndpoint()
191+
{
192+
return getProxyClass().orElse(Add.class);
193+
}
204194

205195
/**
206196
* Returns the endpoint for synchronous RDF imports with a <code>CONSTRUCT</code> query transformation.

0 commit comments

Comments
 (0)