Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from version1-workspace/develop
Develop
- Loading branch information
Showing
22 changed files
with
350 additions
and
44 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
|
||
NODE_ENV=test node_modules/.bin/jest --config ./test/jest-e2e.json --detectOpenHandles $@ | ||
|
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
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,105 @@ | ||
import { INestApplication } from '@nestjs/common'; | ||
import { prepareApp } from '../helper'; | ||
import request from '../helper/request'; | ||
|
||
describe('AuthController (e2e)', () => { | ||
let app: INestApplication; | ||
let server: any; | ||
|
||
beforeAll(async () => { | ||
app = await prepareApp([]); | ||
|
||
server = app?.getHttpServer(); | ||
return; | ||
}); | ||
|
||
describe('Post /auth/login', () => { | ||
const subject = () => request(server).post('/auth/login'); | ||
|
||
it(`with right auth info, return 200`, async () => { | ||
const response = await subject().send({ | ||
email: 'user.1@example.com', | ||
password: 'AndyBobCharrie', | ||
}); | ||
|
||
expect(response.status).toEqual(200); | ||
expect(response.body).toMatchObject({ | ||
data: { | ||
uuid: 'fa66f863-1040-48bd-a156-11bb7cce796e', | ||
accessToken: expect.any(String), | ||
refreshToken: expect.any(String), | ||
}, | ||
}); | ||
}); | ||
|
||
it(`with wrong mail address, return 401: 1`, async () => { | ||
const response = await subject().send({ | ||
email: 'wrong@example.com', | ||
password: 'AndyBobCharrie', | ||
}); | ||
|
||
expect(response.status).toEqual(401); | ||
}); | ||
|
||
it(`with wrong password, return 401: 2`, async () => { | ||
const response = await subject().send({ | ||
email: 'user.1@example.com', | ||
password: 'wrongpassword', | ||
}); | ||
|
||
expect(response.status).toEqual(401); | ||
}); | ||
}); | ||
|
||
describe('Post /auth/refresh', () => { | ||
const subject = () => request(server).post('/auth/refresh'); | ||
|
||
it(`with right refreshToken, return 200`, async () => { | ||
const client = request(server); | ||
const r1 = await client.post('/auth/login').send({ | ||
email: 'user.1@example.com', | ||
password: 'AndyBobCharrie', | ||
}); | ||
|
||
expect(r1.status).toEqual(200); | ||
const { uuid, refreshToken } = r1.body.data; | ||
|
||
const response = await client | ||
.post('/auth/refresh') | ||
.set('Cookie', `refreshToken=${refreshToken}`) | ||
.send({ | ||
uuid, | ||
}); | ||
expect(response.status).toEqual(200); | ||
expect(response.body).toMatchObject({ | ||
data: { | ||
uuid: 'fa66f863-1040-48bd-a156-11bb7cce796e', | ||
accessToken: expect.any(String), | ||
refreshToken: expect.any(String), | ||
}, | ||
}); | ||
expect(response.body.data.refreshToken).not.toEqual(refreshToken); | ||
}); | ||
|
||
it(`with wrong refreshToken, return 401: 1`, async () => { | ||
const uuid = 'fa66f863-1040-48bd-a156-11bb7cce796e'; | ||
const response = await subject().withAuth().send({ | ||
uuid, | ||
}); | ||
|
||
expect(response.status).toEqual(401); | ||
}); | ||
}); | ||
|
||
describe('Delete /auth/refresh', () => { | ||
const subject = () => request(server).delete('/auth/refresh'); | ||
it(`return 200`, async () => { | ||
const response = await subject(); | ||
expect(response.status).toEqual(200); | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
await app.close(); | ||
}); | ||
}); |
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
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,26 @@ | ||
import { Inter } from "next/font/google"; | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
|
||
import { Metadata } from "next"; | ||
import AuthContainer from "@/components/auth"; | ||
|
||
export const metadata: Metadata = { | ||
title: "Turbo", | ||
}; | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<AuthContainer isPublic> | ||
<html lang="ja"> | ||
<body className={inter.className}>{children}</body> | ||
</html> | ||
</AuthContainer> | ||
); | ||
} | ||
|
||
export const dynamic = "error"; |
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,5 +1,4 @@ | ||
.body { | ||
height: calc(100vh - 72px); | ||
} | ||
|
||
.main { | ||
|
Oops, something went wrong.