]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/request/node_modules/hawk/test/crypto.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / request / node_modules / hawk / test / crypto.js
1 // Load modules
2
3 var Code = require('code');
4 var Hawk = require('../lib');
5 var Lab = require('lab');
6
7
8 // Declare internals
9
10 var internals = {};
11
12
13 // Test shortcuts
14
15 var lab = exports.lab = Lab.script();
16 var describe = lab.experiment;
17 var it = lab.test;
18 var expect = Code.expect;
19
20
21 describe('Crypto', function () {
22
23     describe('generateNormalizedString()', function () {
24
25         it('should return a valid normalized string', function (done) {
26
27             expect(Hawk.crypto.generateNormalizedString('header', {
28                 ts: 1357747017,
29                 nonce: 'k3k4j5',
30                 method: 'GET',
31                 resource: '/resource/something',
32                 host: 'example.com',
33                 port: 8080
34             })).to.equal('hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\n\n');
35
36             done();
37         });
38
39         it('should return a valid normalized string (ext)', function (done) {
40
41             expect(Hawk.crypto.generateNormalizedString('header', {
42                 ts: 1357747017,
43                 nonce: 'k3k4j5',
44                 method: 'GET',
45                 resource: '/resource/something',
46                 host: 'example.com',
47                 port: 8080,
48                 ext: 'this is some app data'
49             })).to.equal('hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\nthis is some app data\n');
50
51             done();
52         });
53
54         it('should return a valid normalized string (payload + ext)', function (done) {
55
56             expect(Hawk.crypto.generateNormalizedString('header', {
57                 ts: 1357747017,
58                 nonce: 'k3k4j5',
59                 method: 'GET',
60                 resource: '/resource/something',
61                 host: 'example.com',
62                 port: 8080,
63                 hash: 'U4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=',
64                 ext: 'this is some app data'
65             })).to.equal('hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\nU4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=\nthis is some app data\n');
66
67             done();
68         });
69     });
70 });