Skip to content

Commit

Permalink
Merge pull request #154 from dbpedia/dev
Browse files Browse the repository at this point in the history
fixed sparql get request failing & sparql interface bug
  • Loading branch information
holycrab13 authored Dec 20, 2023
2 parents 5ad99f0 + b6da4d9 commit 6f89524
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion public/css/_collections.scss
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
.collection-editor-tabs {
display: flex;
margin-bottom: -1px;
margin-top: 2em;
padding-top: 2em;
}

.collection-editor-info-text {
Expand Down
2 changes: 1 addition & 1 deletion public/css/website.css
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@
.collection-editor-tabs {
display: flex;
margin-bottom: -1px;
margin-top: 2em;
padding-top: 2em;
}

.collection-editor-info-text {
Expand Down
2 changes: 1 addition & 1 deletion server/app/api/routes/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function (router, protector, webdav) {

router.get('/sparql', cors(), function (req, res, next) {

var query = req.body.query;
var query = req.query.query;

if(query == undefined || query == "") {
next('route');
Expand Down
39 changes: 24 additions & 15 deletions server/app/test/methods/api/general-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,22 @@ async function publishTest() {

// ======== Publish invalid Dataid =======
delete options.body;
try{
try {
response = await rp(options);
assert(false, 'should not be possible to publish non existent metadata')
} catch(err) {
} catch (err) {
assert(err.response.statusCode == 400, 'empty metadata shoud not be publishibly.');
}

// search doesnt work
// Error: connect ECONNREFUSED 127.0.0.1:8082
// at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
// errno: -111,
// code: 'ECONNREFUSED',
// syscall: 'connect',
// address: '127.0.0.1',
// port: 8082
// }
// search doesnt work
// Error: connect ECONNREFUSED 127.0.0.1:8082
// at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1247:16) {
// errno: -111,
// code: 'ECONNREFUSED',
// syscall: 'connect',
// address: '127.0.0.1',
// port: 8082
// }
// // ========= Search Tests ===========
// // ========= Search existing Data ===========
// options.method = "GET";
Expand All @@ -117,21 +117,30 @@ async function publishTest() {
response = await rp(options);
assert(response.statusCode == 204, `Could not delete version ${options.uri}.`);

// ======== send sparql request ===========
// ======== send sparql request POST ===========
options.method = "POST";
options.uri = `${process.env.DATABUS_RESOURCE_BASE_URL}/sparql`;
options.body = { query: "select distinct * where {?a ?b ?c} LIMIT 2" }

response = await rp(options);
assert(response.statusCode == 200, 'fail')

// ======== send sparql request GET ===========
options.method = "GET";
options.uri = `${process.env.DATABUS_RESOURCE_BASE_URL}/sparql?query=select%20distinct%20%2A%20where%20%7B%3Fa%20%3Fb%20%3Fc%7D%20LIMIT%202`;

response = await rp(options);

assert(response.statusCode == 200, 'fail')

// ========= send invalid sparql request =========
options.method = "POST";
options.body = { query: "asd" }
try{

try {
await rp(options);
assert(false, 'invalid sparql query shouldnt work.')
} catch(err) {
} catch (err) {
assert(err.response.statusCode == 400, "invalid sparql query shouldnt work.")
}

Expand Down

0 comments on commit 6f89524

Please sign in to comment.