-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapi-test2.http
More file actions
474 lines (389 loc) · 15.5 KB
/
api-test2.http
File metadata and controls
474 lines (389 loc) · 15.5 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
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
### ========================================
### ========================================
### 🎯 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) + "...");
%}
### 1-2. [Auth] DB에 Refresh Token 저장 확인 (디버깅용)
GET {{auth_host}}/debug/tokens
> {%
client.test("Refresh Token이 DB에 저장됨", function() {
client.assert(response.body.length > 0, "Refresh Token이 DB에 존재해야 함");
});
client.log("✅ DB에 Refresh Token 저장 확인");
%}
### ========================================
### 📌 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. [Auth] DB에서 Refresh Token 삭제 확인
GET {{auth_host}}/debug/tokens
> {%
client.test("Refresh Token 삭제 확인", function() {
// 탈퇴한 회원의 토큰이 없어야 함
let memberTokenExists = response.body.some(token =>
token.memberId === client.global.get("member_id")
);
client.assert(memberTokenExists === false, "탈퇴한 회원의 Refresh Token이 삭제되어야 함");
});
client.log("✅ Refresh Token 삭제 확인");
%}
### 9-4. [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("모든 테스트 완료! 🎉");
%}