fix: auth robot test
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
log.html
|
||||
output.xml
|
||||
report.html
|
||||
env
|
||||
@@ -0,0 +1,83 @@
|
||||
*** Settings ***
|
||||
Documentation Tests of the /auth route.
|
||||
... Ensures that the user can authenticate on kyoo.
|
||||
Resource ../rest.resource
|
||||
|
||||
|
||||
*** Keywords ***
|
||||
Login
|
||||
[Documentation] Shortcut to login with the given username for future requests
|
||||
[Arguments] ${username}
|
||||
&{res}= POST /auth/login {"username": "${username}", "password": "password-${username}"}
|
||||
Output
|
||||
Integer response status 201
|
||||
String response body access_token
|
||||
Set Headers {"Authorization": "Bearer ${res.body.access_token}"}
|
||||
|
||||
Register
|
||||
[Documentation] Shortcut to register with the given username for future requests
|
||||
[Arguments] ${username}
|
||||
&{res}= POST
|
||||
... /auth/register
|
||||
... {"username": "${username}", "password": "password-${username}", "email": "${username}@chromacase.moe"}
|
||||
Output
|
||||
Integer response status 200
|
||||
|
||||
Logout
|
||||
[Documentation] Logout the current user, only the local client is affected.
|
||||
Set Headers {"Authorization": ""}
|
||||
|
||||
|
||||
*** Test Cases ***
|
||||
Me cant be accessed without an account
|
||||
Get /auth/me
|
||||
Output
|
||||
Integer response status 401
|
||||
|
||||
Bad Account
|
||||
[Documentation] Login fails if user does not exist
|
||||
POST /auth/login {"username": "i-don-t-exist", "password": "pass"}
|
||||
Output
|
||||
Integer response status 401
|
||||
|
||||
RegisterAndLogin
|
||||
[Documentation] Create a new user and login in it
|
||||
Register user-1
|
||||
Login user-1
|
||||
[Teardown] DELETE /auth/me
|
||||
|
||||
Register Duplicates
|
||||
[Documentation] If two users tries to register with the same username, it fails
|
||||
Register user-duplicate
|
||||
# We can't use the `Register` keyword because it assert for success
|
||||
POST /auth/register {"username": "user-duplicate", "password": "pass", "email": "mail@kyoo.moe"}
|
||||
Output
|
||||
Integer response status 400
|
||||
Login user-duplicate
|
||||
[Teardown] DELETE /auth/me
|
||||
|
||||
Delete Account
|
||||
[Documentation] Check if a user can delete it's account
|
||||
Register I-should-be-deleted
|
||||
Login I-should-be-deleted
|
||||
DELETE /auth/me
|
||||
Output
|
||||
Integer response status 200
|
||||
|
||||
Login
|
||||
[Documentation] Create a new user and login in it
|
||||
Register login-user
|
||||
Login login-user
|
||||
${res}= GET /auth/me
|
||||
Output
|
||||
Integer response status 200
|
||||
String response body username login-user
|
||||
|
||||
Logout
|
||||
Login login-user
|
||||
${me}= Get /auth/me
|
||||
Output
|
||||
Output ${me}
|
||||
Should Be Equal As Strings ${res["body"]} ${me["body"]}
|
||||
|
||||
[Teardown] DELETE /auth/me
|
||||
@@ -1,4 +1,4 @@
|
||||
*** Settings ***
|
||||
Documentation Common things to handle rest requests
|
||||
|
||||
Library REST http://localhost:3000/api
|
||||
Library REST http://localhost:3000
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
*** Settings ***
|
||||
Documentation Tests of the /users route.
|
||||
... Ensures that the users CRUD works corectly.
|
||||
Resource ../rest.resource
|
||||
|
||||
|
||||
*** Keywords ***
|
||||
*** Test Cases ***
|
||||
Create a user
|
||||
[Documentation] Create a user
|
||||
POST /users {"username": "i-don-t-exist", "password": "pass", "email": "wow@gmail.com"}
|
||||
Output
|
||||
Integer response status 201
|
||||
[Teardown] DELETE /users/1
|
||||
Reference in New Issue
Block a user