HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/1526/cwd/tana/frontend/node_modules/hawk/test/crypto.js
// 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\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\n\n');

            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\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\n\nthis is some app data\n');

            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\n1357747017\nk3k4j5\nGET\n/resource/something\nexample.com\n8080\nU4MKKSmiVxk37JCCrAVIjV/OhB3y+NdwoCr6RShbVkE=\nthis is some app data\n');

            done();
        });
    });
});