Skip to content

Commit e8a29f9

Browse files
wellingguzmandougwilson
authored andcommitted
tests: add case-insensitive scheme tests
closes #41
1 parent bde0bac commit e8a29f9

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/basic-auth.js

+54
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,33 @@ describe('auth(req)', function () {
109109
assert.strictEqual(creds.pass, 'pass:word')
110110
})
111111
})
112+
113+
describe('with scheme "Basic"', function () {
114+
it('should return .name and .pass', function () {
115+
var req = request('Basic Zm9vOmJhcg==')
116+
var creds = auth(req)
117+
assert.strictEqual(creds.name, 'foo')
118+
assert.strictEqual(creds.pass, 'bar')
119+
})
120+
})
121+
122+
describe('with scheme "BASIC"', function () {
123+
it('should return .name and .pass', function () {
124+
var req = request('BASIC Zm9vOmJhcg==')
125+
var creds = auth(req)
126+
assert.strictEqual(creds.name, 'foo')
127+
assert.strictEqual(creds.pass, 'bar')
128+
})
129+
})
130+
131+
describe('with scheme "BaSiC"', function () {
132+
it('should return .name and .pass', function () {
133+
var req = request('BaSiC Zm9vOmJhcg==')
134+
var creds = auth(req)
135+
assert.strictEqual(creds.name, 'foo')
136+
assert.strictEqual(creds.pass, 'bar')
137+
})
138+
})
112139
})
113140

114141
describe('auth.parse(string)', function () {
@@ -175,4 +202,31 @@ describe('auth.parse(string)', function () {
175202
assert.strictEqual(creds.pass, 'pass:word')
176203
})
177204
})
205+
206+
describe('with scheme "Basic"', function () {
207+
it('should return .name and .pass', function () {
208+
var req = request('Basic Zm9vOmJhcg==')
209+
var creds = auth(req)
210+
assert.strictEqual(creds.name, 'foo')
211+
assert.strictEqual(creds.pass, 'bar')
212+
})
213+
})
214+
215+
describe('with scheme "BASIC"', function () {
216+
it('should return .name and .pass', function () {
217+
var req = request('BASIC Zm9vOmJhcg==')
218+
var creds = auth(req)
219+
assert.strictEqual(creds.name, 'foo')
220+
assert.strictEqual(creds.pass, 'bar')
221+
})
222+
})
223+
224+
describe('with scheme "BaSiC"', function () {
225+
it('should return .name and .pass', function () {
226+
var req = request('BaSiC Zm9vOmJhcg==')
227+
var creds = auth(req)
228+
assert.strictEqual(creds.name, 'foo')
229+
assert.strictEqual(creds.pass, 'bar')
230+
})
231+
})
178232
})

0 commit comments

Comments
 (0)