eduverse-backend / Documentation /Auth_UserManagement_Complete.postman_collection.json
tarekdx3's picture
Enrollment Feature DONE AND TESTED SUCCESFULLY
7333f29
Raw
History Blame Contribute Delete
29.2 kB
{
"info": {
"_postman_id": "auth-user-management-complete",
"name": "Auth & User Management - Complete Test Suite",
"description": "Complete test collection for authentication, user management, roles, and permissions",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Authentication",
"item": [
{
"name": "Register User",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 201 or 200', function () {",
" pm.expect([200, 201]).to.include(pm.response.code);",
"});",
"if (pm.response.code === 200 || pm.response.code === 201) {",
" var jsonData = pm.response.json();",
" pm.environment.set('registered_user_id', jsonData.user.userId);",
" console.log('✅ User Registered: ' + jsonData.user.email + ', ID: ' + jsonData.user.userId);",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"newstudent{{$timestamp}}@test.com\",\n \"password\": \"Test@1234\",\n \"firstName\": \"Test\",\n \"lastName\": \"User\",\n \"phone\": \"0201234567\",\n \"role\": \"student\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/register",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"register"
]
}
},
"response": []
},
{
"name": "Login User",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"if (pm.response.code === 200) {",
" var jsonData = pm.response.json();",
" pm.environment.set('test_token', jsonData.accessToken);",
" pm.environment.set('test_user_id', jsonData.user.userId);",
" console.log('✅ Login Successful, Token: ' + jsonData.accessToken.substring(0, 20) + '...');",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"tarekadmin@gmail.com\",\n \"password\": \"Test@1234\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/login",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"login"
]
}
},
"response": []
},
{
"name": "Refresh Token",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Token Refreshed');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"refreshToken\": \"{{refresh_token}}\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/refresh-token",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"refresh-token"
]
}
},
"response": []
},
{
"name": "Logout",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Logged Out Successfully');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"sessionToken\": \"{{session_token}}\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/logout",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"logout"
]
}
},
"response": []
},
{
"name": "Forgot Password",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Password Reset Email Sent');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"tarekstudent@gmail.com\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/forgot-password",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"forgot-password"
]
}
},
"response": []
},
{
"name": "Verify Email",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status is 200 or 400', function () {",
" pm.expect([200, 400]).to.include(pm.response.code);",
"});",
"console.log('✅ Email Verification Attempt: ' + pm.response.code);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"token\": \"verification-token-here\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/verify-email",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"verify-email"
]
}
},
"response": []
},
{
"name": "Resend Verification Email",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status is 200 or 400', function () {",
" pm.expect([200, 400]).to.include(pm.response.code);",
"});",
"console.log('✅ Resend Verification Attempt: ' + pm.response.code);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"email\": \"newuser@test.com\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/auth/resend-verification-email",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"auth",
"resend-verification-email"
]
}
},
"response": []
}
]
},
{
"name": "User Management",
"item": [
{
"name": "Get All Users",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"var jsonData = pm.response.json();",
"pm.test('Response is an array', function () {",
" pm.expect(jsonData).to.be.an('array');",
"});",
"if (jsonData.length > 0) {",
" console.log('✅ Found ' + jsonData.length + ' users');",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/users",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users"
]
}
},
"response": []
},
{
"name": "Get User by ID",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"var jsonData = pm.response.json();",
"pm.test('User has email', function () {",
" pm.expect(jsonData).to.have.property('email');",
"});",
"console.log('✅ User Retrieved: ' + jsonData.email);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/users/{{test_user_id}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users",
"{{test_user_id}}"
]
}
},
"response": []
},
{
"name": "Update User",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ User Updated');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"firstName\": \"Updated\",\n \"lastName\": \"Name\",\n \"phone\": \"0209876543\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/admin/users/{{test_user_id}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users",
"{{test_user_id}}"
]
}
},
"response": []
},
{
"name": "Change User Status",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"var jsonData = pm.response.json();",
"pm.test('Status is changed', function () {",
" pm.expect(['active', 'inactive', 'suspended', 'pending']).to.include(jsonData.status);",
"});",
"console.log('✅ User Status Changed to: ' + jsonData.status);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"status\": \"active\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/admin/users/{{test_user_id}}/status",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users",
"{{test_user_id}}",
"status"
]
}
},
"response": []
},
{
"name": "Search Users",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Search Results Retrieved');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/users/search?query=tarek",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users",
"search"
],
"query": [
{
"key": "query",
"value": "tarek"
}
]
}
},
"response": []
},
{
"name": "Assign Role to User",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Role Assigned to User');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"roleId\": {{role_id}}\n}"
},
"url": {
"raw": "http://localhost:8081/api/admin/users/{{test_user_id}}/roles",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users",
"{{test_user_id}}",
"roles"
]
}
},
"response": []
},
{
"name": "Get User Permissions",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ User Permissions Retrieved');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/users/{{test_user_id}}/permissions",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"users",
"{{test_user_id}}",
"permissions"
]
}
},
"response": []
}
]
},
{
"name": "Role Management",
"item": [
{
"name": "Get All Roles",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"var jsonData = pm.response.json();",
"if (jsonData.length > 0) {",
" pm.environment.set('role_id', jsonData[0].roleId);",
" console.log('✅ Found ' + jsonData.length + ' roles');",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/roles",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"roles"
]
}
},
"response": []
},
{
"name": "Get Role by ID",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Role Retrieved');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/roles/{{role_id}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"roles",
"{{role_id}}"
]
}
},
"response": []
},
{
"name": "Create Role",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 201 or 200', function () {",
" pm.expect([200, 201]).to.include(pm.response.code);",
"});",
"var jsonData = pm.response.json();",
"pm.environment.set('created_role_id', jsonData.roleId);",
"console.log('✅ Role Created: ' + jsonData.roleName);"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"roleName\": \"content_manager\",\n \"description\": \"Manages course content and materials\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/admin/roles",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"roles"
]
}
},
"response": []
},
{
"name": "Update Role",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Role Updated');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"roleName\": \"content_manager_updated\",\n \"description\": \"Updated description\"\n}"
},
"url": {
"raw": "http://localhost:8081/api/admin/roles/{{created_role_id}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"roles",
"{{created_role_id}}"
]
}
},
"response": []
},
{
"name": "Get All Permissions",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"var jsonData = pm.response.json();",
"if (jsonData.length > 0) {",
" pm.environment.set('permission_id', jsonData[0].permissionId);",
" console.log('✅ Found ' + jsonData.length + ' permissions');",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
}
],
"url": {
"raw": "http://localhost:8081/api/admin/permissions",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"permissions"
]
}
},
"response": []
},
{
"name": "Assign Permission to Role",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test('Status code is 200', function () {",
" pm.expect(pm.response.code).to.equal(200);",
"});",
"console.log('✅ Permission Assigned to Role');"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "Authorization",
"value": "Bearer {{admin_token}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/json"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"permissionId\": {{permission_id}}\n}"
},
"url": {
"raw": "http://localhost:8081/api/admin/roles/{{created_role_id}}/permissions",
"protocol": "http",
"host": [
"localhost"
],
"port": "8081",
"path": [
"api",
"admin",
"roles",
"{{created_role_id}}",
"permissions"
]
}
},
"response": []
}
]
}
],
"variable": [
{
"key": "admin_token",
"value": "",
"type": "string"
},
{
"key": "test_user_id",
"value": "",
"type": "string"
},
{
"key": "role_id",
"value": "",
"type": "string"
},
{
"key": "permission_id",
"value": "",
"type": "string"
},
{
"key": "created_role_id",
"value": "",
"type": "string"
}
]
}