-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import userServiceHandler from '@mocks/services/userServiceHandler'; | ||
import teamServiceHandler from '@mocks/services/teamServiceHandler'; | ||
import projectServiceHandler from '@mocks/services/projectServiceHandler'; | ||
import authServiceHandler from './services/authServiceHandler'; | ||
|
||
const handlers = [...userServiceHandler, ...teamServiceHandler, ...projectServiceHandler]; | ||
const handlers = [...userServiceHandler, ...teamServiceHandler, ...projectServiceHandler, ...authServiceHandler]; | ||
|
||
export default handlers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { http, HttpResponse } from 'msw'; | ||
|
||
const BASE_URL = import.meta.env.VITE_BASE_URL; | ||
|
||
type LoginRequestBody = { | ||
username: string; | ||
password: string; | ||
}; | ||
const authServiceHandler = [ | ||
// 로그인 API | ||
http.post(`${BASE_URL}/user/login`, async ({ request }) => { | ||
const { username, password } = (await request.json()) as LoginRequestBody; | ||
|
||
if (username === 'test' && password === 'test@123') { | ||
const accessToken = 'mockedAccessToken'; | ||
const refreshToken = 'mockedRefreshToken'; | ||
|
||
return HttpResponse.json( | ||
{ accessToken }, | ||
{ | ||
status: 200, | ||
headers: { | ||
'Set-Cookie': `refreshToken=${refreshToken}; HttpOnly; Secure; SameSite=Strict; Path=/;`, | ||
}, | ||
}, | ||
); | ||
} | ||
return new HttpResponse(JSON.stringify({ message: '아이디 또는 비밀번호가 잘못되었습니다.' }), { status: 400 }); | ||
}), | ||
]; | ||
|
||
export default authServiceHandler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters