-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from SardonyxApp/dev-board
Implement tasklist features
- Loading branch information
Showing
90 changed files
with
6,404 additions
and
1,160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const request = require('supertest'); | ||
const app = require('../app'); | ||
const db = require('../db'); | ||
|
||
require('dotenv').config(); | ||
|
||
|
@@ -118,67 +119,75 @@ describe('Authentication API', () => { | |
}); | ||
}); | ||
|
||
describe('POST /api/login', () => { | ||
test('POST /api/login should return 401 without credentials', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.then(response => { | ||
expect(response.statusCode).toBe(401); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return 200 with valid credentials', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', process.env.LOGIN) | ||
.field('password', process.env.PASSWORD) | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return 401 with invalid login', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', '[email protected]') | ||
.field('password', process.env.PASSWORD) | ||
.then(response => { | ||
expect(response.statusCode).toBe(401); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return 401 with invalid password', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', process.env.LOGIN) | ||
.field('password', 'foobar') | ||
.then(response => { | ||
expect(response.statusCode).toBe(401); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return Login-Token with valid credentials', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', process.env.LOGIN) | ||
.field('password', process.env.PASSWORD) | ||
.then(response => { | ||
const credentials = JSON.parse(response.headers['login-token'] || '{}'); | ||
expect(credentials).toHaveProperty('login'); | ||
expect(credentials).toHaveProperty('password'); | ||
expect(credentials).toHaveProperty('managebacSession'); | ||
expect(credentials).toHaveProperty('cfduid'); | ||
expect(credentials).toHaveProperty('authenticityToken'); | ||
done(); | ||
}); | ||
db.connect(err => { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
|
||
describe('POST /api/login', () => { | ||
test('POST /api/login should return 401 without credentials', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.then(response => { | ||
expect(response.statusCode).toBe(401); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return 200 with valid credentials', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', process.env.LOGIN) | ||
.field('password', process.env.PASSWORD) | ||
.then(response => { | ||
expect(response.statusCode).toBe(200); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return 401 with invalid login', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', '[email protected]') | ||
.field('password', process.env.PASSWORD) | ||
.then(response => { | ||
expect(response.statusCode).toBe(401); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return 401 with invalid password', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', process.env.LOGIN) | ||
.field('password', 'foobar') | ||
.then(response => { | ||
expect(response.statusCode).toBe(401); | ||
done(); | ||
}); | ||
}); | ||
|
||
test('POST /api/login should return Login-Token with valid credentials', (done) => { | ||
request(app) | ||
.post('/api/login') | ||
.set('Content-Type', 'multipart/form-data') | ||
.field('login', process.env.LOGIN) | ||
.field('password', process.env.PASSWORD) | ||
.then(response => { | ||
const credentials = JSON.parse(response.headers['login-token'] || '{}'); | ||
expect(credentials).toHaveProperty('login'); | ||
expect(credentials).toHaveProperty('password'); | ||
expect(credentials).toHaveProperty('managebacSession'); | ||
expect(credentials).toHaveProperty('cfduid'); | ||
expect(credentials).toHaveProperty('authenticityToken'); | ||
expect(response.headers).toHaveProperty('sardonyx-token'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.