@@ -24,8 +24,7 @@ The goal of this project is to implement an application called `order-app` to ma
24
24
| ` GET /api/users ` | Yes | ` ADMIN ` |
25
25
| ` GET /api/users/{username} ` | Yes | ` ADMIN ` |
26
26
| ` DELETE /api/users/{username} ` | Yes | ` ADMIN ` |
27
- | ` GET /api/orders ` | Yes | ` ADMIN ` |
28
- | ` GET /api/orders/{id} ` | Yes | ` ADMIN ` , ` USER ` |
27
+ | ` GET /api/orders [?text] ` | Yes | ` ADMIN ` |
29
28
| ` POST /api/orders -d {"description"} ` | Yes | ` ADMIN ` , ` USER ` |
30
29
| ` DELETE /api/orders/{id} ` | Yes | ` ADMIN ` |
31
30
@@ -136,8 +135,10 @@ The gif below shows ...
136
135
```
137
136
Code: 200
138
137
{
139
- "id": "ccc4b36d-bda4-4f41-b6c2-f19c77f0243f",
140
- "description": "Buy two iPhones"
138
+ "id": "718c9f40-5c06-4571-bc3e-3f888c52eff2",
139
+ "description": "Buy two iPhones",
140
+ "user": { "username": "user" },
141
+ "createdAt": "..."
141
142
}
142
143
```
143
144
@@ -155,42 +156,41 @@ The gif below shows ...
155
156
2
156
157
```
157
158
158
- - Call `GET /api/orders/{id} ` without JWT access token
159
+ - Call `GET /api/orders` without JWT access token
159
160
```
160
- curl -i localhost:8080/api/orders/6ce8cdf5-004d-4511-a6a1-604945246af8
161
+ curl -i localhost:8080/api/orders
161
162
```
162
163
As for this endpoint a valid JWT access token is required, it should return
163
164
```
164
165
HTTP/1.1 401
165
166
```
166
167
167
- - Call `POST /auth/authenticate` to get `user ` JWT access token
168
+ - Call `POST /auth/authenticate` to get `admin ` JWT access token
168
169
```
169
- USER_ACCESS_TOKEN ="$(curl -s -X POST http://localhost:8080/auth/login \
170
+ ADMIN_ACCESS_TOKEN ="$(curl -s -X POST http://localhost:8080/auth/authenticate \
170
171
-H 'Content-Type: application/json' \
171
- -d '{"username": "user ", "password": "user "}' | jq -r .accessToken)"
172
+ -d '{"username": "admin ", "password": "admin "}' | jq -r .accessToken)"
172
173
```
173
174
174
- - Call again `GET /api/orders/{id} `, now with `user ` JWT access token
175
+ - Call again `GET /api/orders`, now with `admin ` JWT access token
175
176
```
176
- curl -i -H "Authorization: Bearer $USER_ACCESS_TOKEN " localhost:8080/api/orders/6ce8cdf5-004d-4511-a6a1-604945246af8
177
+ curl -i -H "Authorization: Bearer $ADMIN_ACCESS_TOKEN " localhost:8080/api/orders
177
178
```
178
- It should return
179
+ It should return an empty array or an array with orders
179
180
```
180
181
HTTP/1.1 200
181
- { "id":"6ce8cdf5-004d-4511-a6a1-604945246af8", "description":"Buy one MacBook Pro" }
182
+ [ ... ]
182
183
```
183
184
184
- - Call `GET /api/users/me` to get more information about the `user `
185
+ - Call `GET /api/users/me` to get more information about the `admin `
185
186
```
186
- curl -i -H "Authorization: Bearer $USER_ACCESS_TOKEN " localhost:8080/api/users/me
187
+ curl -i -H "Authorization: Bearer $ADMIN_ACCESS_TOKEN " localhost:8080/api/users/me
187
188
```
188
189
It should return
189
190
```
190
191
HTTP/1.1 200
191
- {
192
- "id": 2, "username": "user", "name": "User", "email": "[email protected] ", "role": "USER",
193
- "orders": [ ... ]
192
+ { "id": 1, "username": "admin", "name": "Admin", "email": "[email protected] ", "role": "ADMIN",
193
+ "orders": []
194
194
}
195
195
```
196
196
@@ -234,7 +234,6 @@ The gif below shows ...
234
234
......................... + ............. + ........... + ............ |
235
235
GET /api/orders | 401 | 403 | 200 |
236
236
POST /api/orders | 401 | 201 | 201 |
237
- GET /api/orders/{id} | 401 | 200 | 200 |
238
237
DELETE /api/orders/{id} | 401 | 403 | 200 |
239
238
------------------------------------------------------------------------
240
239
[200] Success - [201] Created - [401] Unauthorized - [403] Forbidden
0 commit comments