MXS-1300: Move the REST API tests back into the core
As the REST API is a part of the core, it is more appropriate for the tests to reside there as well. Further refactoring of the testing needs to be done to allow multiple components to use the same framework but with different tests.
This commit is contained in:
59
server/core/test/rest-api/test/users.js
Normal file
59
server/core/test/rest-api/test/users.js
Normal file
@ -0,0 +1,59 @@
|
||||
require("../utils.js")()
|
||||
|
||||
|
||||
describe("Users", function() {
|
||||
before(startMaxScale)
|
||||
|
||||
var user = {
|
||||
data: {
|
||||
id: "user1",
|
||||
type: "inet",
|
||||
attributes: {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it("add new user without password", function() {
|
||||
return request.post(base_url + "/users/inet", { json: user })
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it("add user", function() {
|
||||
user.data.attributes.password = "pw1"
|
||||
return request.post(base_url + "/users/inet", { json: user })
|
||||
.should.be.fulfilled
|
||||
})
|
||||
|
||||
it("add user again", function() {
|
||||
return request.post(base_url + "/users/inet", { json: user })
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it("add user again but without password", function() {
|
||||
delete user.data.attributes.password
|
||||
return request.post(base_url + "/users/inet", { json: user })
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it("get created user", function() {
|
||||
return request.get(base_url + "/users/inet/user1")
|
||||
.should.be.fulfilled
|
||||
})
|
||||
|
||||
it("get non-existent user", function() {
|
||||
return request.get(base_url + "/users/inet/user2")
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
it("delete created user", function() {
|
||||
return request.delete(base_url + "/users/inet/user1")
|
||||
.should.be.fulfilled
|
||||
})
|
||||
|
||||
it("delete created user again", function() {
|
||||
return request.delete(base_url + "/users/inet/user1")
|
||||
.should.be.rejected
|
||||
})
|
||||
|
||||
after(stopMaxScale)
|
||||
});
|
||||
Reference in New Issue
Block a user