Skip to content

Commit

Permalink
More gateway service tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Mario committed Apr 27, 2024
1 parent c799b3d commit 1c14d9e
Showing 1 changed file with 131 additions and 0 deletions.
131 changes: 131 additions & 0 deletions gatewayservice/gateway-service.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,135 @@ describe('Gateway Service without mocked micro services', () => {
expect(error.response.data.error).toBe('Invalid username or password');
}
});

it('should not forward adduser request and give 500', async () => {
try{
await request(app)
.post('/adduser')
.send({ username: 'testuser', password: 'testpassword' });

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward forgetPassword request and give 500', async () => {
try{
await request(app)
.post('/forgetPassword');

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward changePassword request and give 500', async () => {
try{
await request(app)
.post('/changePassword')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward questions request and give 500', async () => {
try{
await request(app)
.get('/questions')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward questions request and give 500', async () => {
try{
await request(app)
.get('/questions/es/1/CAPITAL')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward questions request and give 500', async () => {
try{
await request(app)
.get('/questions/es/1')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward questions request and give 500', async () => {
try{
await request(app)
.get('/questions/es')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward record request and give 500', async () => {
try{
await request(app)
.post('/record')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward record request and give 500', async () => {
try{
await request(app)
.get('/record/ranking/top10')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward record request and give 500', async () => {
try{
await request(app)
.get('/record/ranking/user')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});

it('should not forward record request and give 500', async () => {
try{
await request(app)
.get('/record/user')
.set('token', 'valorDelToken');;

} catch(error){
expect(error.response.status).toBe(500);
expect(error.response.data.error).toBe('Internal server error');
}
});
});

0 comments on commit 1c14d9e

Please sign in to comment.