197 lines
4.7 KiB
HTTP
197 lines
4.7 KiB
HTTP
@WepApiTest_HostAddress = http://localhost:5162
|
|
|
|
### Swagger page working
|
|
GET {{WepApiTest_HostAddress}}/swagger
|
|
Accept: text/xml
|
|
|
|
> {%
|
|
client.test("Swagger page working", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
###
|
|
# @name Register rng user
|
|
< {%
|
|
client.global.set("rngUser", $random.alphabetic(15));
|
|
client.global.set("rngEmail", $random.alphabetic(5) + "@redcode.com");
|
|
client.global.set("rngPassword", "test" + $random.alphabetic(5));
|
|
%}
|
|
|
|
POST {{WepApiTest_HostAddress}}/api/auth/register
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"username": "{{rngUser}}",
|
|
"email": "{{rngEmail}}",
|
|
"password": "{{rngPassword}}"
|
|
}
|
|
|
|
> {%
|
|
client.test("Register rng user", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### Login rng user
|
|
|
|
POST {{WepApiTest_HostAddress}}/api/auth/login
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"identifier": "{{rngUser}}",
|
|
"password": "{{rngPassword}}"
|
|
}
|
|
|
|
> {%
|
|
client.global.set("auth_token", jsonPath(response.body, "$.token"));
|
|
client.test("Login rng user", function () {
|
|
client.assert(response.status === 200)
|
|
//client.assert(jsonPath(response.body, "$.success") != true,jsonPath(response.body, "$.errorMessage")??"null")
|
|
});
|
|
%}
|
|
|
|
|
|
### API Authenticated Empty
|
|
POST {{WepApiTest_HostAddress}}/api/auth
|
|
Content-Type: application/json
|
|
|
|
{}
|
|
|
|
> {%
|
|
client.test("API Authenticated Empty", function () {
|
|
client.assert(response.status === 401)
|
|
});
|
|
%}
|
|
|
|
### API Rng User Authenticated
|
|
POST {{WepApiTest_HostAddress}}/api/auth
|
|
Authorization: Bearer {{auth_token}}
|
|
Accept: application/json
|
|
|
|
> {%
|
|
client.test("API Rng User Authenticated", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### API Logout
|
|
POST {{WepApiTest_HostAddress}}/api/auth/logout
|
|
Authorization: Bearer {{auth_token}}
|
|
Accept: application/json
|
|
|
|
> {%
|
|
client.test("API Logout", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### API Login as admin
|
|
POST {{WepApiTest_HostAddress}}/api/auth/login
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"identifier": "admin",
|
|
"password": "admin"
|
|
}
|
|
|
|
> {%
|
|
client.global.set("admin_token", jsonPath(response.body, "$.token"));
|
|
client.test("Login as admin", function () {
|
|
client.assert(response.status === 200)
|
|
//client.assert(jsonPath(response.body, "$.success") != true,jsonPath(response.body, "$.errorMessage")??"null")
|
|
});
|
|
%}
|
|
|
|
### API Authenticated as admin
|
|
POST {{WepApiTest_HostAddress}}/api/auth
|
|
Authorization: Bearer {{admin_token}}
|
|
|
|
> {%
|
|
client.test("API Authenticated as admin", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### Try User create as rng user
|
|
PUT {{WepApiTest_HostAddress}}/api/user
|
|
Authorization: Bearer {{auth_token}}
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"username": "thisUserShouldNotBeCreated",
|
|
"email": "nope@nope.cope",
|
|
"password": "qwertyu",
|
|
"accessLevel": 0
|
|
}
|
|
|
|
> {%
|
|
client.test("User create as rng user", function () {
|
|
client.assert(response.status === 403)
|
|
});
|
|
%}
|
|
|
|
### Try User create as admin
|
|
PUT {{WepApiTest_HostAddress}}/api/user
|
|
Authorization: Bearer {{admin_token}}
|
|
Accept: application/json
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"username": "thisUserShouldBeCreated",
|
|
"email": "thisUserWillBeDeleted@gmai.com",
|
|
"password": "qwertyu",
|
|
"accessLevel": 1
|
|
}
|
|
|
|
> {%
|
|
client.global.set("createdUser", jsonPath(response.body, "$"));
|
|
client.test("User create as admin", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### Try get the user as rng user
|
|
GET {{WepApiTest_HostAddress}}/api/user/{{createdUser}}
|
|
Authorization: Bearer {{auth_token}}
|
|
Accept: application/json
|
|
|
|
//TODO: check what data is returned
|
|
> {%
|
|
client.test("Get the user as rng user", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### Try get the user as admin
|
|
GET {{WepApiTest_HostAddress}}/api/user/{{createdUser}}
|
|
Authorization: Bearer {{admin_token}}
|
|
Accept: application/json
|
|
|
|
//TODO: check what data is returned
|
|
> {%
|
|
client.test("Get the user as admin", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|
|
|
|
### Try Delete user as rng user
|
|
DELETE {{WepApiTest_HostAddress}}/api/user/{{createdUser}}
|
|
Authorization: Bearer {{auth_token}}
|
|
|
|
> {%
|
|
client.test("Delete user as rng user", function () {
|
|
client.assert(response.status === 403)
|
|
});
|
|
%}
|
|
|
|
### Delete created user
|
|
DELETE {{WepApiTest_HostAddress}}/api/user/{{createdUser}}
|
|
Authorization: Bearer {{admin_token}}
|
|
|
|
> {%
|
|
client.test("Delete created user", function () {
|
|
client.assert(response.status === 200)
|
|
});
|
|
%}
|