Skip to content

Commit ff21db6

Browse files
committed
✅ test: session id 테스트 코드 추가
1 parent d69d495 commit ff21db6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

server/test/admin/e2e/session-id.e2e-spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ describe(`GET ${URL} E2E Test`, () => {
1313
let app: INestApplication;
1414
let agent: TestAgent;
1515
let admin: Admin;
16+
let redisService: RedisService;
1617
const sessionKey = 'admin-session-check-key';
1718
const redisKeyMake = (data: string) => `${REDIS_KEYS.ADMIN_AUTH_KEY}:${data}`;
1819

1920
beforeAll(async () => {
2021
app = global.testApp;
2122
agent = supertest(app.getHttpServer());
23+
redisService = app.get(RedisService);
2224
const adminRepository = app.get(AdminRepository);
23-
const redisService = app.get(RedisService);
2425

2526
admin = await adminRepository.save(
2627
await AdminFixture.createAdminCryptFixture(),
@@ -36,6 +37,12 @@ describe(`GET ${URL} E2E Test`, () => {
3637
const { data } = response.body;
3738
expect(response.status).toBe(HttpStatus.UNAUTHORIZED);
3839
expect(data).toBeUndefined();
40+
41+
// DB, Redis when
42+
const savedSession = await redisService.get(redisKeyMake(sessionKey));
43+
44+
// DB, Redis then
45+
expect(savedSession).not.toBeNull();
3946
});
4047

4148
it('[401] 관리자 로그인 쿠키가 만료됐을 경우 관리자 자동 로그인을 실패한다.', async () => {
@@ -48,6 +55,12 @@ describe(`GET ${URL} E2E Test`, () => {
4855
const { data } = response.body;
4956
expect(response.status).toBe(HttpStatus.UNAUTHORIZED);
5057
expect(data).toBeUndefined();
58+
59+
// DB, Redis when
60+
const savedSession = await redisService.get(redisKeyMake(sessionKey));
61+
62+
// DB, Redis then
63+
expect(savedSession).not.toBeNull();
5164
});
5265

5366
it('[200] 관리자 로그인 쿠키가 존재할 경우 관리자 자동 로그인을 성공한다.', async () => {
@@ -60,5 +73,11 @@ describe(`GET ${URL} E2E Test`, () => {
6073
const { data } = response.body;
6174
expect(response.status).toBe(HttpStatus.OK);
6275
expect(data).toBeUndefined();
76+
77+
// DB, Redis when
78+
const savedSession = await redisService.get(redisKeyMake(sessionKey));
79+
80+
// DB, Redis then
81+
expect(savedSession).not.toBeNull();
6382
});
6483
});

0 commit comments

Comments
 (0)