Blame view
node_modules/hawk/test/crypto.js
2.17 KB
f7563de62
|
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
// Load modules var Code = require('code'); var Hawk = require('../lib'); var Lab = require('lab'); // Declare internals var internals = {}; // Test shortcuts var lab = exports.lab = Lab.script(); var describe = lab.experiment; var it = lab.test; var expect = Code.expect; describe('Crypto', function () { describe('generateNormalizedString()', function () { it('should return a valid normalized string', function (done) { expect(Hawk.crypto.generateNormalizedString('header', { ts: 1357747017, nonce: 'k3k4j5', method: 'GET', resource: '/resource/something', host: 'example.com', port: 8080 })).to.equal('hawk.1.header 1357747017 k3k4j5 GET /resource/something example.com 8080 '); done(); }); it('should return a valid normalized string (ext)', function (done) { expect(Hawk.crypto.generateNormalizedString('header', { ts: 1357747017, nonce: 'k3k4j5', method: 'GET', resource: '/resource/something', host: 'example.com', port: 8080, ext: 'this is some app data' })).to.equal('hawk.1.header 1357747017 k3k4j5 GET /resource/something example.com 8080 this is some app data '); done(); }); it('should return a valid normalized string (payload + ext)', function (done) { expect(Hawk.crypto.generateNormalizedString('header', { ts: 1357747017, nonce: 'k3k4j5', method: 'GET', resource: '/resource/something', host: 'example.com', port: 8080, hash: 'U4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=', ext: 'this is some app data' })).to.equal('hawk.1.header 1357747017 k3k4j5 GET /resource/something example.com 8080 U4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE= this is some app data '); done(); }); }); }); |