testing lines of code that are not documented...and documenting them - DK/MW
This commit is contained in:
parent
7902478c82
commit
bdbea069ad
@ -108,9 +108,17 @@ For more validation options see [auth0/jsonwebtoken](https://github.com/auth0/no
|
|||||||
Append the jwt token using query string:
|
Append the jwt token using query string:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
//// token part of query string ////
|
||||||
var socket = io.connect('http://localhost:9000', {
|
var socket = io.connect('http://localhost:9000', {
|
||||||
'query': 'token=' + your_jwt
|
'query': 'token=' + your_jwt
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//// token coming in as Authorization Header ////
|
||||||
|
var socket = io.connect('http://localhost:9000', {
|
||||||
|
'extraHeaders': { Authorization: `Bearer ${your_jwt}` }
|
||||||
|
});
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Append the jwt token using 'Authorization Header' (Bearer Token):
|
Append the jwt token using 'Authorization Header' (Bearer Token):
|
||||||
|
@ -27,7 +27,7 @@ describe('authorizer', function () {
|
|||||||
|
|
||||||
describe('when the user is logged in', function() {
|
describe('when the user is logged in', function() {
|
||||||
|
|
||||||
beforeEach(function (done) {
|
before(function (done) {
|
||||||
request.post({
|
request.post({
|
||||||
url: 'http://localhost:9000/login',
|
url: 'http://localhost:9000/login',
|
||||||
form: { username: 'jose', password: 'Pa123' },
|
form: { username: 'jose', password: 'Pa123' },
|
||||||
@ -38,6 +38,17 @@ describe('authorizer', function () {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('auth headers are supported', function (done){
|
||||||
|
var socket = io.connect('http://localhost:9000', {
|
||||||
|
'forceNew':true,
|
||||||
|
'extraHeaders': {'Authorization': `Bearer ${this.token}`}
|
||||||
|
});
|
||||||
|
socket.on('connect', function(){
|
||||||
|
socket.close();
|
||||||
|
done();
|
||||||
|
}).on('error', done);
|
||||||
|
});
|
||||||
|
|
||||||
it('should do the handshake and connect', function (done){
|
it('should do the handshake and connect', function (done){
|
||||||
var socket = io.connect('http://localhost:9000', {
|
var socket = io.connect('http://localhost:9000', {
|
||||||
'forceNew':true,
|
'forceNew':true,
|
||||||
|
Reference in New Issue
Block a user