135 lines
3.4 KiB
HTTP
135 lines
3.4 KiB
HTTP
@WepApiTest_HostAddress = http://localhost:5162
|
|
|
|
### Swagger page working
|
|
GET {{WepApiTest_HostAddress}}/swagger
|
|
Accept: text/xml
|
|
|
|
###
|
|
# @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}}"
|
|
}
|
|
|
|
### Login rng user
|
|
|
|
POST {{WepApiTest_HostAddress}}/api/auth/login
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"identifier": "{{rngUser}}",
|
|
"password": "{{rngPassword}}"
|
|
}
|
|
|
|
> {% client.global.set("auth_token", response.body); %}
|
|
|
|
### API Authenticated Empty
|
|
POST {{WepApiTest_HostAddress}}/api/auth
|
|
Content-Type: application/json
|
|
|
|
{}
|
|
|
|
### API Rng User Authenticated
|
|
POST {{WepApiTest_HostAddress}}/api/auth
|
|
Authorization: Bearer {{auth_token}}
|
|
Accept: application/json
|
|
|
|
### API Logout
|
|
POST {{WepApiTest_HostAddress}}/api/auth/logout
|
|
Authorization: Bearer {{auth_token}}
|
|
Accept: application/json
|
|
|
|
### API Login as admin
|
|
POST {{WepApiTest_HostAddress}}/api/auth/login
|
|
Content-Type: application/json
|
|
|
|
{
|
|
"identifier": "admin",
|
|
"password": "admin"
|
|
}
|
|
|
|
> {% client.global.set("admin_token", response.body); %}
|
|
|
|
### API Authenticated as admin
|
|
POST {{WepApiTest_HostAddress}}/api/auth
|
|
Authorization: Bearer {{admin_token}}
|
|
|
|
### 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.test("User create as admin", function() {
|
|
client.assert(response.status === 200)});
|
|
client.global.set("createdUser", jsonPath(response.body, "$"));
|
|
%}
|
|
|
|
### 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)});
|
|
%}
|