HEX
Server: nginx/1.18.0
System: Linux test-ipsremont 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
User: ips (1000)
PHP: 8.0.30
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: /var/www/europequiz/node_modules/oauth-1.0a/test/options/multiple_values.js
var expect = require('chai').expect;
var OAuth = require('../../oauth-1.0a');
var crypto = require('crypto');

function hash_function_SHA1(base_string, key) {
    return crypto.createHmac('sha1', key).update(base_string).digest('base64');
}

describe("Signature method", function() {
    describe("HMAC-SHA1 signature method with multiple values", function() {
        var oauth = new OAuth({
            consumer: {
            key: "batch-dbc2cd8c-6ca8-463b-96e2-6d8683eac6fd",
            secret: "4S4Rvm25CJZWv7HBg5HOhhlRTBSZ7npl"
            },
            signature_method: 'HMAC-SHA1',
            hash_function: hash_function_SHA1
        });

        //overide for testing only !!!
        oauth.getTimeStamp = function() {
            return 1445951836;
        };

        //overide for testing only !!!
        oauth.getNonce = function(length) {
            return 'tKOQtKan8PHIrIoOlrl17zHkZQ2H5CsP';
        };


        var request_data = {
          url: "http://localhost:3737/rest/profiles/1ea2a42f-e14d-4057-8bcd-3e0b4514a267/properties?alt=json",
          method: "PUT",
          data: {
            currentbrowserversion: [ '1', '5', 'dfadfadfa' ],
            alt: 'json'
          }
        };

        var result = oauth.authorize(request_data);

        it("Signature should match", function() {
            expect(result.oauth_signature).to.equal("ri0lfv4udd2uQmkg5cCPVqLruyk=");
        });

        it("Nonce should match", function() {
            expect(result.oauth_nonce).to.equal("tKOQtKan8PHIrIoOlrl17zHkZQ2H5CsP");
        });

        it("Timestamp should match", function() {
            expect(result.oauth_timestamp).to.equal(1445951836);
        });
    });
});