|
@@ -39,10 +39,32 @@ describe('Auth (e2e)', () => {
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ it('/api/v1/auth/stylist/login (POST) returns a token payload with username', async () => {
|
|
|
|
|
+ const response = await request(app.getHttpServer())
|
|
|
|
|
+ .post('/api/v1/auth/stylist/login')
|
|
|
|
|
+ .send({
|
|
|
|
|
+ email: 'stylist@example.com',
|
|
|
|
|
+ password: 'Passw0rd!',
|
|
|
|
|
+ remember: false,
|
|
|
|
|
+ })
|
|
|
|
|
+ .expect(201);
|
|
|
|
|
+
|
|
|
|
|
+ const payload = await jwtService.verifyAsync<{
|
|
|
|
|
+ sub: number;
|
|
|
|
|
+ email: string;
|
|
|
|
|
+ username: string;
|
|
|
|
|
+ }>(response.body.data.token);
|
|
|
|
|
+
|
|
|
|
|
+ expect(payload.sub).toBe(1);
|
|
|
|
|
+ expect(payload.email).toBe('stylist@example.com');
|
|
|
|
|
+ expect(payload.username).toBe('Ogawa');
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
it('/api/v1/customers (GET) accepts a valid signed token', async () => {
|
|
it('/api/v1/customers (GET) accepts a valid signed token', async () => {
|
|
|
const token = await jwtService.signAsync({
|
|
const token = await jwtService.signAsync({
|
|
|
sub: 1,
|
|
sub: 1,
|
|
|
email: 'stylist@example.com',
|
|
email: 'stylist@example.com',
|
|
|
|
|
+ username: 'Ogawa',
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const response = await request(app.getHttpServer())
|
|
const response = await request(app.getHttpServer())
|