Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] Auth E2E 테스트 작성 #389

Merged
merged 14 commits into from
Feb 13, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: auth e2e 테스트 초기 세팅 #382
  • Loading branch information
HyoJongPark committed Feb 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 58609ca9ad9e835883d69afd75de209737939a36
48 changes: 48 additions & 0 deletions backend/test/auth/auth.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as request from 'supertest';
import { ExecutionContext, INestApplication } from '@nestjs/common';
import { Test } from '@nestjs/testing';
import { AppModule } from 'src/app.module';
import { JwtAuthGuard } from 'src/auth/guards/jwtAuth.guard';
import { ImagesRepository } from 'src/images/images.repository';

describe('ImagesController (e2e)', () => {
let app: INestApplication;
let imagesRepository: ImagesRepository;
const user = { id: 1, nickname: 'testUser' };

beforeAll(async () => {
const module = await Test.createTestingModule({
imports: [AppModule],
})
.overrideGuard(JwtAuthGuard)
.useValue({
canActivate: (context: ExecutionContext) => {
const req = context.switchToHttp().getRequest();
req.user = user;

return true;
},
})
.compile();

imagesRepository = module.get<ImagesRepository>(ImagesRepository);
app = module.createNestApplication();
await app.init();
});

afterAll(async () => {
await app.close();
});

describe('/login (POST)', () => {
HyoJongPark marked this conversation as resolved.
Show resolved Hide resolved
//TODO: 회원가입 정보가 존재하면, 로그인
//TODO: 회원가입 정보가 존재하지 않으면, 회원가입 후 로그인
//TODO: 잘못된 access 요청 시 401
/**
* access까지 요청해야함.
* -> 이전에 fetch api로 거기까지 요청 보내는 것을 구현
* -> response에서 꺼내서 사용하기
* -> 로그인과 권한 동의를 어떻게 시킬 것인지...?
*/
});
});
49 changes: 0 additions & 49 deletions backend/test/tags/app.e2e-spec.ts

This file was deleted.