2023-10-06 23:32:28 +02:00
|
|
|
import { OAuthController } from '@app/immich';
|
2023-09-01 13:08:42 +02:00
|
|
|
import { INestApplication } from '@nestjs/common';
|
2023-09-11 17:56:38 +02:00
|
|
|
import { api } from '@test/api';
|
|
|
|
import { db } from '@test/db';
|
|
|
|
import { errorStub } from '@test/fixtures';
|
2023-10-06 23:32:28 +02:00
|
|
|
import { createTestApp } from '@test/test-utils';
|
2023-09-01 13:08:42 +02:00
|
|
|
import request from 'supertest';
|
|
|
|
|
|
|
|
describe(`${OAuthController.name} (e2e)`, () => {
|
|
|
|
let app: INestApplication;
|
|
|
|
let server: any;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2023-10-06 23:32:28 +02:00
|
|
|
app = await createTestApp();
|
2023-09-01 13:08:42 +02:00
|
|
|
server = app.getHttpServer();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
await db.reset();
|
2023-09-11 17:56:38 +02:00
|
|
|
await api.authApi.adminSignUp(server);
|
2023-09-01 13:08:42 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await db.disconnect();
|
|
|
|
await app.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('POST /oauth/authorize', () => {
|
|
|
|
beforeEach(async () => {
|
|
|
|
await db.reset();
|
|
|
|
});
|
|
|
|
|
|
|
|
it(`should throw an error if a redirect uri is not provided`, async () => {
|
|
|
|
const { status, body } = await request(server).post('/oauth/authorize').send({});
|
|
|
|
expect(status).toBe(400);
|
2023-09-20 13:16:33 +02:00
|
|
|
expect(body).toEqual(errorStub.badRequest(['redirectUri must be a string', 'redirectUri should not be empty']));
|
2023-09-01 13:08:42 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|