aboutsummaryrefslogtreecommitdiff
path: root/test/integration/auth.routes.test.ts
diff options
context:
space:
mode:
authorHafeez2018-04-14 17:35:39 +0100
committerHafeez2018-04-14 17:35:39 +0100
commitc619c845822e0019d988bdcdb760ffd7a220d601 (patch)
tree449bb5b827300cf52e7e533f580c6ab36bf8e4c4 /test/integration/auth.routes.test.ts
parentMerge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff)
parentfixed 1 test in auth.routes.test.ts (diff)
downloadmedicine-c619c845822e0019d988bdcdb760ffd7a220d601.tar.gz
medicine-c619c845822e0019d988bdcdb760ffd7a220d601.zip

merge

Diffstat (limited to 'test/integration/auth.routes.test.ts')
-rw-r--r--test/integration/auth.routes.test.ts22
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);