-
Notifications
You must be signed in to change notification settings - Fork 15
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
87 changed files
with
515 additions
and
376 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export { loginHandler } from './loginHandler' | ||
export { registerHandler, mockRegisterId } from './registerHandler' | ||
export { validateTokenHandler } from './validateTokenHandler' | ||
export { getUserHandler } from './getUserHandler' | ||
export { patchUserHandler } from './patchUserHandler' | ||
export { getUsersNameByIdHandler } from './getUsersNameByIdHandler' | ||
export { getItinerariesHandler } from './getItinerariesHandler' | ||
export { getMeUsersHandler as getUserHandler } from './getMeUsersHandler' | ||
export { updateUserHandler } from './updateUserHandler' | ||
export { listUsersHandler as getUsersNameByIdHandler } from './listUsersHandler' | ||
export { listItinerariesHandler } from './listItinerariesHandler' |
4 changes: 2 additions & 2 deletions
4
...ocks/ssoHandlers/getItinerariesHandler.ts → ...cks/ssoHandlers/listItinerariesHandler.ts
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 was deleted.
Oops, something went wrong.
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,56 @@ | ||
import { http, HttpResponse } from 'msw' | ||
import { TSsoPatchUserRequest } from '../../../schemas/sso' | ||
import { authToken } from './authToken' | ||
import { testUserData } from '../../globalSetup' | ||
import { UserRole, UserStatus } from '../../../schemas/users/userSchema' | ||
|
||
type UpdateUserResponse = { message: string } | ||
export const updateUserHandler = http.patch( | ||
'http://localhost:8000/api/v1/users/:id', | ||
async ({ request, params }) => { | ||
const sampleUser = { | ||
id: 'jvrbkpeq9v6l4l23rt0u00w9', | ||
email: '[email protected]', | ||
name: 'sampleUser', | ||
dni: '00000000R', | ||
password: 'testingPswd1', | ||
role: UserRole.REGISTERED, | ||
status: UserStatus.ACTIVE, | ||
avatarId: null, | ||
} | ||
const updatedUserData = { ...testUserData, sampleUser } | ||
const { id } = params | ||
const { authToken: token } = (await request.json()) as TSsoPatchUserRequest | ||
const isValidToken = Object.values(authToken).includes(token) | ||
if (!isValidToken) { | ||
return HttpResponse.json( | ||
{ | ||
message: 'Invalid Credentials', | ||
} as UpdateUserResponse, | ||
{ status: 401 } | ||
) | ||
} | ||
const user = Object.values(updatedUserData).find((u) => u.id === id) | ||
if (!user) { | ||
return HttpResponse.json( | ||
{ | ||
message: 'User not found', | ||
}, | ||
{ status: 404 } | ||
) | ||
} | ||
const userType = Object.keys(authToken).find( | ||
(key) => authToken[key] === token | ||
) | ||
if (!userType) { | ||
return HttpResponse.json( | ||
{ | ||
message: 'Invalid Credentials', | ||
} as UpdateUserResponse, | ||
{ status: 401 } | ||
) | ||
} | ||
|
||
return new HttpResponse(null, { status: 204 }) | ||
} | ||
) |
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
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,8 @@ | ||
import Koa, { Middleware } from 'koa' | ||
import { ssoHandler } from '../../helpers' | ||
|
||
export const listItineraries: Middleware = async (ctx: Koa.Context) => { | ||
const data = await ssoHandler.listItineraries() | ||
ctx.status = 200 | ||
ctx.body = data | ||
} |
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
export { getItineraries } from './getItineraries' | ||
export { getUser } from './getUser' | ||
export { listItineraries } from './listItineraries' | ||
export { getMeUsers } from './getMeUsers' | ||
export { login } from './login' | ||
export { pathSso } from './pathSso' | ||
export { register } from './register' | ||
export { validate } from './validate' | ||
export { patchUser } from './patchUser' | ||
export { getUsersNameById } from './getUsersNameById' | ||
export { updateUser } from './updateUser' | ||
export { listUsers } from './listUsers' |
Oops, something went wrong.