Skip to content

Commit

Permalink
tests: add case-insensitive scheme tests
Browse files Browse the repository at this point in the history
closes #41
  • Loading branch information
wellingguzman authored and dougwilson committed Sep 25, 2018
1 parent bde0bac commit e8a29f9
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/basic-auth.js
Expand Up @@ -109,6 +109,33 @@ describe('auth(req)', function () {
assert.strictEqual(creds.pass, 'pass:word')
})
})

describe('with scheme "Basic"', function () {
it('should return .name and .pass', function () {
var req = request('Basic Zm9vOmJhcg==')
var creds = auth(req)
assert.strictEqual(creds.name, 'foo')
assert.strictEqual(creds.pass, 'bar')
})
})

describe('with scheme "BASIC"', function () {
it('should return .name and .pass', function () {
var req = request('BASIC Zm9vOmJhcg==')
var creds = auth(req)
assert.strictEqual(creds.name, 'foo')
assert.strictEqual(creds.pass, 'bar')
})
})

describe('with scheme "BaSiC"', function () {
it('should return .name and .pass', function () {
var req = request('BaSiC Zm9vOmJhcg==')
var creds = auth(req)
assert.strictEqual(creds.name, 'foo')
assert.strictEqual(creds.pass, 'bar')
})
})
})

describe('auth.parse(string)', function () {
Expand Down Expand Up @@ -175,4 +202,31 @@ describe('auth.parse(string)', function () {
assert.strictEqual(creds.pass, 'pass:word')
})
})

describe('with scheme "Basic"', function () {
it('should return .name and .pass', function () {
var req = request('Basic Zm9vOmJhcg==')
var creds = auth(req)
assert.strictEqual(creds.name, 'foo')
assert.strictEqual(creds.pass, 'bar')
})
})

describe('with scheme "BASIC"', function () {
it('should return .name and .pass', function () {
var req = request('BASIC Zm9vOmJhcg==')
var creds = auth(req)
assert.strictEqual(creds.name, 'foo')
assert.strictEqual(creds.pass, 'bar')
})
})

describe('with scheme "BaSiC"', function () {
it('should return .name and .pass', function () {
var req = request('BaSiC Zm9vOmJhcg==')
var creds = auth(req)
assert.strictEqual(creds.name, 'foo')
assert.strictEqual(creds.pass, 'bar')
})
})
})

0 comments on commit e8a29f9

Please sign in to comment.