diff --git a/CHANGELOG b/CHANGELOG index 5449a426af..07b91f4673 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ v3.5.2 (XXXX-XX-XX) ------------------- +* The General Graph document API is now persistent with the document API in its + errormessages. When attempting to create / modify edges pointing to non + existing vertex collections HTTP 400 is returned instead of 404. + * Disallow the usage of subqueries inside AQL traversal PRUNE conditions. Using subqueries inside PRUNE conditions causes undefined behavior, so such queries will now be aborted early on with a parse error diff --git a/arangod/RestHandler/RestGraphHandler.cpp b/arangod/RestHandler/RestGraphHandler.cpp index b65e092272..3be167b3e4 100644 --- a/arangod/RestHandler/RestGraphHandler.cpp +++ b/arangod/RestHandler/RestGraphHandler.cpp @@ -47,13 +47,25 @@ RestGraphHandler::RestGraphHandler(GeneralRequest* request, GeneralResponse* res RestStatus RestGraphHandler::execute() { Result res = executeGharial(); if (res.fail()) { - generateError(res); + TRI_ASSERT(!_response->isResponseEmpty()); return RestStatus::FAIL; } // The url is required to properly generate the result! return RestStatus::DONE; } +Result RestGraphHandler::returnError(int errorNumber) { + auto res = Result(errorNumber); + generateError(res); + return res; +} + +Result RestGraphHandler::returnError(int errorNumber, char const* message) { + auto res = Result(errorNumber, message); + generateError(res); + return res; +} + Result RestGraphHandler::executeGharial() { auto suffix = request()->suffixes().begin(); auto end = request()->suffixes().end(); @@ -86,7 +98,7 @@ Result RestGraphHandler::executeGharial() { const char* vertex = "vertex"; const char* edge = "edge"; if (collType != vertex && collType != edge) { - return {TRI_ERROR_HTTP_NOT_FOUND}; + return returnError(TRI_ERROR_HTTP_NOT_FOUND); } if (noMoreSuffixes()) { @@ -152,7 +164,7 @@ Result RestGraphHandler::executeGharial() { } } - return {TRI_ERROR_HTTP_NOT_FOUND}; + return returnError(TRI_ERROR_HTTP_NOT_FOUND); } Result RestGraphHandler::graphAction(Graph& graph) { @@ -163,7 +175,7 @@ Result RestGraphHandler::graphAction(Graph& graph) { return graphActionRemoveGraph(graph); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::graphsAction() { @@ -174,7 +186,7 @@ Result RestGraphHandler::graphsAction() { return graphActionCreateGraph(); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::vertexSetsAction(Graph& graph) { @@ -185,7 +197,7 @@ Result RestGraphHandler::vertexSetsAction(Graph& graph) { return modifyVertexDefinition(graph, VertexDefinitionAction::CREATE, ""); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::edgeSetsAction(Graph& graph) { @@ -196,7 +208,7 @@ Result RestGraphHandler::edgeSetsAction(Graph& graph) { return createEdgeDefinition(graph); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::edgeSetAction(Graph& graph, const std::string& edgeDefinitionName) { @@ -209,7 +221,7 @@ Result RestGraphHandler::edgeSetAction(Graph& graph, const std::string& edgeDefi return removeEdgeDefinition(graph, edgeDefinitionName); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::vertexSetAction(Graph& graph, const std::string& vertexCollectionName) { @@ -220,7 +232,7 @@ Result RestGraphHandler::vertexSetAction(Graph& graph, const std::string& vertex return modifyVertexDefinition(graph, VertexDefinitionAction::REMOVE, vertexCollectionName); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::vertexAction(Graph& graph, const std::string& vertexCollectionName, @@ -238,7 +250,7 @@ Result RestGraphHandler::vertexAction(Graph& graph, const std::string& vertexCol return vertexActionRemove(graph, vertexCollectionName, vertexKey); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } Result RestGraphHandler::edgeAction(Graph& graph, const std::string& edgeDefinitionName, @@ -255,7 +267,7 @@ Result RestGraphHandler::edgeAction(Graph& graph, const std::string& edgeDefinit return edgeActionReplace(graph, edgeDefinitionName, edgeKey); default:; } - return {TRI_ERROR_HTTP_METHOD_NOT_ALLOWED}; + return returnError(TRI_ERROR_HTTP_METHOD_NOT_ALLOWED); } void RestGraphHandler::vertexActionRead(Graph& graph, std::string const& collectionName, @@ -713,7 +725,7 @@ Result RestGraphHandler::modifyVertexDefinition(graph::Graph& graph, bool parseSuccess = false; VPackSlice body = this->parseVPackBody(parseSuccess); if (!parseSuccess) { - return {TRI_ERROR_BAD_PARAMETER, "unable to parse body"}; + return returnError(TRI_ERROR_BAD_PARAMETER, "unable to parse body"); } // TODO maybe merge this function with modifyEdgeDefinition? @@ -751,7 +763,6 @@ Result RestGraphHandler::modifyVertexDefinition(graph::Graph& graph, return Result(); } - Result RestGraphHandler::removeEdgeDefinition(graph::Graph& graph, const std::string& edgeDefinitionName) { return modifyEdgeDefinition(graph, EdgeDefinitionAction::REMOVE, edgeDefinitionName); @@ -769,7 +780,7 @@ Result RestGraphHandler::documentModify(graph::Graph& graph, const std::string& bool parseSuccess = false; VPackSlice body = this->parseVPackBody(parseSuccess); if (!parseSuccess) { - return {TRI_ERROR_BAD_PARAMETER, "unable to parse body"}; + return returnError(TRI_ERROR_BAD_PARAMETER, "unable to parse body"); } bool waitForSync = _request->parsedValue(StaticStrings::WaitForSyncString, false); @@ -830,7 +841,7 @@ Result RestGraphHandler::documentCreate(graph::Graph& graph, std::string const& bool parseSuccess = false; VPackSlice body = this->parseVPackBody(parseSuccess); if (!parseSuccess) { - return {TRI_ERROR_BAD_PARAMETER, "unable to parse body"}; + return returnError(TRI_ERROR_BAD_PARAMETER, "unable to parse body"); } bool waitForSync = _request->parsedValue(StaticStrings::WaitForSyncString, false); @@ -927,7 +938,7 @@ Result RestGraphHandler::graphActionCreateGraph() { bool parseSuccess = false; VPackSlice body = this->parseVPackBody(parseSuccess); if (!parseSuccess) { - return {TRI_ERROR_BAD_PARAMETER, "unable to parse body"}; + return returnError(TRI_ERROR_BAD_PARAMETER, "unable to parse body"); } bool waitForSync = _request->parsedValue(StaticStrings::WaitForSyncString, false); diff --git a/arangod/RestHandler/RestGraphHandler.h b/arangod/RestHandler/RestGraphHandler.h index 1e5344d363..ec0d0227a9 100644 --- a/arangod/RestHandler/RestGraphHandler.h +++ b/arangod/RestHandler/RestGraphHandler.h @@ -55,6 +55,11 @@ class RestGraphHandler : public arangodb::RestVocbaseBaseHandler { RequestLane lane() const override; private: + + Result returnError(int errorNumber); + + Result returnError(int errorNumber, char const* message); + arangodb::Result executeGharial(); // /_api/gharial diff --git a/lib/Rest/GeneralResponse.h b/lib/Rest/GeneralResponse.h index 2b16fed07d..708440929a 100644 --- a/lib/Rest/GeneralResponse.h +++ b/lib/Rest/GeneralResponse.h @@ -135,6 +135,8 @@ class GeneralResponse { _headers.emplace(key, value); } + virtual bool isResponseEmpty() const {return false;}; + public: virtual uint64_t messageId() const { return 1; } @@ -146,6 +148,7 @@ class GeneralResponse { void setPayload(Payload&& payload, bool generateBody, VPackOptions const& options = VPackOptions::Options::Defaults, bool resolveExternals = true) { + TRI_ASSERT(isResponseEmpty()); _generateBody = generateBody; addPayload(std::forward(payload), &options, resolveExternals); } diff --git a/lib/Rest/HttpResponse.h b/lib/Rest/HttpResponse.h index fa6538868d..7b157e9dd5 100644 --- a/lib/Rest/HttpResponse.h +++ b/lib/Rest/HttpResponse.h @@ -83,6 +83,10 @@ class HttpResponse : public GeneralResponse { void addPayload(VPackBuffer&&, arangodb::velocypack::Options const* = nullptr, bool resolve_externals = true) override; + bool isResponseEmpty() const override { + return _body->empty(); + } + /// used for head-responses bool setGenerateBody(bool generateBody) override final { return _generateBody = generateBody; diff --git a/lib/Rest/VstResponse.h b/lib/Rest/VstResponse.h index 64d74352cb..63c16f4b10 100644 --- a/lib/Rest/VstResponse.h +++ b/lib/Rest/VstResponse.h @@ -47,6 +47,10 @@ class VstResponse : public GeneralResponse { VstResponse(ResponseCode code, uint64_t id); + bool isResponseEmpty() const override { + return _vpackPayloads.empty(); + } + // required by base uint64_t messageId() const override { return _messageId; } virtual arangodb::Endpoint::TransportType transportType() override { diff --git a/tests/IResearch/RestHandlerMock.h b/tests/IResearch/RestHandlerMock.h index ef180e5f9f..22cfd65b8e 100644 --- a/tests/IResearch/RestHandlerMock.h +++ b/tests/IResearch/RestHandlerMock.h @@ -49,6 +49,9 @@ struct GeneralRequestMock: public arangodb::GeneralRequest { struct GeneralResponseMock: public arangodb::GeneralResponse { arangodb::velocypack::Builder _payload; + virtual bool isResponseEmpty() const override { + return _payload.isEmpty(); + } GeneralResponseMock(arangodb::ResponseCode code = arangodb::ResponseCode::OK); virtual void addPayload(arangodb::velocypack::Buffer&& buffer, arangodb::velocypack::Options const* options = nullptr, bool resolveExternals = true) override; diff --git a/tests/js/client/http/api-gharial-spec.js b/tests/js/client/http/api-gharial-spec.js index a279057d9d..3d1b95e6ac 100644 --- a/tests/js/client/http/api-gharial-spec.js +++ b/tests/js/client/http/api-gharial-spec.js @@ -32,7 +32,7 @@ chai.Assertion.addProperty('does', function () { }); const arangodb = require('@arangodb'); -const request = require('@arangodb/request'); +const arango = arangodb.arango; const ERRORS = arangodb.errors; const db = arangodb.db; @@ -105,16 +105,14 @@ describe('_api/gharial', () => { }; expect(db._collection(eColName)).to.be.null; expect(db._collection(vColName)).to.be.null; - let req = request.post(url, { - body: JSON.stringify(graphDef) - }); - expect(req.statusCode).to.equal(202); + let req = arango.POST(url, graphDef); + expect(req.code).to.equal(202); // This is all async give it some time do { wait(0.1); - req = request.get(url + "/" + graphName); - } while (req.statusCode !== 200); + req = arango.GET(url + "/" + graphName); + } while (req.code !== 200); expect(db._collection(eColName)).to.not.be.null; expect(db._collection(vColName)).to.not.be.null; @@ -139,16 +137,14 @@ describe('_api/gharial', () => { expect(db._collection(vColName)).to.be.null; expect(db._collection(oColName)).to.be.null; expect(db._collection(oColName2)).to.be.null; - let req = request.post(url, { - body: JSON.stringify(graphDef) - }); - expect(req.statusCode).to.equal(202); + let req = arango.POST(url, graphDef); + expect(req.code).to.equal(202); // This is all async give it some time do { wait(0.1); - req = request.get(url + "/" + graphName); - } while (req.statusCode !== 200); + req = arango.GET(url + "/" + graphName); + } while (req.code !== 200); expect(db._collection(eColName)).to.not.be.null; expect(db._collection(vColName)).to.not.be.null; @@ -175,10 +171,8 @@ describe('_api/gharial', () => { _from: 'persons/bob', _to: 'persons/charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(202); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef ); + expect(req.code).to.equal(202); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -196,11 +190,9 @@ describe('_api/gharial', () => { _from: 'persons/notavailable', _to: 'persons/charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -216,11 +208,9 @@ describe('_api/gharial', () => { _from: 'persons/bob', _to: 'persons/notavailable' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -236,11 +226,9 @@ describe('_api/gharial', () => { _from: 'persons/notavailable', _to: 'persons/notavailable' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -260,11 +248,9 @@ describe('_api/gharial', () => { _from: 'xxx/peter', _to: 'persons/charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -282,11 +268,9 @@ describe('_api/gharial', () => { }; // get a (any) valid key of an existing edge document - let req = request.post(url + '/' + exampleGraphName + '/edge/knows/', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows/', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -304,11 +288,9 @@ describe('_api/gharial', () => { }; // get a (any) valid key of an existing edge document - let req = request.post(url + '/' + exampleGraphName + '/edge/knows/', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows/', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -326,11 +308,9 @@ describe('_api/gharial', () => { }; // get a (any) valid key of an existing edge document - let req = request.post(url + '/' + exampleGraphName + '/edge/knows/', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows/', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -346,11 +326,9 @@ describe('_api/gharial', () => { _from: 'persons/bob', _to: 'xxx/charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -366,11 +344,9 @@ describe('_api/gharial', () => { _from: 'xxx/peter', _to: 'xxx/charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -386,11 +362,9 @@ describe('_api/gharial', () => { _from: 'peter', _to: 'persons/charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -406,11 +380,9 @@ describe('_api/gharial', () => { _from: 'persons/peter', _to: 'charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -426,11 +398,9 @@ describe('_api/gharial', () => { _from: 'peter', _to: 'charlie' }; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -447,11 +417,9 @@ describe('_api/gharial', () => { expect(g).to.not.be.null; const edgeDef = {}; - let req = request.post(url + '/' + exampleGraphName + '/edge/knows', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.POST(url + '/' + exampleGraphName + '/edge/knows', edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -473,14 +441,11 @@ describe('_api/gharial', () => { edgeDef._from = 'persons/charlie'; edgeDef._to = 'persons/charlie'; - let res = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + edgeDef._key, { - body: JSON.stringify(edgeDef) - }); + let res = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + edgeDef._key, edgeDef); // 202 without waitForSync (default) - expect(res.statusCode).to.equal(202); - expect(res.json.code).to.equal(202); - expect(res.json.error).to.equal(false); - expect(res.json.edge._key).to.equal(edgeDef._key); + expect(res.code).to.equal(202); + expect(res.error).to.equal(false); + expect(res.edge._key).to.equal(edgeDef._key); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -501,11 +466,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -524,11 +487,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -547,11 +508,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -570,11 +529,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -593,11 +550,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -616,11 +571,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -639,11 +592,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -662,11 +613,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -694,16 +643,13 @@ describe('_api/gharial', () => { const newEdge = Object.assign({}, e); newEdge.newAttribute = 'new value'; - const res = request.put( - `${url}/${exampleGraphName}/edge/${eName}/${e._key}`, - {body: JSON.stringify(newEdge)} - ); + const res = arango.PUT( + `${url}/${exampleGraphName}/edge/${eName}/${e._key}`, newEdge); // 202 without waitForSync (default) - expect(res.statusCode).to.equal(202); - expect(res.json.code).to.equal(202); - expect(res.json.error).to.equal(false); - expect(res.json.edge._key).to.equal(e._key); + expect(res.code).to.equal(202); + expect(res.error).to.equal(false); + expect(res.edge._key).to.equal(e._key); expect(db.knows.document(e._key)) .to.be.an('object') @@ -743,13 +689,12 @@ describe('_api/gharial', () => { const description = key; const newEdge = newEdges[key]; - const res = request.put( + const res = arango.PUT( `${url}/${exampleGraphName}/edge/${eName}/${e._key}`, - {body: JSON.stringify(newEdge)} - ); + newEdge); - expect(res.statusCode, description).to.equal(400); - expect(res.json.errorNum, description) + expect(res.code, description).to.equal(400); + expect(res.errorNum, description) .to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); } @@ -771,11 +716,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -794,11 +737,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -817,11 +758,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -840,11 +779,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -863,11 +800,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -886,11 +821,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -909,11 +842,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.patch(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(400); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); + let req = arango.PATCH(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(400); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_INVALID_EDGE_ATTRIBUTE.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -932,11 +863,9 @@ describe('_api/gharial', () => { // get a (any) valid key of an existing edge document const _key = db.knows.any()._key; - let req = request.put(url + '/' + exampleGraphName + '/edge/knows/' + _key, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(404); - expect(req.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); + let req = arango.PUT(url + '/' + exampleGraphName + '/edge/knows/' + _key, edgeDef); + expect(req.code).to.equal(404); + expect(req.errorNum).to.equal(ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code); expect(db._collection(eName)).to.not.be.null; expect(db._collection(vName)).to.not.be.null; @@ -964,16 +893,13 @@ describe('_api/gharial', () => { expect(db[eName].all().toArray().length).to.equal(5); // delete vertex bob - const res = request.delete( + const res = arango.DELETE( `${url}/${exampleGraphName}/vertex/${vName}/${bob}` ); // check response - expect(res).to.be.an.instanceof(request.Response); - expect(res.body).to.be.a('string'); - const body = JSON.parse(res.body); // 202 without waitForSync (default) - expect(body).to.eql({ + expect(res).to.eql({ error: false, code: 202, removed: true @@ -1031,16 +957,13 @@ describe('_api/gharial', () => { expect(db[eName].all().toArray().length).to.equal(5); // delete vertex bob - const res = request.delete( + const res = arango.DELETE( `${url}/${exampleGraphName}/vertex/${vName}/${bob}` ); // check response - expect(res).to.be.an.instanceof(request.Response); - expect(res.body).to.be.a('string'); - const body = JSON.parse(res.body); // 202 without waitForSync (default) - expect(body).to.eql({ + expect(res).to.eql({ error: false, code: 202, removed: true @@ -1094,18 +1017,14 @@ describe('_api/gharial', () => { }; // create the actual edge pointing from bob to alice - let reqB = request.post(url + '/' + exampleGraphName + '/edge/' + eName_2, { - body: JSON.stringify(edgeDefBToA) - }); - expect(reqB.statusCode).to.equal(202); - let bobToAlice = reqB.json.edge; + let reqB = arango.POST(url + '/' + exampleGraphName + '/edge/' + eName_2, edgeDefBToA); + expect(reqB.code).to.equal(202); + let bobToAlice = reqB.edge; // create the actual edge pointing from alice to bob - let reqA = request.post(url + '/' + exampleGraphName + '/edge/' + eName_2, { - body: JSON.stringify(edgeDefAToB) - }); - expect(reqA.statusCode).to.equal(202); - let aliceToBob = reqA.json.edge; + let reqA = arango.POST(url + '/' + exampleGraphName + '/edge/' + eName_2, edgeDefAToB); + expect(reqA.code).to.equal(202); + let aliceToBob = reqA.edge; // now create a new edge between the edges from A->B and B->A @@ -1114,12 +1033,10 @@ describe('_api/gharial', () => { _to: bobToAlice._id }; - let reqx = request.post(url + '/' + exampleGraphName + '/edge/' + eName_2, { - body: JSON.stringify(edgeLinkDef) - }); + let reqx = arango.POST(url + '/' + exampleGraphName + '/edge/' + eName_2, edgeLinkDef); - let newEdge = reqx.json.edge; - expect(reqx.statusCode).to.equal(202); + let newEdge = reqx.edge; + expect(reqx.code).to.equal(202); const updateEdgeLinkDef = { _to: aliceToBob._id, @@ -1127,23 +1044,19 @@ describe('_api/gharial', () => { }; // UPDATE that edge - reqx = request.patch(url + '/' + exampleGraphName + '/edge/' + eName_2 + "/" + newEdge._key, { - body: JSON.stringify(updateEdgeLinkDef) - }); - newEdge = reqx.json.edge; - expect(reqx.statusCode).to.equal(202); + reqx = arango.PATCH(url + '/' + exampleGraphName + '/edge/' + eName_2 + "/" + newEdge._key, updateEdgeLinkDef); + newEdge = reqx.edge; + expect(reqx.code).to.equal(202); // REPLACE that edge - reqx = request.put(url + '/' + exampleGraphName + '/edge/' + eName_2 + "/" + newEdge._key, { - body: JSON.stringify(edgeLinkDef) - }); - newEdge = reqx.json.edge; - expect(reqx.statusCode).to.equal(202); + reqx = arango.PUT(url + '/' + exampleGraphName + '/edge/' + eName_2 + "/" + newEdge._key, edgeLinkDef); + newEdge = reqx.edge; + expect(reqx.code).to.equal(202); // DELETE that edge - reqx = request.delete(url + '/' + exampleGraphName + '/edge/' + eName_2 + "/" + newEdge._key, { + reqx = arango.DELETE(url + '/' + exampleGraphName + '/edge/' + eName_2 + "/" + newEdge._key, { }); - expect(reqx.statusCode).to.equal(202); + expect(reqx.code).to.equal(202); }); }); @@ -1178,11 +1091,9 @@ describe('_api/gharial', () => { }; // create the actual edge pointing from bob to alice - let req = request.post(url + '/' + exampleGraphName + '/edge/' + eName, { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(202); - let bobToAlice = req.json.edge; + let req = arango.POST(url + '/' + exampleGraphName + '/edge/' + eName, edgeDef); + expect(req.code).to.equal(202); + let bobToAlice = req.edge; // now create a new edge between the edges from A->B and B->A const edgeLinkDef = { @@ -1190,12 +1101,10 @@ describe('_api/gharial', () => { _to: bobToAlice._id }; - let reqx = request.post(url + '/' + exampleGraphName + '/edge/' + eName, { - body: JSON.stringify(edgeLinkDef) - }); - expect(reqx.statusCode).to.equal(404); - expect(reqx.json.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); - expect(reqx.json.error).to.equal(true); + let reqx = arango.POST(url + '/' + exampleGraphName + '/edge/' + eName, edgeLinkDef); + expect(reqx.code).to.equal(404); + expect(reqx.errorNum).to.equal(ERRORS.ERROR_ARANGO_DATA_SOURCE_NOT_FOUND.code); + expect(reqx.error).to.equal(true); }); }); }); @@ -1217,13 +1126,13 @@ describe('_api/gharial', () => { const doc = db[vName].document(key); const revision = doc._rev; // get a valid revision - let req = request.get(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { + let req = arango.GET(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { headers: { 'if-match': revision } }); - expect(req.statusCode).to.equal(200); - expect(req.json.edge).to.deep.equal(doc); + expect(req.code).to.equal(200); + expect(req.edge).to.deep.equal(doc); }); it('should check if the if-match header is working - negative', () => { @@ -1246,15 +1155,12 @@ describe('_api/gharial', () => { const revisions = [null, undefined, true, false, revision]; revisions.forEach(function (rev) { - let req = request.get(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { - headers: { + let req = arango.GET(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { 'if-match': rev - } }); - expect(req.json.error).to.equal(true); - expect(req.statusCode).to.equal(ERRORS.ERROR_HTTP_PRECONDITION_FAILED.code); - expect(req.json.code).to.equal(ERRORS.ERROR_HTTP_PRECONDITION_FAILED.code); - expect(req.json.errorMessage).to.equal(ERRORS.ERROR_HTTP_PRECONDITION_FAILED.message); + expect(req.error).to.equal(true); + expect(req.code).to.equal(ERRORS.ERROR_HTTP_PRECONDITION_FAILED.code); + expect(req.errorMessage).to.equal(ERRORS.ERROR_HTTP_PRECONDITION_FAILED.message); }); }); @@ -1274,13 +1180,10 @@ describe('_api/gharial', () => { const doc = db[vName].document(key); const revision = doc._rev; // get a valid revision - let req = request.get(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { - headers: { + let req = arango.GET(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { 'if-none-match': revision - } }); - expect(req.status).to.equal(304); - expect(req.json).to.equal(undefined); + expect(req.code).to.equal(304); }); it('should check if the if-none-match header is working - negative', () => { @@ -1303,13 +1206,11 @@ describe('_api/gharial', () => { const revisions = [null, undefined, true, false, revision]; revisions.forEach(function (rev) { - let req = request.get(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { - headers: { + let req = arango.GET(url + '/' + exampleGraphName + '/edge/' + vName + '/' + key, { 'if-none-match': rev - } }); - expect(req.statusCode).to.equal(200); - expect(req.json.edge).to.deep.equal(doc); + expect(req.code).to.equal(200); + expect(req.edge).to.deep.equal(doc); }); }); }); @@ -1367,15 +1268,13 @@ describe('_api/gharial', () => { }; // create edge pointing from g2 to g1 (edge) - let req = request.post(url + '/' + 'secondGraph' + '/edge/secondEdge', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(202); - let toBeRemovedEdgeID = req.json.edge._id; + let req = arango.POST(url + '/' + 'secondGraph' + '/edge/secondEdge', edgeDef); + expect(req.code).to.equal(202); + let toBeRemovedEdgeID = req.edge._id; // now delete the target edge of g1 - let req2 = request.delete(url + '/' + 'firstGraph' + '/edge/' + edgeID1); - expect(req2.statusCode).to.equal(202); + let req2 = arango.DELETE(url + '/' + 'firstGraph' + '/edge/' + edgeID1); + expect(req2.code).to.equal(202); var deleted = false; try { @@ -1423,15 +1322,13 @@ describe('_api/gharial', () => { }; // create edge pointing from g2 to g1 (edge) - let req = request.post(url + '/' + 'secondGraph' + '/edge/secondEdge', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(202); - let toBeRemovedEdgeID = req.json.edge._id; + let req = arango.POST(url + '/' + 'secondGraph' + '/edge/secondEdge', edgeDef); + expect(req.code).to.equal(202); + let toBeRemovedEdgeID = req.edge._id; // now delete the target edge of g1 (a vertex) - let req2 = request.delete(url + '/' + 'firstGraph' + '/vertex/' + vertexIDTo1); - expect(req2.statusCode).to.equal(202); + let req2 = arango.DELETE(url + '/' + 'firstGraph' + '/vertex/' + vertexIDTo1); + expect(req2.code).to.equal(202); var deleted = false; try { @@ -1459,13 +1356,11 @@ describe('_api/gharial', () => { to: [to] }; var createAndDropEdgeDefinition = function () { - let req = request.post(url + '/' + gName + '/edge', { - body: JSON.stringify(edgeDef) - }); - expect(req.statusCode).to.equal(202); + let req = arango.POST(url + '/' + gName + '/edge', edgeDef); + expect(req.code).to.equal(202); // now delete the created edge definition - let req2 = request.delete(url + '/' + gName + '/edge/' + collection + '?dropCollections=true'); - expect(req2.statusCode).to.equal(202); + let req2 = arango.DELETE(url + '/' + gName + '/edge/' + collection + '?dropCollections=true'); + expect(req2.code).to.equal(202); }; createAndDropEdgeDefinition(); createAndDropEdgeDefinition(); diff --git a/tests/rb/HttpInterface/api-general-graph-spec.rb b/tests/rb/HttpInterface/api-general-graph-spec.rb index f4f49cc6f0..c94c7eff32 100644 --- a/tests/rb/HttpInterface/api-general-graph-spec.rb +++ b/tests/rb/HttpInterface/api-general-graph-spec.rb @@ -1298,6 +1298,14 @@ describe ArangoDB do doc.parsed_response['errorMessage'].should include("collection or view not found") end + def check400Collection (doc) + doc.code.should eq(400) + doc.parsed_response['error'].should eq(true) + doc.parsed_response['code'].should eq(400) + doc.parsed_response['errorNum'].should eq(1203) + doc.parsed_response['errorMessage'].should include("no collection name specified") + end + def check400 (doc) doc.code.should eq(400) doc.parsed_response['error'].should eq(true) @@ -1338,7 +1346,7 @@ describe ArangoDB do # Added _from and _to, because otherwise a 400 might conceal the # 404. Another test checking that missing _from or _to trigger # errors was added to api-gharial-spec.js. - check404Collection(replace_edge( sync, graph_name, friend_collection, unknown_name, {"_from" => "xyz/1", "_to" => "abc/2"})) + check400Collection(replace_edge( sync, graph_name, friend_collection, unknown_name, {"_from" => "xyz/1", "_to" => "abc/2"})) end it "replace edge (document does not exist) not found" do