1
0
Fork 0

issue #751: Create database through API should return HTTP status code 201

This commit is contained in:
Jan Steemann 2014-01-27 08:54:36 +01:00
parent b5905a293b
commit df1ce45e15
3 changed files with 43 additions and 11 deletions

View File

@ -1,6 +1,15 @@
v1.5.0 (XXXX-XX-XX)
-------------------
* issue #751: Create database through API should return HTTP status code 201
By default, the server now returns HTTP 201 (created) when creating a new
database successfully. To keep compatibility with older ArangoDB versions, the
startup parameter `--server.default-api-compatibility` can be set to a value
of `10400` to indicate API compatibility with ArangoDB 1.4. The compatibility
can also be enforced by setting the `X-Arango-Version` HTTP header in a
client request to this API on a per-request basis.
* issue #748: add vertex filtering to AQL's TRAVERSAL[_TREE]() function
* allow direct access from the `db` object to collections whose names start

View File

@ -66,12 +66,34 @@ describe ArangoDB do
after do
ArangoDB.delete(api + "/#{name}")
end
it "creates a new database, old return code" do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create", api, :body => body, :headers => { "X-Arango-Version" => "1.4" })
doc.code.should eq(200)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
response["error"].should eq(false)
end
it "creates a new database, new return code" do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create", api, :body => body, :headers => { "X-Arango-Version" => "1.5" })
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
response["error"].should eq(false)
end
it "creates a new database" do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
@ -115,7 +137,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-re-create", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc = ArangoDB.log_post("#{prefix}-post", api, :body => body)
@ -132,7 +154,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-drop", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
doc = ArangoDB.log_delete("#{prefix}-drop", cmd)
@ -158,7 +180,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-create-properties", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
@ -206,7 +228,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\", \"users\": [ { \"username\": \"admin\", \"password\": \"secret\", \"extra\": { \"gender\": \"m\" } }, { \"username\": \"foxx\", \"active\": false } ] }"
doc = ArangoDB.log_post("#{prefix}-create-users", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
@ -268,7 +290,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\", \"users\": [ { \"username\": \"\" } ] }"
doc = ArangoDB.log_post("#{prefix}-create-users-invalid", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)
@ -305,7 +327,7 @@ describe ArangoDB do
body = "{\"name\" : \"#{name}\" }"
doc = ArangoDB.log_post("#{prefix}-check-system", api, :body => body)
doc.code.should eq(200)
doc.code.should eq(201)
doc.headers['content-type'].should eq("application/json; charset=utf-8")
response = doc.parsed_response
response["result"].should eq(true)

View File

@ -240,7 +240,7 @@ function get_api_database (req, res) {
///
/// @RESTRETURNCODES
///
/// @RESTRETURNCODE{200}
/// @RESTRETURNCODE{201}
/// is returned if the database was created successfully.
///
/// @RESTRETURNCODE{400}
@ -272,7 +272,7 @@ function get_api_database (req, res) {
/// var response = logCurlRequest('POST', url, JSON.stringify(data));
///
/// db._dropDatabase(name);
/// assert(response.code === 200);
/// assert(response.code === 201);
///
/// logJsonResponse(response);
/// @END_EXAMPLE_ARANGOSH_RUN
@ -306,7 +306,7 @@ function get_api_database (req, res) {
/// var response = logCurlRequest('POST', url, JSON.stringify(data));
///
/// db._dropDatabase(name);
/// assert(response.code === 200);
/// assert(response.code === 201);
///
/// logJsonResponse(response);
/// @END_EXAMPLE_ARANGOSH_RUN
@ -374,7 +374,8 @@ function post_api_database (req, res) {
var result = arangodb.db._createDatabase(json.name || "", options, users);
actions.resultOk(req, res, actions.HTTP_OK, { result : result });
var returnCode = (req.compatibility <= 10400 ? actions.HTTP_OK : actions.HTTP_CREATED);
actions.resultOk(req, res, returnCode, { result : result });
}
////////////////////////////////////////////////////////////////////////////////