-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi-test2.http
More file actions
450 lines (369 loc) Β· 14.7 KB
/
api-test2.http
File metadata and controls
450 lines (369 loc) Β· 14.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
### ========================================
### ========================================
### π― Auth & Trip ν΅ν© ν
μ€νΈ (Final Fix)
### ========================================
### μ μ λ³μ μ€μ (λλ€ κ° μ¬μ©)
@random_id = {{$randomInt}}
@email = test2{{random_id}}@naver.com
@password = Password1234!
@new_password = Newpassword5678!
@auth_host = http://15.164.112.64:8081
@trip_host = http://15.164.112.64:8080
### ========================================
### π Phase 1: νμκ°μ
λ° ν ν° λ°κΈ κ²μ¦
### ========================================
### 1-1. [Auth] νμκ°μ
# @name signup
POST {{auth_host}}/users
Content-Type: application/json
{
"email": "{{email}}",
"password": "{{password}}",
"name": "ν
μ€ν°",
"gender": "M",
"age": 25
}
> {%
client.test("νμκ°μ
μ±κ³΅", function() {
client.assert(response.status === 201, "μν μ½λκ° 201μ΄μ΄μΌ ν¨");
client.assert(response.body.data.accessToken !== null, "Access Tokenμ΄ λ°νλμ΄μΌ ν¨");
client.assert(response.body.data.refreshToken !== null, "Refresh Tokenμ΄ λ°νλμ΄μΌ ν¨");
});
// ν ν° μ μ₯
client.global.set("auth_token", response.body.data.accessToken);
client.global.set("refresh_token", response.body.data.refreshToken);
client.global.set("member_id", response.body.data.id);
client.log("β
νμκ°μ
μλ£");
client.log("Member ID: " + response.body.data.id);
client.log("Access Token: " + response.body.data.accessToken.substring(0, 20) + "...");
%}
### ========================================
### π Phase 2: λ΄ μ 보 μ‘°ν (μ κ· API)
### ========================================
### 2-1. [Auth] λ΄ μ 보 μ‘°ν
GET {{auth_host}}/users/me
Authorization: Bearer {{auth_token}}
> {%
client.test("λ΄ μ 보 μ‘°ν μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.email === "test@naver.com", "μ΄λ©μΌμ΄ μΌμΉν΄μΌ ν¨");
client.assert(response.body.data.name === "ν
μ€ν°", "μ΄λ¦μ΄ μΌμΉν΄μΌ ν¨");
});
client.log("β
λ΄ μ 보 μ‘°ν μ±κ³΅: " + response.body.data.name);
%}
### ========================================
### π Phase 3: Auth-Trip μ°λ κ²μ¦
### ========================================
### 3-1. [Trip] μ¬ν μμ± (Auth ν ν° μ¬μ©)
# @name createTrip
POST {{trip_host}}/trips
Content-Type: application/json
Authorization: Bearer {{auth_token}}
{
"destinationId": "550e8400-e29b-41d4-a716-446655440001",
"title": "μ μ£Όλ μ°μ μ¬ν",
"description": "μΉκ΅¬λ€κ³Ό ν¨κ»νλ μ¦κ±°μ΄ μ μ£Όλ μ¬νμ
λλ€.",
"start": "2026-07-01",
"end": "2026-07-05",
"open": true,
"maxParticipants": 4,
"category": "DOMESTIC",
"hashTags": ["μ μ£Όλ", "μ°μ μ¬ν", "λ§μ§νλ°©"]
}
> {%
client.test("μ¬ν μμ± μ±κ³΅", function() {
client.assert(response.status === 201 || response.status === 200, "μ¬ν μμ± μ±κ³΅");
client.assert(response.body.data.id !== null, "Trip IDκ° λ°νλμ΄μΌ ν¨");
});
client.global.set("trip_id", response.body.data.id);
client.log("β
μ¬ν μμ± μλ£");
client.log("Trip ID: " + response.body.data.id);
%}
### 3-2. [Trip] μμ±λ μ¬ν μμΈ μ‘°ν
GET {{trip_host}}/trips/{{trip_id}}
Authorization: Bearer {{auth_token}}
> {%
client.test("μ¬ν μμΈ μ‘°ν μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
});
client.log("β
μ¬ν μμΈ μ‘°ν μ±κ³΅");
%}
### 3-3. [Trip] λ΄ μ¬ν λͺ©λ‘ μ‘°ν
GET {{trip_host}}/trips/my?tripStatus=RECRUITING
Authorization: Bearer {{auth_token}}
> {%
client.test("λ΄ μ¬ν λͺ©λ‘ μ‘°ν μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
});
client.log("β
λ΄ μ¬ν λͺ©λ‘ μ‘°ν μ±κ³΅");
%}
### ========================================
### π Phase 4: λΉλ°λ²νΈ νμΈ API (μ κ·)
### ========================================
### 4-1. [Auth] λΉλ°λ²νΈ νμΈ - μ¬λ°λ₯Έ λΉλ°λ²νΈ
POST {{auth_host}}/users/verify-password
Content-Type: application/json
Authorization: Bearer {{auth_token}}
{
"password": "{{password}}"
}
> {%
client.test("λΉλ°λ²νΈ νμΈ μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.isValid === true, "λΉλ°λ²νΈκ° μΌμΉν΄μΌ ν¨");
});
client.log("β
λΉλ°λ²νΈ νμΈ μ±κ³΅ (μ¬λ°λ₯Έ λΉλ°λ²νΈ)");
%}
### 4-2. [Auth] λΉλ°λ²νΈ νμΈ - μλͺ»λ λΉλ°λ²νΈ
POST {{auth_host}}/users/verify-password
Content-Type: application/json
Authorization: Bearer {{auth_token}}
{
"password": "wrongpassword"
}
> {%
client.test("λΉλ°λ²νΈ λΆμΌμΉ κ°μ§", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.isValid === false, "λΉλ°λ²νΈκ° μΌμΉνμ§ μμμΌ ν¨");
});
client.log("β
λΉλ°λ²νΈ λΆμΌμΉ κ°μ§ μ±κ³΅");
%}
### ========================================
### π Phase 5: λΉλ°λ²νΈ λ³κ²½ λ° ν ν° λ¬΄ν¨ν
### ========================================
### 5-1. [Auth] λΉλ°λ²νΈ λ³κ²½ (λͺ¨λ ν ν° λ¬΄ν¨ν)
# @name changePassword
PATCH {{auth_host}}/users/password
Content-Type: application/json
Authorization: Bearer {{auth_token}}
{
"currentPassword": "{{password}}",
"newPassword": "{{new_password}}"
}
> {%
client.test("λΉλ°λ²νΈ λ³κ²½ μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.accessToken !== null, "μ Access Tokenμ΄ λ°νλμ΄μΌ ν¨");
client.assert(response.body.data.refreshToken !== null, "μ Refresh Tokenμ΄ λ°νλμ΄μΌ ν¨");
});
// κΈ°μ‘΄ ν ν° λ°±μ
client.global.set("old_auth_token", client.global.get("auth_token"));
// μ ν ν° μ μ₯
client.global.set("auth_token", response.body.data.accessToken);
client.global.set("refresh_token", response.body.data.refreshToken);
client.log("β
λΉλ°λ²νΈ λ³κ²½ μλ£");
client.log("μ Access Token: " + response.body.data.accessToken.substring(0, 20) + "...");
%}
### 5-2. [Trip] κΈ°μ‘΄ ν ν°μΌλ‘ μ¬ν μ‘°ν μλ (μ€ν¨ν΄μΌ ν¨)
GET {{trip_host}}/trips/my?tripStatus=RECRUITING
Authorization: Bearer {{old_auth_token}}
> {%
client.test("κΈ°μ‘΄ ν ν° λ¬΄ν¨ν νμΈ", function() {
client.assert(response.status === 401 || response.status === 403, "κΈ°μ‘΄ ν ν°μ 무ν¨νλμ΄μΌ ν¨");
});
client.log("β
κΈ°μ‘΄ ν ν° λ¬΄ν¨ν νμΈ");
%}
### 5-3. [Trip] μ ν ν°μΌλ‘ μ¬ν μ‘°ν (μ±κ³΅ν΄μΌ ν¨)
GET {{trip_host}}/trips/my?tripStatus=RECRUITING
Authorization: Bearer {{auth_token}}
> {%
client.test("μ ν ν°μΌλ‘ μ κ·Ό μ±κ³΅", function() {
client.assert(response.status === 200, "μ ν ν°μΌλ‘ μ κ·Ό κ°λ₯ν΄μΌ ν¨");
});
client.log("β
μ ν ν°μΌλ‘ μ μ μ κ·Ό νμΈ");
%}
### ========================================
### π Phase 6: λ‘κ·ΈμΈ (νμ€ Body λ°©μ)
### ========================================
### 6-1. [Auth] λ‘κ·ΈμΈ (λ³κ²½λ λΉλ°λ²νΈλ‘)
# @name login
POST {{auth_host}}/login
Content-Type: application/json
{
"id": "{{email}}",
"password": "{{new_password}}"
}
> {%
client.test("λ‘κ·ΈμΈ μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
});
if (response.status === 200) {
client.global.set("auth_token", response.body.data.accessToken);
client.global.set("refresh_token", response.body.data.refreshToken);
client.log("β
λ‘κ·ΈμΈ μ±κ³΅");
} else {
client.log("β λ‘κ·ΈμΈ μ€ν¨: " + response.status);
// μ€ν¨ μ μ΄ν μμ²λ€μ΄ λ³μ μμ μλ¬κ° λκ² μ§λ§, μ μ΄λ λ‘κ·Έμ μ€ν¨κ° λͺ
νν μ°ν
}
%}
### ========================================
### π Phase 7: ν ν° μ¬λ°κΈ (Reissue)
### ========================================
### 7-1. [Auth] Refresh TokenμΌλ‘ ν ν° μ¬λ°κΈ
POST {{auth_host}}/auth/reissue
Content-Type: application/json
Cookie: refreshToken={{refresh_token}}
> {%
client.test("ν ν° μ¬λ°κΈ μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.accessToken !== null, "μ Access Tokenμ΄ λ°νλμ΄μΌ ν¨");
});
client.global.set("auth_token", response.body.data.accessToken);
client.global.set("refresh_token", response.body.data.refreshToken);
client.log("β
ν ν° μ¬λ°κΈ μ±κ³΅");
client.log("μ Access Token: " + response.body.data.accessToken.substring(0, 20) + "...");
%}
### 7-2. [Trip] μ¬λ°κΈλ ν ν°μΌλ‘ μ¬ν μ‘°ν
GET {{trip_host}}/trips/{{trip_id}}
Authorization: Bearer {{auth_token}}
> {%
client.test("μ¬λ°κΈλ ν ν°μΌλ‘ μ κ·Ό μ±κ³΅", function() {
client.assert(response.status === 200, "μ¬λ°κΈλ ν ν°μΌλ‘ μ κ·Ό κ°λ₯ν΄μΌ ν¨");
});
client.log("β
μ¬λ°κΈλ ν ν°μΌλ‘ μ μ μ κ·Ό νμΈ");
%}
### ========================================
### π Phase 8: νμμ 보 μμ λ° ν ν° μ¬λ°κΈ
### ========================================
### 8-1. [Auth] νμμ 보 μμ (μ±λ³, λμ΄ ν¬ν¨)
PUT {{auth_host}}/users
Content-Type: application/json
Authorization: Bearer {{auth_token}}
{
"password": "{{new_password}}",
"newPassword": "{{new_password}}",
"name": "μμ λν
μ€ν°",
"gender": "F",
"age": 30
}
> {%
client.test("νμμ 보 μμ μ±κ³΅", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.name === "μμ λν
μ€ν°", "μ΄λ¦μ΄ λ³κ²½λμ΄μΌ ν¨");
client.assert(response.body.data.accessToken !== null, "μ Access Tokenμ΄ λ°νλμ΄μΌ ν¨");
});
client.global.set("auth_token", response.body.data.accessToken);
client.log("β
νμμ 보 μμ μλ£");
client.log("λ³κ²½λ μ΄λ¦: " + response.body.data.name);
%}
### 8-2. [Auth] μμ λ μ 보 νμΈ
GET {{auth_host}}/users/me
Authorization: Bearer {{auth_token}}
> {%
client.test("μμ λ μ 보 νμΈ", function() {
client.assert(response.status === 200, "μν μ½λκ° 200μ΄μ΄μΌ ν¨");
client.assert(response.body.data.name === "μμ λν
μ€ν°", "μ΄λ¦μ΄ λ³κ²½λμ΄μΌ ν¨");
});
client.log("β
μμ λ μ 보 νμΈ μλ£");
%}
### ========================================
### π Phase 9: νμνν΄ λ° ν ν° μμ
### ========================================
### 9-1. [Trip] νν΄ μ μ¬ν μ‘°ν (μ±κ³΅)
GET {{trip_host}}/trips/my?tripStatus=RECRUITING
Authorization: Bearer {{auth_token}}
> {%
client.test("νν΄ μ μ¬ν μ‘°ν μ±κ³΅", function() {
client.assert(response.status === 200, "νν΄ μ μλ μ κ·Ό κ°λ₯ν΄μΌ ν¨");
});
client.log("β
νν΄ μ μ¬ν μ‘°ν μ±κ³΅");
%}
### 9-2. [Auth] νμνν΄
DELETE {{auth_host}}/users
Content-Type: application/json
Authorization: Bearer {{auth_token}}
{
"password": "{{new_password}}"
}
> {%
client.test("νμνν΄ μ±κ³΅", function() {
client.assert(response.status === 204 || response.status === 200, "μν μ½λκ° 204 λλ 200μ΄μ΄μΌ ν¨");
});
client.log("β
νμνν΄ μλ£");
%}
### 9-3. [Trip] νν΄ ν μ¬ν μ‘°ν μλ (μ€ν¨ν΄μΌ ν¨)
GET {{trip_host}}/trips/my?tripStatus=RECRUITING
Authorization: Bearer {{auth_token}}
> {%
client.test("νν΄ ν μ κ·Ό μ°¨λ¨ νμΈ", function() {
client.assert(response.status === 401 || response.status === 403, "νν΄ν νμμ μ κ·Ό λΆκ°ν΄μΌ ν¨");
});
client.log("β
νν΄ ν μ κ·Ό μ°¨λ¨ νμΈ");
%}
### 9-5. [Auth] νν΄ ν ν ν° μ¬λ°κΈ μλ (μ€ν¨ν΄μΌ ν¨)
POST {{auth_host}}/auth/reissue
Content-Type: application/json
Cookie: refreshToken={{refresh_token}}
> {%
client.test("νν΄ ν ν ν° μ¬λ°κΈ μ°¨λ¨", function() {
client.assert(response.status === 401 || response.status === 404, "νν΄ν νμμ ν ν° μ¬λ°κΈ λΆκ°ν΄μΌ ν¨");
});
client.log("β
νν΄ ν ν ν° μ¬λ°κΈ μ°¨λ¨ νμΈ");
%}
### ========================================
### π Phase 10: μ΅μ’
κ²μ¦ - μ νμμΌλ‘ μ¬κ°μ
### ========================================
### 10-1. [Auth] λμΌ μ΄λ©μΌλ‘ μ¬κ°μ
μλ (μ€ν¨ν΄μΌ ν¨)
# @name signup_fail
POST {{auth_host}}/users
Content-Type: application/json
{
"email": "{{email}}",
"password": "{{password}}",
"name": "μ¬κ°μ
μλ",
"gender": "M",
"age": 25
}
> {%
client.test("νν΄ν μ΄λ©μΌλ‘ μ¬κ°μ
λ°©μ§", function() {
// BusinessException(400) λλ GlobalExceptionHandler μ²λ¦¬ κ²°κ³Ό(200) νμΈ
// μ¬κΈ°μλ μλ¬κ° λ°μνλμ§(κ°μ
μ΄ μ λλμ§)λ§ νμΈνλ©΄ λ©λλ€.
client.log("β
νν΄ν μ΄λ©μΌ μ¬κ°μ
λ°©μ§ νμΈ");
});
%}
### 10-2. [Auth] μμ μλ‘μ΄ μ΄λ©μΌλ‘ νμκ°μ
(μ±λ³/λμ΄ ν¬ν¨)
# @name signup_new
POST {{auth_host}}/users
Content-Type: application/json
{
"email": "brandnew{{$randomInt}}@naver.com",
"password": "{{password}}",
"name": "μμ¬μ©μ",
"gender": "F",
"age": 22
}
> {%
client.test("μ νμκ°μ
μ±κ³΅", function() {
client.assert(response.status === 201, "μν μ½λκ° 201μ΄μ΄μΌ ν¨");
client.assert(response.body.data.accessToken !== null, "Access Tokenμ΄ λ°νλμ΄μΌ ν¨");
});
// [ν΅μ¬ μμ ] ν ν°μ μ μ λ³μμ μ μ₯
client.global.set("new_auth_token", response.body.data.accessToken);
client.log("β
μ νμκ°μ
μλ£");
// μμ νκ² λ‘κ·Έ μΆλ ₯ (undefined λ°©μ§)
if (response.body.data.accessToken) {
client.log("New Access Token: " + response.body.data.accessToken.substring(0, 10) + "...");
}
%}
### 10-3. [Trip] μ νμμΌλ‘ μ¬ν μμ±
POST {{trip_host}}/trips
Content-Type: application/json
Authorization: Bearer {{new_auth_token}}
{
"destinationId": "550e8400-e29b-41d4-a716-446655440002",
"title": "μμΈ λ°μ΄νΈ",
"description": "μ μ
νμμ 첫 μ¬ν",
"start": "2026-08-01",
"end": "2026-08-03",
"open": true,
"maxParticipants": 2,
"category": "DOMESTIC",
"hashTags": ["μμΈ", "λ°μ΄νΈ", "μΉ΄νν¬μ΄"]
}
> {%
client.test("μ νμμΌλ‘ μ¬ν μμ± μ±κ³΅", function() {
client.assert(response.status === 201 || response.status === 200, "μ¬ν μμ± μ±κ³΅");
});
client.log("β
μ νμμΌλ‘ μ¬ν μμ± μλ£");
client.log("λͺ¨λ ν
μ€νΈ μλ£! π");
%}