react / wstein / node_modules / jest-cli / node_modules / jsdom / node_modules / request / node_modules / hawk / test / crypto.js
81146 views// Load modules12var Code = require('code');3var Hawk = require('../lib');4var Lab = require('lab');567// Declare internals89var internals = {};101112// Test shortcuts1314var lab = exports.lab = Lab.script();15var describe = lab.experiment;16var it = lab.test;17var expect = Code.expect;181920describe('Hawk', function () {2122describe('Crypto', function () {2324describe('#generateNormalizedString', function () {2526it('should return a valid normalized string', function (done) {2728expect(Hawk.crypto.generateNormalizedString('header', {29credentials: {30key: 'dasdfasdf',31algorithm: 'sha256'32},33ts: 1357747017,34nonce: 'k3k4j5',35method: 'GET',36resource: '/resource/something',37host: 'example.com',38port: 808039})).to.equal('hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\n\n');4041done();42});4344it('should return a valid normalized string (ext)', function (done) {4546expect(Hawk.crypto.generateNormalizedString('header', {47credentials: {48key: 'dasdfasdf',49algorithm: 'sha256'50},51ts: 1357747017,52nonce: 'k3k4j5',53method: 'GET',54resource: '/resource/something',55host: 'example.com',56port: 8080,57ext: 'this is some app data'58})).to.equal('hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\nthis is some app data\n');5960done();61});6263it('should return a valid normalized string (payload + ext)', function (done) {6465expect(Hawk.crypto.generateNormalizedString('header', {66credentials: {67key: 'dasdfasdf',68algorithm: 'sha256'69},70ts: 1357747017,71nonce: 'k3k4j5',72method: 'GET',73resource: '/resource/something',74host: 'example.com',75port: 8080,76hash: 'U4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=',77ext: 'this is some app data'78})).to.equal('hawk.1.header\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\nU4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=\nthis is some app data\n');7980done();81});82});83});84});85868788