-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add 2 new .rest files for API testing using VS Code REST Client…
… plugin
- Loading branch information
1 parent
43a4e86
commit 65fb652
Showing
4 changed files
with
183 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// REST Client is a tool that allows you to make HTTP requests directly within Visual Studio Code. | ||
// https://marketplace.visualstudio.com/items?itemName=humao.rest-client | ||
// This file includes all requests available in AuthCompanion's Admin API | ||
@host = 127.0.0.1:3002/v1/admin | ||
@admin_email = admin@localhost | ||
// admin password can be found in ./adminkey file by default (on first startup) | ||
@admin_password = | ||
@access_token = {{login.response.body.data.attributes.access_token}} | ||
@refresh_token = {{login.response.body.data.attributes.refresh_token}} | ||
@admin_id = {{login.response.body.data.id}} | ||
|
||
|
||
### Login to the admin account | ||
# @name login | ||
POST http://{{host}}/login | ||
content-type: application/json | ||
|
||
{ | ||
"data": { | ||
"type": "users", | ||
"attributes": { | ||
"email": "{{admin_email}}", | ||
"password": "{{admin_password}}" | ||
} | ||
} | ||
} | ||
|
||
### Create a user account | ||
# @name createdUser | ||
POST http://{{host}}/users | ||
content-type: application/json | ||
Authorization: Bearer {{access_token}} | ||
|
||
{ | ||
"data": { | ||
"type": "users", | ||
"attributes": { | ||
"name": "Authy Person", | ||
"email": "[email protected]", | ||
"password": "supersecretpassword", | ||
"metadata": { | ||
"tenant": "1234" | ||
}, | ||
"appdata": { | ||
"tenant": "5678" | ||
}, | ||
"active": true, | ||
"isAdmin": false | ||
} | ||
} | ||
} | ||
|
||
### Update a user account | ||
@user_id = {{createdUser.response.body.data.id}} | ||
PATCH http://{{host}}/users/{{user_id}} | ||
content-type: application/json | ||
Authorization: Bearer {{access_token}} | ||
|
||
{ | ||
"data": { | ||
"type": "users", | ||
"attributes": { | ||
"name": "Authy Person", | ||
"email": "[email protected]", | ||
"password": "supersecretpassword", | ||
"metadata": { | ||
"tenant": "1234" | ||
}, | ||
"appdata": { | ||
"tenant": "5678" | ||
}, | ||
"active": true, | ||
"isAdmin": false | ||
} | ||
} | ||
} | ||
|
||
### List the user accounts | ||
GET http://{{host}}/users?page[number]=1 | ||
content-type: application/json | ||
Authorization: Bearer {{access_token}} | ||
|
||
|
||
### Delete a user account | ||
@user_id = {{createdUser.response.body.data.id}} | ||
DELETE http://{{host}}/users/{{user_id}} | ||
content-type: application/json | ||
Authorization: Bearer {{access_token}} | ||
|
||
### Regenerate admins's refresh token | ||
POST http://{{host}}/refresh | ||
content-type: application/json | ||
|
||
{ | ||
"refreshToken": "{{refresh_token}}" | ||
} | ||
|
||
### Logout of admin account | ||
@user_id = {{createdUser.response.body.data.id}} | ||
DELETE http://{{host}}/logout/{{admin_id}} | ||
content-type: application/json | ||
Authorization: Bearer {{access_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
// REST Client is a tool that allows you to make HTTP requests directly within Visual Studio Code. | ||
// https://marketplace.visualstudio.com/items?itemName=humao.rest-client | ||
// This file includes all requests available in AuthCompanion's Authentication API | ||
@host = 127.0.0.1:3002/v1/auth | ||
@user_email = [email protected] | ||
@user_password = supersecretpassword | ||
|
||
### Register a new user account | ||
POST http://{{host}}/register | ||
content-type: application/json | ||
|
||
{ | ||
"data": { | ||
"type": "users", | ||
"attributes": { | ||
"name": "Authy Person", | ||
"email": "{{user_email}}", | ||
"password": "{{user_password}}", | ||
"metadata": { | ||
"tenantID": "1234" | ||
} | ||
} | ||
} | ||
} | ||
|
||
### Login to the user account | ||
# @name login | ||
POST http://{{host}}/login | ||
content-type: application/json | ||
|
||
{ | ||
"data": { | ||
"type": "users", | ||
"attributes": { | ||
"email": "{{user_email}}", | ||
"password": "{{user_password}}" | ||
} | ||
} | ||
} | ||
|
||
### Update the user account | ||
@access_token = {{login.response.body.data.attributes.access_token}} | ||
@refresh_token = {{login.response.headers.set-cookie}} | ||
POST http://{{host}}/users/me | ||
content-type: application/json | ||
Authorization: Bearer {{access_token}} | ||
Cookie: {{refresh_token}} | ||
|
||
{ | ||
"data": { | ||
"type": "users", | ||
"attributes": { | ||
"name": "Authy Person_updated_name" | ||
} | ||
} | ||
} | ||
|
||
### Recover a user account | ||
POST http://{{host}}/recovery | ||
content-type: application/json | ||
|
||
{ | ||
"email": "{{user_email}}" | ||
} | ||
|
||
### Regenerate user's refresh token | ||
POST http://{{host}}/refresh | ||
content-type: application/json | ||
Cookie: {{refresh_token}} | ||
|
||
{} | ||
|
||
### Delete user's refresh token | ||
DELETE http://{{host}}/refresh | ||
content-type: application/json | ||
Cookie: {{refresh_token}} | ||
|
||
{} |