From bf4d8b05c3c5d62c15b0c101bc9bf6145fff8648 Mon Sep 17 00:00:00 2001 From: Troy Goode Date: Tue, 8 Jul 2014 20:46:19 -0700 Subject: [PATCH] testing for #25 --- package.json | 3 ++- test/basic-auth.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 test/basic-auth.js diff --git a/package.json b/package.json index a6af75f..64472e9 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ } , "dependencies": {} , "devDependencies": { - "body-parser": "^1.4.3" + "basic-auth-connect": "^1" + , "body-parser": "^1.4.3" , "express": "^4" , "lint": "^1.1.2" , "mocha": "^1.18.2" diff --git a/test/basic-auth.js b/test/basic-auth.js new file mode 100644 index 0000000..adc8579 --- /dev/null +++ b/test/basic-auth.js @@ -0,0 +1,45 @@ +/*jslint indent: 2*/ +/*global require: true, module: true, describe: true, it: true, setTimeout: true*/ + +(function () { + + 'use strict'; + + var should = require('should'), + express = require('express'), + supertest = require('supertest'), + basicAuth = require('basic-auth-connect'), + cors = require('../lib'), + app; + + /* -------------------------------------------------------------------------- */ + + app = express(); + app.use(basicAuth('username', 'password')); + app.use(cors()); + /*jslint unparam: true*/ // `req` is part of the signature, but not used in these routes + app.post('/', function (req, res) { + res.send('hello world'); + }); + /*jslint unparam: false*/ + + /* -------------------------------------------------------------------------- */ + + describe('basic auth', function () { + describe('', function () { + it('POST works', function (done) { + supertest(app) + .post('/') + .auth('username', 'password') + .expect(200) + .end(function (err, res) { + should.not.exist(err); + res.text.should.eql('hello world'); + done(); + }); + }); + }); + }); + +}()); +