-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserManagementAPI.http
More file actions
136 lines (99 loc) · 2.99 KB
/
UserManagementAPI.http
File metadata and controls
136 lines (99 loc) · 2.99 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
@UserManagementAPI_HostAddress = http://localhost:5048
# Login and capture token (REST Client variable)
# @name login
POST {{UserManagementAPI_HostAddress}}/api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "password123"
}
###
@token = {{login.response.body.token}}
###############################################
# TEST SUITE FOR API VALIDATION
###############################################
### TEST 1: Login with invalid credentials (SHOULD RETURN 401)
POST {{UserManagementAPI_HostAddress}}/api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "wrongpassword"
}
###
### TEST 2: Access protected endpoint WITHOUT token (SHOULD RETURN 401)
GET {{UserManagementAPI_HostAddress}}/api/users
Accept: application/json
###
### TEST 3: Access protected endpoint WITH INVALID token (SHOULD RETURN 401)
GET {{UserManagementAPI_HostAddress}}/api/users
Accept: application/json
Authorization: Bearer invalid.token.here
###
### TEST 4: Get all users WITH VALID TOKEN (SHOULD RETURN 200 + DATA)
GET {{UserManagementAPI_HostAddress}}/api/users
Accept: application/json
Authorization: Bearer {{token}}
###
### TEST 5: Get user by ID WITH VALID TOKEN (SHOULD RETURN 200 + USER)
GET {{UserManagementAPI_HostAddress}}/api/users/1
Accept: application/json
Authorization: Bearer {{token}}
###
### TEST 6: Get non-existent user (SHOULD RETURN 404 + ERROR RESPONSE)
GET {{UserManagementAPI_HostAddress}}/api/users/999
Accept: application/json
Authorization: Bearer {{token}}
###
### TEST 7: Create user with INVALID NAME - only 1 word (SHOULD RETURN 400)
POST {{UserManagementAPI_HostAddress}}/api/users
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "John",
"status": "Active"
}
###
### TEST 8: Create user with valid data (SHOULD RETURN 201 + USER with Status=Inactive)
POST {{UserManagementAPI_HostAddress}}/api/users
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "Alice Marie Johnson",
"status": "Active"
}
###
### TEST 9: Update user with valid token (SHOULD RETURN 200 + UPDATED USER)
PUT {{UserManagementAPI_HostAddress}}/api/users/1
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "John Michael Updated",
"status": "Active"
}
###
### TEST 10: Update user with INVALID NAME (SHOULD RETURN 400)
PUT {{UserManagementAPI_HostAddress}}/api/users/1
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "Jo",
"status": "Active"
}
###
### TEST 11: Update non-existent user (SHOULD RETURN 404)
PUT {{UserManagementAPI_HostAddress}}/api/users/999
Content-Type: application/json
Authorization: Bearer {{token}}
{
"name": "Test User Name",
"status": "Active"
}
###
### TEST 12: Delete user with valid token (SHOULD RETURN 204)
DELETE {{UserManagementAPI_HostAddress}}/api/users/2
Authorization: Bearer {{token}}
###
### TEST 13: Delete non-existent user (SHOULD RETURN 404)
DELETE {{UserManagementAPI_HostAddress}}/api/users/999
Authorization: Bearer {{token}}
###