forked from sintaxi/harp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.js
37 lines (31 loc) · 886 Bytes
/
auth.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var should = require("should")
var request = require('request')
var path = require('path')
var harp = require("../")
describe("basicAuth", function(){
describe("single", function(done){
var projectPath = path.join(__dirname, "apps/auth/single")
before(function(done){
harp.server(projectPath, { port: 8310 }, done)
})
it("should be a protected page", function(done){
request('http://localhost:8310/', function (e, r, b) {
r.statusCode.should.eql(401)
done()
})
})
it("should fetch protected resource with correct creds", function(done){
request({
method: "GET",
url: 'http://localhost:8310/',
auth: {
'user': 'foo',
'pass': 'bar'
}
}, function (e, r, b) {
r.statusCode.should.eql(200)
done()
})
})
})
})