From 5be5b34522f3d3268bd425589dbad632d9da0101 Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Sat, 28 Jan 2017 20:13:56 +0100 Subject: [PATCH] Remove temporarily integration tests --- .travis.yml | 2 +- package.json | 1 - test/integration/test_server.js | 168 -------------------------------- 3 files changed, 1 insertion(+), 170 deletions(-) delete mode 100644 test/integration/test_server.js diff --git a/.travis.yml b/.travis.yml index b5f3617c..4fcbf7cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ script: - docker-compose build - docker-compose up -d - sleep 5 -- npm run-script int-test +- scripts/check_services.sh deploy: provider: npm email: clement.michaud34@gmail.com diff --git a/package.json b/package.json index 805417ac..ef6461ae 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "scripts": { "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", "coverage": "./node_modules/.bin/istanbul cover _mocha -- -R spec --recursive test" }, diff --git a/test/integration/test_server.js b/test/integration/test_server.js deleted file mode 100644 index 69df3827..00000000 --- a/test/integration/test_server.js +++ /dev/null @@ -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'); -}