|
1 | | -var assert = require('assert'); |
2 | | -var auth = require('..'); |
| 1 | +var assert = require('assert') |
| 2 | +var auth = require('..') |
3 | 3 |
|
4 | | -function request(authorization) { |
| 4 | +function request (authorization) { |
5 | 5 | return { |
6 | 6 | headers: { |
7 | 7 | authorization: authorization |
@@ -44,76 +44,76 @@ describe('auth(req)', function () { |
44 | 44 | }) |
45 | 45 | }) |
46 | 46 |
|
47 | | - describe('with no Authorization field', function(){ |
48 | | - it('should return null', function(){ |
49 | | - var req = request(); |
50 | | - assert(null == auth(req)); |
| 47 | + describe('with no Authorization field', function () { |
| 48 | + it('should return null', function () { |
| 49 | + var req = request() |
| 50 | + assert(auth(req) == null) |
51 | 51 | }) |
52 | 52 | }) |
53 | 53 |
|
54 | | - describe('with malformed Authorization field', function(){ |
55 | | - it('should return null', function(){ |
56 | | - var req = request('Something'); |
57 | | - assert(null == auth(req)); |
| 54 | + describe('with malformed Authorization field', function () { |
| 55 | + it('should return null', function () { |
| 56 | + var req = request('Something') |
| 57 | + assert(auth(req) == null) |
58 | 58 | }) |
59 | 59 | }) |
60 | 60 |
|
61 | | - describe('with malformed Authorization scheme', function(){ |
62 | | - it('should return null', function(){ |
63 | | - var req = request('basic_Zm9vOmJhcg=='); |
64 | | - assert(null == auth(req)); |
| 61 | + describe('with malformed Authorization scheme', function () { |
| 62 | + it('should return null', function () { |
| 63 | + var req = request('basic_Zm9vOmJhcg==') |
| 64 | + assert(auth(req) == null) |
65 | 65 | }) |
66 | 66 | }) |
67 | 67 |
|
68 | | - describe('with malformed credentials', function(){ |
69 | | - it('should return null', function(){ |
70 | | - var req = request('basic Zm9vcgo='); |
71 | | - assert(null == auth(req)); |
| 68 | + describe('with malformed credentials', function () { |
| 69 | + it('should return null', function () { |
| 70 | + var req = request('basic Zm9vcgo=') |
| 71 | + assert(auth(req) == null) |
72 | 72 | }) |
73 | 73 | }) |
74 | 74 |
|
75 | | - describe('with valid credentials', function(){ |
76 | | - it('should return .name and .pass', function(){ |
77 | | - var req = request('basic Zm9vOmJhcg=='); |
78 | | - var creds = auth(req); |
79 | | - assert.equal(creds.name, 'foo'); |
80 | | - assert.equal(creds.pass, 'bar'); |
| 75 | + describe('with valid credentials', function () { |
| 76 | + it('should return .name and .pass', function () { |
| 77 | + var req = request('basic Zm9vOmJhcg==') |
| 78 | + var creds = auth(req) |
| 79 | + assert.equal(creds.name, 'foo') |
| 80 | + assert.equal(creds.pass, 'bar') |
81 | 81 | }) |
82 | 82 | }) |
83 | 83 |
|
84 | | - describe('with empty password', function(){ |
85 | | - it('should return .name and .pass', function(){ |
86 | | - var req = request('basic Zm9vOg=='); |
87 | | - var creds = auth(req); |
88 | | - assert.equal(creds.name, 'foo'); |
89 | | - assert.equal(creds.pass, ''); |
| 84 | + describe('with empty password', function () { |
| 85 | + it('should return .name and .pass', function () { |
| 86 | + var req = request('basic Zm9vOg==') |
| 87 | + var creds = auth(req) |
| 88 | + assert.equal(creds.name, 'foo') |
| 89 | + assert.equal(creds.pass, '') |
90 | 90 | }) |
91 | 91 | }) |
92 | 92 |
|
93 | | - describe('with empty userid', function(){ |
94 | | - it('should return .name and .pass', function(){ |
95 | | - var req = request('basic OnBhc3M='); |
96 | | - var creds = auth(req); |
97 | | - assert.equal(creds.name, ''); |
98 | | - assert.equal(creds.pass, 'pass'); |
| 93 | + describe('with empty userid', function () { |
| 94 | + it('should return .name and .pass', function () { |
| 95 | + var req = request('basic OnBhc3M=') |
| 96 | + var creds = auth(req) |
| 97 | + assert.equal(creds.name, '') |
| 98 | + assert.equal(creds.pass, 'pass') |
99 | 99 | }) |
100 | 100 | }) |
101 | 101 |
|
102 | | - describe('with empty userid and pass', function(){ |
103 | | - it('should return .name and .pass', function(){ |
104 | | - var req = request('basic Og=='); |
105 | | - var creds = auth(req); |
106 | | - assert.equal(creds.name, ''); |
107 | | - assert.equal(creds.pass, ''); |
| 102 | + describe('with empty userid and pass', function () { |
| 103 | + it('should return .name and .pass', function () { |
| 104 | + var req = request('basic Og==') |
| 105 | + var creds = auth(req) |
| 106 | + assert.equal(creds.name, '') |
| 107 | + assert.equal(creds.pass, '') |
108 | 108 | }) |
109 | 109 | }) |
110 | 110 |
|
111 | | - describe('with colon in pass', function(){ |
112 | | - it('should return .name and .pass', function(){ |
113 | | - var req = request('basic Zm9vOnBhc3M6d29yZA=='); |
114 | | - var creds = auth(req); |
115 | | - assert.equal(creds.name, 'foo'); |
116 | | - assert.equal(creds.pass, 'pass:word'); |
| 111 | + describe('with colon in pass', function () { |
| 112 | + it('should return .name and .pass', function () { |
| 113 | + var req = request('basic Zm9vOnBhc3M6d29yZA==') |
| 114 | + var creds = auth(req) |
| 115 | + assert.equal(creds.name, 'foo') |
| 116 | + assert.equal(creds.pass, 'pass:word') |
117 | 117 | }) |
118 | 118 | }) |
119 | 119 | }) |
0 commit comments