Skip to content

Commit c69fad7

Browse files
committed
Add test for default token/bearer auth
1 parent 61c2674 commit c69fad7

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/request.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,22 @@ describe('request', function () {
189189
.then(done, done);
190190
});
191191

192+
it('agent can be used to set default baerer authentication', function (done){
193+
var agent = request.agent('https://httpbin.org');
194+
agent.set("Authorization", "Bearer test_bearer");
195+
196+
agent
197+
.get('/bearer')
198+
.then(function (res){
199+
res.should.have.status(200);
200+
res.should.be.json;
201+
res.body.should.have.property('authenticated').that.equals(true);
202+
res.body.should.have.property('token').that.equals("test_bearer");
203+
agent.close();
204+
})
205+
.then(done, done);
206+
});
207+
192208
it('agent can be used to set default basic authentication', function (done){
193209
var agent = request.agent('https://httpbin.org');
194210
agent.auth("user", "passwd");

0 commit comments

Comments
 (0)