Add song & search history (#165)

This commit is contained in:
Zoe Roux
2023-03-01 13:29:33 +09:00
committed by GitHub
parent df85d0cfa7
commit f1a3f6e46a
30 changed files with 553 additions and 126 deletions
+47
View File
@@ -0,0 +1,47 @@
*** Settings ***
Documentation Methods to login/register.
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 200
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 201
RegisterLogin
[Documentation] Shortcut to register with the given username for future requests
[Arguments] ${username}
POST
... /auth/register
... {"username": "${username}", "password": "password-${username}", "email": "${username}@chromacase.moe"}
Output
Integer response status 201
&{res}= POST /auth/login {"username": "${username}", "password": "password-${username}"}
Output
Integer response status 200
String response body access_token
Set Headers {"Authorization": "Bearer ${res.body.access_token}"}
&{me}= GET /auth/me
Output
Integer response status 200
RETURN ${me.body.id}
Logout
[Documentation] Logout the current user, only the local client is affected.
Set Headers {"Authorization": ""}
+6 -28
View File
@@ -1,31 +1,9 @@
*** 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 200
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 201
Logout
[Documentation] Logout the current user, only the local client is affected.
Set Headers {"Authorization": ""}
Resource ./auth.resource
*** Test Cases ***
@@ -43,7 +21,7 @@ Bad Account
RegisterAndLogin
[Documentation] Create a new user and login in it
Register user-1
Login user-1
Login user-1
[Teardown] DELETE /auth/me
Register Duplicates
@@ -53,13 +31,13 @@ Register Duplicates
POST /auth/register {"username": "user-duplicate", "password": "pass", "email": "mail@kyoo.moe"}
Output
Integer response status 400
Login user-duplicate
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
Login I-should-be-deleted
DELETE /auth/me
Output
Integer response status 200
@@ -67,7 +45,7 @@ Delete Account
Login
[Documentation] Create a new user and login in it
Register login-user
Login login-user
Login login-user
${res}= GET /auth/me
Output
Integer response status 200
+55
View File
@@ -0,0 +1,55 @@
*** Settings ***
Documentation Tests of the /history route.
... Ensures that the history CRUD works corectly.
Resource ../rest.resource
Resource ../auth/auth.resource
*** Test Cases ***
Get history without behing connected
&{history}= GET /history
Output
Integer response status 401
Create and get an history record
[Documentation] Create an history item
&{song}= POST
... /song
... {"name": "Mama mia", "difficulties": {}, "midiPath": "/musics/Beethoven-125-4.midi", "musicXmlPath": "/musics/Beethoven-125-4.mxl"}
Output
${userID}= RegisterLogin wowuser
&{history}= POST
... /history
... { "userID": ${userID}, "songID": ${song.body.id}, "score": 55, "difficulties": {} }
Output
Integer response status 201
&{res}= GET /history
Output
Integer response status 200
Array response body
Integer $[0].userID ${userID}
Integer $[0].songID ${song.body.id}
Integer $[0].score 55
[Teardown] Run Keywords DELETE /users/${userID}
... AND DELETE /song/${song.body.id}
Create and get a search history record
[Documentation] Create a search history item
${userID}= RegisterLogin historyqueryuser
GET /search/song/toto
Output
Integer response status 404
&{res}= GET /history/search
Output
Integer response status 200
Array response body
String $[0].type "song"
String $[0].query "toto"
[Teardown] DELETE /users/${userID}