diff options
| author | cjd24 | 2018-04-19 20:48:19 +0100 |
|---|---|---|
| committer | cjd24 | 2018-04-19 20:48:19 +0100 |
| commit | 92e23d37f843e49eda01a4d0ea7ed8005efffdb2 (patch) | |
| tree | 7c08678dfce9bf82eaa4f71f5e23182f8515d386 /test/integration/auth.routes.test.ts | |
| parent | Added a write of the base teir JSON object, made the images actually write to... (diff) | |
| parent | Merge branch 'trh/gets' into cjd24/conversion (diff) | |
| download | medicine-92e23d37f843e49eda01a4d0ea7ed8005efffdb2.tar.gz medicine-92e23d37f843e49eda01a4d0ea7ed8005efffdb2.zip | |
Merge branch ‘cjd24/conversion’ of https://gitlab.cs.st-andrews.ac.uk/cs3099group-be-4/project-code into cjd24/conversion
Diffstat (limited to 'test/integration/auth.routes.test.ts')
| -rw-r--r-- | test/integration/auth.routes.test.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/test/integration/auth.routes.test.ts b/test/integration/auth.routes.test.ts index af3f696..29c0cfc 100644 --- a/test/integration/auth.routes.test.ts +++ b/test/integration/auth.routes.test.ts @@ -65,13 +65,15 @@ const authorisationErr = { error_description: 'user does not have correct authorisation for task' }; +const base: string = '/cs3099group-be-4'; + describe('authentication', () => { before(initDatabase); context('invalid password authentication', () => { before(populateDatabase); it('should reject login to invalid endpoints', () => { return chai.request(app) - .post('/') + .post('/invalid endpoint') .send({ username: mockUser.username, password: mockUser.password, @@ -86,7 +88,7 @@ describe('authentication', () => { }); it('should reject invalid usernames', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: 'invalid', password: mockUser.password, @@ -97,7 +99,7 @@ describe('authentication', () => { }); it('should reject invalid passwords', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: mockUser.username, password: 'asasasas', @@ -108,7 +110,7 @@ describe('authentication', () => { }); it('should reject invalid grant_type', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: mockUser.username, password: mockUser.password, @@ -119,7 +121,7 @@ describe('authentication', () => { }); it('should reject empty usernames', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: '', password: mockUser.password, @@ -130,7 +132,7 @@ describe('authentication', () => { }); it('should reject empty passwords', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: mockUser.username, password: '', @@ -141,7 +143,7 @@ describe('authentication', () => { }); it('should reject empty grant_type', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: mockUser.username, password: mockUser.password, @@ -155,7 +157,7 @@ describe('authentication', () => { before(populateDatabase); it('should accept correct credentials', () => { return chai.request(app) - .post('/cs3099group-be-4/oauth/token') + .post(`${base}/oauth/token`) .send({ username: mockUser.username, password: mockUser.password, @@ -169,7 +171,7 @@ describe('authentication', () => { beforeEach(populateDatabase); beforeEach(getToken); it('should reject invalid tokens', () => { - return chai.request(app).get('/') + return chai.request(app).get(`${base}/users`) .set('Authorization', 'Bearer ' + 'invalid') .then((res) => { expect(res).to.have.status(401); @@ -178,7 +180,7 @@ describe('authentication', () => { }); }); it('should accept valid tokens', () => { - return chai.request(app).get('/') + return chai.request(app).get(`${base}/_supported_protocols_`) .set('Authorization', `Bearer ${token}`) .then((res) => { expect(res).to.have.status(200); |
