From d489d0cba23ce67e87943d5e465833048aff86e2 Mon Sep 17 00:00:00 2001 From: Ebenezer Monney Date: Mon, 28 Oct 2024 16:49:38 +0000 Subject: [PATCH] Refactord API testing HTTP file --- QuickApp.Server/QuickApp.Server.http | 114 +++++++++++---------------- 1 file changed, 47 insertions(+), 67 deletions(-) diff --git a/QuickApp.Server/QuickApp.Server.http b/QuickApp.Server/QuickApp.Server.http index 2937dee8c..246452139 100644 --- a/QuickApp.Server/QuickApp.Server.http +++ b/QuickApp.Server/QuickApp.Server.http @@ -1,18 +1,24 @@ @QuickApp.Server_HostAddress = https://localhost:7085 @QuickApp.Client_HostAddress = https://localhost:4200 -@AccessToken = +@AccessToken = Paste_access_token_here #### This file enables you to test the APIs of QuickApp. #### You can also test the APIs with Swagger by appending "/swagger"" to the home url or by using postman #### See https://learn.microsoft.com/en-us/aspnet/core/test/http-files?view=aspnetcore-8.0 for more info on http files + +################################################### ### Login to get access token +################################################### POST {{QuickApp.Server_HostAddress}}/connect/token Content-Type: application/x-www-form-urlencoded client_id=swagger_ui&grant_type=password&username=admin&password=tempP@ss123 -#### User APIs #### + +################################################### +### User APIs +################################################### ### Get all users GET {{QuickApp.Server_HostAddress}}/api/account/users @@ -24,11 +30,6 @@ GET {{QuickApp.Server_HostAddress}}/api/account/users/me Accept: application/json Authorization: Bearer {{AccessToken}} -### Get user with username "admin" -GET {{QuickApp.Server_HostAddress}}/api/account/users/username/admin -Accept: application/json -Authorization: Bearer {{AccessToken}} - ### Register new user POST {{QuickApp.Server_HostAddress}}/api/account/users Authorization: Bearer {{AccessToken}} @@ -42,54 +43,43 @@ Content-Type: application/json "roles": ["administrator"] } -### Delete an exisint user -POST {{QuickApp.Server_HostAddress}}/api/account/users +### Get newly registered user with username "test_1" +GET {{QuickApp.Server_HostAddress}}/api/account/users/username/test_1 +Accept: application/json Authorization: Bearer {{AccessToken}} -Content-Type: application/json -{ - "userName": "test_1", - "email": "test_1@ebenmonney.com", - "isEnabled": true, - "newPassword": "testP@ss123", - "roles": ["administrator"] -} - -### Update user with id "1445aa42-b5d3-4f2b-b702-8c2b9f526c0f" -PUT {{QuickApp.Server_HostAddress}}/api/account/users/1445aa42-b5d3-4f2b-b702-8c2b9f526c0f +### Update user with a specific id +PUT {{QuickApp.Server_HostAddress}}/api/account/users/Paste_user_id_here Authorization: Bearer {{AccessToken}} Content-Type: application/json { - "id": "1445aa42-b5d3-4f2b-b702-8c2b9f526c0f", - "userName": "admin", - "fullName": "Inbuilt Administrator", - "email": "admin@ebenmonney.com", + "userName": "test_1", + "fullName": "My New Fullname", + "email": "test_1@ebenmonney.com", "isEnabled": true, "isLockedOut": false, - "jobTitle": "Dr", - "phoneNumber": "+1 (123) 000-0000", + "jobTitle": "Dr.", + "phoneNumber": "+2 (456) 123-789", "roles": ["administrator"] } -### Delete user with id "1445aa42-b5d3-4f2b-b702-8c2b9f526c0f" -DELETE {{QuickApp.Server_HostAddress}}/api/account/users/a5ce6e4a-ccb9-4c73-b0bb-157f1c6672a9 +### Delete user with a specific id +DELETE {{QuickApp.Server_HostAddress}}/api/account/users/Paste_user_id_here Authorization: Bearer {{AccessToken}} -### Role APIs #### + +################################################### +### Role APIs +################################################### ### Get all roles GET {{QuickApp.Server_HostAddress}}/api/account/roles Accept: application/json Authorization: Bearer {{AccessToken}} -### Get current role -GET {{QuickApp.Server_HostAddress}}/api/account/roles/7ededf4b-c535-4976-ad10-feb3e1aa681c -Accept: application/json -Authorization: Bearer {{AccessToken}} - -### Get role with rolename "admin" -GET {{QuickApp.Server_HostAddress}}/api/account/roles/rolename/admin +### Get role with a specific id +GET {{QuickApp.Server_HostAddress}}/api/account/roles/Paste_role_id_here Accept: application/json Authorization: Bearer {{AccessToken}} @@ -99,51 +89,41 @@ Authorization: Bearer {{AccessToken}} Content-Type: application/json { - "roleName": "test_1", - "email": "test_1@ebenmonney.com", - "isEnabled": true, - "newPassword": "testP@ss123", - "roles": ["administrator"] + "name": "test_1", + "description": "Test role 1" } -### Delete an exisint role -POST {{QuickApp.Server_HostAddress}}/api/account/roles +### Get newly registered role with role name "test_1" +GET {{QuickApp.Server_HostAddress}}/api/account/roles/name/test_1 +Accept: application/json Authorization: Bearer {{AccessToken}} -Content-Type: application/json - -{ - "roleName": "test_1", - "email": "test_1@ebenmonney.com", - "isEnabled": true, - "newPassword": "testP@ss123", - "roles": ["administrator"] -} -### Update role with id "7ededf4b-c535-4976-ad10-feb3e1aa681c" -PUT {{QuickApp.Server_HostAddress}}/api/account/roles/7ededf4b-c535-4976-ad10-feb3e1aa681c +### Update role with a specific id +PUT {{QuickApp.Server_HostAddress}}/api/account/roles/Paste_role_id_here Authorization: Bearer {{AccessToken}} Content-Type: application/json { - "id": "7ededf4b-c535-4976-ad10-feb3e1aa681c", - "roleName": "admin", - "fullName": "Inbuilt Administrator", - "email": "admin@ebenmonney.com", - "isEnabled": true, - "isLockedOut": false, - "jobTitle": "Dr", - "phoneNumber": "+1 (123) 000-0000", - "roles": ["administrator"] + "name": "test_123", + "description": "New test role 1 description", + "permissions": [ + {"value": "users.view"}, + {"value": "roles.view"} + ] } -### Delete role with id "7ededf4b-c535-4976-ad10-feb3e1aa681c" -DELETE {{QuickApp.Server_HostAddress}}/api/account/roles/7ededf4b-c535-4976-ad10-feb3e1aa681c + +### Delete role with a specific id +DELETE {{QuickApp.Server_HostAddress}}/api/account/roles/Paste_role_id_here Authorization: Bearer {{AccessToken}} -### Customer APIs ### + +################################################### +### Customer APIs +################################################### ### Get dummy customers GET {{QuickApp.Client_HostAddress}}/api/Customer Accept: */* -### \ No newline at end of file +### ... Add more APIs here \ No newline at end of file