2023-10-06 23:32:28 +02:00
|
|
|
import { OAuthController } from '@app/immich';
|
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-19 00:02:42 +02:00
|
|
|
import { testApp } from '@test/test-utils';
|
2023-09-01 13:08:42 +02:00
|
|
|
import request from 'supertest';
|
|
|
|
|
|
|
|
describe(`${OAuthController.name} (e2e)`, () => {
|
|
|
|
let server: any;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
2023-10-19 00:02:42 +02:00
|
|
|
[server] = await testApp.create();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(async () => {
|
|
|
|
await testApp.teardown();
|
2023-09-01 13:08:42 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|