1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| var assert = require('assert'),
| vows = require('vows'),
| basicAuthParser = require('../');
|
| vows.describe('basic-auth-parser').addBatch({
| 'When using `basic-auth-parser`': {
| 'with a correct string input': {
| topic: basicAuthParser('Basic YWRtaW46cGFzc3dvcmQ='),
| 'it should return parsed data': function (result) {
| assert.deepEqual(result, {
| scheme: 'Basic',
| username: 'admin',
| password: 'password'
| });
| }
| },
| 'with a wrong scheme': {
| topic: basicAuthParser('Digest DEADC0FFEE'),
| 'it should return parsed data': function (result) {
| assert.deepEqual(result, {
| scheme: 'Digest'
| });
| }
| },
| 'with a correct string and a colon in password': {
| topic: basicAuthParser('Basic YWRtaW46cGFzczp3b3Jk'),
| 'it should return parsed data': function (result) {
| assert.deepEqual(result, {
| scheme: 'Basic',
| username: 'admin',
| password: 'pass:word'
| });
| }
| }
| }
| }).export(module);
|
|