-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauthSystemPostmanCollection.json
More file actions
158 lines (158 loc) · 4.7 KB
/
authSystemPostmanCollection.json
File metadata and controls
158 lines (158 loc) · 4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
{
"info": {
"name": "Auth System Complete Flow",
"_postman_id": "auth-system-complete-001",
"description": "Full workflow: auto-registration/login, manual login, failure tests, and protected endpoints with JWT",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Register User - Auto Login",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{\n \"emailAddress\": \"user@example.com\",\n \"password\": \"password123\",\n \"fullName\": \"John Doe\"\n}"
},
"url": {
"raw": "http://localhost:8080/api/v1/auth/register",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api","v1","auth","register"]
}
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"// Auto login after registration",
"let jsonData = pm.response.json();",
"if(jsonData.success){",
" pm.sendRequest({",
" url: 'http://localhost:8080/api/v1/auth/login',",
" method: 'POST',",
" header: {'Content-Type': 'application/json'},",
" body: { mode: 'raw', raw: JSON.stringify({",
" emailAddress: 'user@example.com',",
" password: 'password123'",
" }) }",
" }, function (err, res) {",
" let loginData = res.json();",
" if(loginData.success && loginData.token){",
" pm.environment.set('JWT_TOKEN', loginData.token);",
" }",
" });",
"}"
],
"type": "text/javascript"
}
}
]
},
{
"name": "Login - Manual Success",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{\n \"emailAddress\": \"user@example.com\",\n \"password\": \"password123\"\n}"
},
"url": {
"raw": "http://localhost:8080/api/v1/auth/login",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api","v1","auth","login"]
}
},
"event": [
{
"listen": "test",
"script": {
"exec": [
"let jsonData = pm.response.json();",
"if(jsonData.success && jsonData.token){",
" pm.environment.set('JWT_TOKEN', jsonData.token);",
"}"
],
"type": "text/javascript"
}
}
]
},
{
"name": "Login - Invalid Credentials",
"request": {
"method": "POST",
"header": [
{ "key": "Content-Type", "value": "application/json" }
],
"body": {
"mode": "raw",
"raw": "{\n \"emailAddress\": \"user@example.com\",\n \"password\": \"wrongpassword\"\n}"
},
"url": {
"raw": "http://localhost:8080/api/v1/auth/login",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api","v1","auth","login"]
}
}
},
{
"name": "Get Profile - Protected Endpoint",
"request": {
"method": "GET",
"header": [
{ "key": "Authorization", "value": "Bearer {{JWT_TOKEN}}" }
],
"url": {
"raw": "http://localhost:8080/api/v1/user/profile",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api","v1","user","profile"]
}
}
},
{
"name": "Get Profile - Missing JWT",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/v1/user/profile",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api","v1","user","profile"]
}
}
},
{
"name": "Get Profile - Invalid JWT",
"request": {
"method": "GET",
"header": [
{ "key": "Authorization", "value": "Bearer invalid.token.here" }
],
"url": {
"raw": "http://localhost:8080/api/v1/user/profile",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api","v1","user","profile"]
}
}
}
]
}