Skip to content

Commit

Permalink
testing for expressjs#25
Browse files Browse the repository at this point in the history
  • Loading branch information
troygoode committed Jul 9, 2014
1 parent 893cf2c commit bf4d8b0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
45 changes: 45 additions & 0 deletions test/basic-auth.js
Original file line number Diff line number Diff line change
@@ -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();
});
});
});
});

}());

0 comments on commit bf4d8b0

Please sign in to comment.