Remove temporarily integration tests

This commit is contained in:
Clement Michaud 2017-01-28 20:13:56 +01:00
parent d29aac78d0
commit 5be5b34522
3 changed files with 1 additions and 170 deletions

View File

@ -10,7 +10,7 @@ script:
- docker-compose build - docker-compose build
- docker-compose up -d - docker-compose up -d
- sleep 5 - sleep 5
- npm run-script int-test - scripts/check_services.sh
deploy: deploy:
provider: npm provider: npm
email: clement.michaud34@gmail.com email: clement.michaud34@gmail.com

View File

@ -6,7 +6,6 @@
"scripts": { "scripts": {
"test": "./node_modules/.bin/mocha --recursive test/unitary", "test": "./node_modules/.bin/mocha --recursive test/unitary",
"unit-test": "./node_modules/.bin/mocha --recursive test/unitary", "unit-test": "./node_modules/.bin/mocha --recursive test/unitary",
"int-test": "./node_modules/.bin/mocha --recursive test/integration",
"all-test": "./node_modules/.bin/mocha --recursive test", "all-test": "./node_modules/.bin/mocha --recursive test",
"coverage": "./node_modules/.bin/istanbul cover _mocha -- -R spec --recursive test" "coverage": "./node_modules/.bin/istanbul cover _mocha -- -R spec --recursive test"
}, },

View File

@ -1,168 +0,0 @@
var request_ = require('request');
var assert = require('assert');
var speakeasy = require('speakeasy');
var j = request_.jar();
var Promise = require('bluebird');
var request = Promise.promisifyAll(request_.defaults({jar: j}));
var BASE_URL = 'https://localhost:8080';
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
describe('test the server', function() {
var home_page;
var login_page;
before(function() {
var home_page_promise = getHomePage()
.then(function(data) {
home_page = data.body;
});
var login_page_promise = getLoginPage()
.then(function(data) {
login_page = data.body;
});
return Promise.all([home_page_promise,
login_page_promise]);
});
it('should serve the login page', function(done) {
getPromised(BASE_URL + '/authentication/login?redirect=/')
.then(function(data) {
assert.equal(data.statusCode, 200);
done();
});
});
it('should serve the homepage', function(done) {
getPromised(BASE_URL + '/')
.then(function(data) {
assert.equal(data.statusCode, 200);
done();
});
});
it('should redirect when logout', function(done) {
getPromised(BASE_URL + '/authentication/logout?redirect=/')
.then(function(data) {
assert.equal(data.statusCode, 200);
assert.equal(data.body, home_page);
done();
});
});
it('should be redirected to the login page when accessing secret while not authenticated', function() {
return getPromised(BASE_URL + '/secret.html')
.then(function(data) {
assert.equal(data.statusCode, 200);
assert.equal(data.body, login_page);
return Promise.resolve();
});
});
it('should fail the first_factor login', function() {
return postPromised(BASE_URL + '/authentication/1stfactor', {
form: {
username: 'user',
password: 'bad_password'
}
})
.then(function(data) {
assert.equal(data.statusCode, 401);
return Promise.resolve();
});
});
it('should login and access the secret using totp', function() {
var token = speakeasy.totp({
secret: 'GRWGIJS6IRHVEODVNRCXCOBMJ5AGC6ZE',
encoding: 'base32'
});
return postPromised(BASE_URL + '/authentication/1stfactor', {
form: {
username: 'user',
password: 'password',
}
})
.then(function(response) {
assert.equal(response.statusCode, 204);
return postPromised(BASE_URL + '/authentication/2ndfactor/totp', {
form: { token: token }
});
})
.then(function(response) {
assert.equal(response.statusCode, 204);
return getPromised(BASE_URL + '/secret.html');
})
.then(function(response) {
var content = response.body;
var is_secret_page_content =
(content.indexOf('This is a very important secret!') > -1);
assert(is_secret_page_content);
return Promise.resolve();
})
.catch(function(err) {
console.error(err);
return Promise.reject(err);
});
});
it('should logoff and should not be able to access secret anymore', function() {
return getPromised(BASE_URL + '/secret.html')
.then(function(data) {
var content = data.body;
var is_secret_page_content =
(content.indexOf('This is a very important secret!') > -1);
assert(is_secret_page_content);
return getPromised(BASE_URL + '/authentication/logout')
})
.then(function(data) {
assert.equal(data.statusCode, 200);
assert.equal(data.body, home_page);
return getPromised(BASE_URL + '/secret.html');
})
.then(function(data) {
var content = data.body;
assert.equal(data.body, login_page);
return Promise.resolve();
})
.catch(function(err) {
console.error(err);
return Promise.reject();
});
});
});
function responsePromised(defer) {
return function(error, response, body) {
if(error) {
console.error(error);
defer.reject(error);
return;
}
defer.resolve({
response: response,
body: body
});
}
}
function getPromised(url) {
console.log('GET: %s', url);
return request.getAsync(url);
}
function postPromised(url, body) {
console.log('POST: %s, %s', url, JSON.stringify(body));
return request.postAsync(url, body);
}
function getHomePage() {
return getPromised(BASE_URL + '/');
}
function getLoginPage() {
return getPromised(BASE_URL + '/authentication/login');
}