From c12a085f8e85fbc1dab3c0dd683d30db6a9e00f6 Mon Sep 17 00:00:00 2001 From: Clement Michaud Date: Wed, 26 Jul 2017 23:45:26 +0200 Subject: [PATCH] Replace mocha integration tests by cucumber tests --- .travis.yml | 24 +++- Gruntfile.js | 17 ++- README.md | 1 + config.template.yml | 2 +- example/ldap/base.ldif | 7 ++ example/nginx/html/index.html | 8 +- example/nginx/nginx.conf | 3 +- package.json | 11 +- scripts/dc-dev.sh | 5 +- scripts/example/dc-example.sh | 3 +- scripts/integration-tests.sh | 40 +------ .../firstfactor/FirstFactorValidator.ts | 2 +- .../reset-password/reset-password-request.ts | 2 +- src/server/lib/AuthenticationRegulator.ts | 28 ++--- src/server/lib/ldap/Client.ts | 4 +- .../lib/notifiers/FileSystemNotifier.ts | 4 +- src/server/views/errors/401.pug | 2 +- src/server/views/errors/403.pug | 2 +- src/server/views/firstfactor.pug | 2 +- src/server/views/layout/layout.pug | 2 +- src/server/views/secondfactor.pug | 8 +- test/features/access-control.feature | 38 ++++++ test/features/authentication.feature | 53 +++++++++ test/features/redirection.feature | 7 ++ test/features/reset-password.feature | 33 ++++++ test/features/resilience.feature | 13 ++ test/features/restrictions.feature | 17 +++ test/features/step_definitions/after.ts | 7 ++ .../step_definitions/authentication.ts | 92 ++++++++++++++ test/features/step_definitions/redirection.ts | 17 +++ .../step_definitions/reset-password.ts | 20 ++++ test/features/step_definitions/resilience.ts | 12 ++ .../features/step_definitions/restrictions.ts | 11 ++ test/features/support/world.ts | 110 +++++++++++++++++ test/integration/Dockerfile | 4 - test/integration/docker-compose.yml | 30 ----- test/integration/main.ts | 112 ------------------ test/system/main.ts | 92 -------------- .../firstfactor/FirstFactorValidator.test.ts | 2 +- 39 files changed, 517 insertions(+), 330 deletions(-) create mode 100644 test/features/access-control.feature create mode 100644 test/features/authentication.feature create mode 100644 test/features/redirection.feature create mode 100644 test/features/reset-password.feature create mode 100644 test/features/resilience.feature create mode 100644 test/features/restrictions.feature create mode 100644 test/features/step_definitions/after.ts create mode 100644 test/features/step_definitions/authentication.ts create mode 100644 test/features/step_definitions/redirection.ts create mode 100644 test/features/step_definitions/reset-password.ts create mode 100644 test/features/step_definitions/resilience.ts create mode 100644 test/features/step_definitions/restrictions.ts create mode 100644 test/features/support/world.ts delete mode 100644 test/integration/Dockerfile delete mode 100644 test/integration/docker-compose.yml delete mode 100644 test/integration/main.ts delete mode 100644 test/system/main.ts diff --git a/.travis.yml b/.travis.yml index b5052c4fe..2ec3f9f54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,37 @@ +dist: trusty language: node_js +sudo: required node_js: -- node + - "7" services: -- docker -- ntp + - docker + - ntp addons: + chrome: stable apt: + sources: + - google-chrome packages: - - libgif-dev + - libgif-dev + - google-chrome-stable hosts: - auth.test.local - home.test.local + - public.test.local - secret.test.local - secret1.test.local - secret2.test.local - mx1.mail.test.local - mx2.mail.test.local -before_install: npm install -g npm@'>=2.13.5' +before_install: + - npm install -g npm@'>=2.13.5' + +before_script: + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - sleep 3 + script: - ./scripts/travis.sh diff --git a/Gruntfile.js b/Gruntfile.js index ba2c93e8f..c5b590bb7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -12,17 +12,13 @@ module.exports = function (grunt) { cmd: "./node_modules/.bin/tslint", args: ['-c', 'tslint.json', '-p', 'tsconfig.json'] }, - "test": { + "unit-tests": { cmd: "./node_modules/.bin/mocha", args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/unit'] }, - "test-int": { - cmd: "./node_modules/.bin/mocha", - args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/integration'] - }, - "test-system": { - cmd: "./node_modules/.bin/mocha", - args: ['--compilers', 'ts:ts-node/register', '--recursive', 'test/system'] + "integration-tests": { + cmd: "./node_modules/.bin/cucumber-js", + args: ["--compiler", "ts:ts-node/register", "./test/features"] }, "docker-build": { cmd: "docker", @@ -165,5 +161,8 @@ module.exports = function (grunt) { grunt.registerTask('docker-build', ['run:docker-build']); grunt.registerTask('docker-restart', ['run:docker-restart']); - grunt.registerTask('test', ['run:test']); + grunt.registerTask('unit-tests', ['run:unit-tests']); + grunt.registerTask('integration-tests', ['run:unit-tests']); + + grunt.registerTask('test', ['unit-tests']); }; diff --git a/README.md b/README.md index 669960862..aa8d2d07f 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Make sure you don't have anything listening on port 8080. Add the following lines to your **/etc/hosts** to alias multiple subdomains so that nginx can redirect request to the correct virtual host. + 127.0.0.1 public.test.local 127.0.0.1 secret.test.local 127.0.0.1 secret1.test.local 127.0.0.1 secret2.test.local diff --git a/config.template.yml b/config.template.yml index e21ca9967..638b59202 100644 --- a/config.template.yml +++ b/config.template.yml @@ -48,7 +48,7 @@ ldap: # beginning of the pattern. access_control: default: - - home.test.local + - public.test.local groups: admin: - '*.test.local' diff --git a/example/ldap/base.ldif b/example/ldap/base.ldif index f1fbdb887..06e962c04 100644 --- a/example/ldap/base.ldif +++ b/example/ldap/base.ldif @@ -45,3 +45,10 @@ mail: bob.dylan@example.com sn: Bob Dylan userpassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= +dn: cn=james,ou=users,dc=example,dc=com +cn: james +objectclass: inetOrgPerson +objectclass: top +mail: james.dean@example.com +sn: James Dean +userpassword: {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g= diff --git a/example/nginx/html/index.html b/example/nginx/html/index.html index 8f76ab5b3..f009d515e 100644 --- a/example/nginx/html/index.html +++ b/example/nginx/html/index.html @@ -9,6 +9,9 @@ You need to log in to access the secret!

Try to access it via one of the following links.