feat: add tbank tokens
This commit is contained in:
@@ -27,6 +27,7 @@ describe('Authentication (e2e)', () => {
|
||||
app.useGlobalFilters(new HttpExceptionFilter());
|
||||
await app.init();
|
||||
await app.get(PrismaService).session.deleteMany();
|
||||
await app.get(PrismaService).tbankConnection.deleteMany();
|
||||
await app.get(PrismaService).user.deleteMany();
|
||||
});
|
||||
|
||||
@@ -82,4 +83,23 @@ describe('Authentication (e2e)', () => {
|
||||
expect((body as Problem).code).toBe('INVALID_CREDENTIALS'),
|
||||
);
|
||||
});
|
||||
|
||||
it('guards T-Bank connection and never returns a token', async () => {
|
||||
const registration = await request(app.getHttpServer())
|
||||
.post('/api/v1/auth/register')
|
||||
.send({ email: 'connection@example.com', password: 'a secure password' })
|
||||
.expect(201);
|
||||
const accessToken = (registration.body as Authentication).accessToken;
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.get('/api/v1/tbank-connection')
|
||||
.expect(401);
|
||||
await request(app.getHttpServer())
|
||||
.get('/api/v1/tbank-connection')
|
||||
.set('Authorization', `Bearer ${accessToken}`)
|
||||
.expect(200)
|
||||
.expect(({ body }: { body: unknown }) =>
|
||||
expect(body).toEqual({ connected: false, connectedAt: null }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
process.env.DATABASE_URL = 'file:/tmp/wealth-ledger-e2e.db';
|
||||
process.env.FRONTEND_ORIGIN = 'http://localhost:5173';
|
||||
process.env.JWT_SECRET = 'e2e-secret-that-is-at-least-thirty-two-characters';
|
||||
process.env.TOKEN_ENCRYPTION_KEY = 'MDEyMzQ1Njc4OWFiY2RlZjAxMjM0NTY3ODlhYmNkZWY=';
|
||||
|
||||
Reference in New Issue
Block a user