-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCoreModule-Customers-API.http
More file actions
180 lines (156 loc) · 9.42 KB
/
CoreModule-Customers-API.http
File metadata and controls
180 lines (156 loc) · 9.42 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
###############################################################################################
## CoreModule Module API Integration Tests ##
## ##
## This file exercises the full set of endpoints exposed by the CoreModule module ##
## ----------------------------------------------------------------------------------------- ##
## Endpoints covered: ##
## GET /api/coremodule/customers/{id} (Find one) ##
## GET /api/coremodule/customers (Find all / list) ##
## POST /api/coremodule/customers (Create) ##
## PUT /api/coremodule/customers/{id} (Update) ##
## PUT /api/coremodule/customers/{id}/status (Update status) ##
## DELETE /api/coremodule/customers/{id} (Delete) ##
## ##
## Variables: (see http-client.env.json) ##
## -customerId A seeded existing customer (read/update/delete scenarios) ##
## -concurrencyVersion The concurrency version of the existing customer ##
## ##
## ----------------------------------------------------------------------------------------- ##
## Use in Visual Studio:https://learn.microsoft.com/en-us/aspnet/core/test/http-files/ ##
## Use in VS Code: https://marketplace.visualstudio.com/items?itemName=humao.rest-client##
###############################################################################################
#############################################
### Resource Owner Password Flow
# @name login
POST {{baseUrl}}/api/_system/identity/connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=password
&client_id={{auth_client_id}}
&username={{auth_username}}
&password={{auth_password}}
&scope=openid profile email roles
###############################################################################################
### [GET] Customers - Find One ###
GET {{baseUrl}}/api/coremodule/customers/{{customerId}} HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
###############################################################################################
### [GET] Customers - Find All ###
GET {{baseUrl}}/api/coremodule/customers HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
###############################################################################################
### [GET] Customers - Find All filter ###
GET {{baseUrl}}/api/coremodule/customers?filter={"page":1,"pageSize":10,"filters":[{"field":"firstName","operator":"isnotnull"},{"field":"firstName","operator":"eq","value":"John"}]} HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
###############################################################################################
### [POST] Customers - Search All filter ###
POST {{baseUrl}}/api/coremodule/customers/search HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"page":1,
"pageSize":10,
"filters":[
{"field":"firstName","operator":"isnotnull"},{"field":"firstName","operator":"eq","value":"John"}]
}
###############################################################################################
### [POST] Customers - Create ###
POST {{baseUrl}}/api/coremodule/customers HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"firstName": "John{{$randomInt 1000 9999}}",
"lastName": "Doe{{$randomInt 1000 9999}}",
"email": "john.doe{{$randomInt 1000 9999}}@example.com",
"status": "Lead"
}
###############################################################################################
### [PUT] Customers - Update ###
PUT {{baseUrl}}/api/coremodule/customers/{{customerId}} HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"id": "{{customerId}}",
"firstName": "John{{$randomInt 1000 9999}}Changed",
"lastName": "Doe{{$randomInt 1000 9999}}Changed",
"email": "john.doe{{$randomInt 1000 9999}}changed@example.com",
"number": "CUS-2026-{{$randomInt 100000 999999}}",
"status": "Lead",
"concurrencyVersion": "{{concurrencyVersion}}"
}
###############################################################################################
### [PUT] Customers - Change Status -> Active ###
PUT {{baseUrl}}/api/coremodule/customers/{{customerId}}/status HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"status": "Active"
}
###############################################################################################
### [DELETE] Customers - Delete (Created) ###
### (Idempotent test - expect 204 first time, 404 if repeated) ###
DELETE {{baseUrl}}/api/coremodule/customers/{{customerId}} HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
###############################################################################################
### [POST] Customers - Create ###
### [NEGATIVE] Customers - Invalid first/lastname (empty) ###
### (Should return 400) ###
POST {{baseUrl}}/api/coremodule/customers HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"firstName": "",
"lastName": "",
"email": "john.doe{{$randomInt 1000 9999}}@example.com",
"status": "Lead"
}
###############################################################################################
### [PUT] Customers - Update ###
### [NEGATIVE] Customers - Update invalid concurrencyVersion (Random GUID) ###
### (Should return 409) ###
PUT {{baseUrl}}/api/coremodule/customers/{{customerId}} HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"id": "{{customerId}}",
"firstName": "John{{$randomInt 1000 9999}}Changed",
"lastName": "Doe{{$randomInt 1000 9999}}Changed",
"email": "john.doe{{$randomInt 1000 9999}}changed@example.com",
"number": "CUS-2026-{{$randomInt 100000 999999}}",
"status": "Lead",
"concurrencyVersion": "00000000-0000-0000-0000-000000000001"
}
###############################################################################################
### [GET] Customers - Find One ###
### [NEGATIVE] Customers - Get Not Found (Random GUID) ###
### (Should return 404) ###
GET {{baseUrl}}/api/coremodule/customers/00000000-0000-0000-0000-000000000001 HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
###############################################################################################
### [PUT] Customers - Update ###
### [NEGATIVE] Customers - Change invalid status ###
### (Should return 400) ###
PUT {{baseUrl}}/api/coremodule/customers/{{customerId}}/status HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
{
"status": "InvalidStatus"
}
###############################################################################################
### [DELETE] Customers - Delete ###
### [NEGATIVE] Customers - Not Found (Random GUID) ###
### (Should return 404) ###
DELETE {{baseUrl}}/api/coremodule/customers/00000000-0000-0000-0000-000000000001 HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json
###############################################################################################
### [DELETE] Customers - Delete ###
### [NEGATIVE] Customers - Not Found (Random GUID) ###
### (Should return 404) ###
DELETE {{baseUrl}}/api/coremodule/customers/exception HTTP/1.1
Authorization: Bearer {{login.response.body.$.access_token}}
Content-Type: application/json