Skip to content

Commit

Permalink
Add test for default token/bearer auth
Browse files Browse the repository at this point in the history
  • Loading branch information
jrford committed Aug 3, 2018
1 parent 61c2674 commit c69fad7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,22 @@ describe('request', function () {
.then(done, done);
});

it('agent can be used to set default baerer authentication', function (done){
var agent = request.agent('https://httpbin.org');
agent.set("Authorization", "Bearer test_bearer");

agent
.get('/bearer')
.then(function (res){
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property('authenticated').that.equals(true);
res.body.should.have.property('token').that.equals("test_bearer");
agent.close();
})
.then(done, done);
});

it('agent can be used to set default basic authentication', function (done){
var agent = request.agent('https://httpbin.org');
agent.auth("user", "passwd");
Expand Down

0 comments on commit c69fad7

Please sign in to comment.