'Success' : function(test) {
    test.expect(3);
    var ar = AuthRequest.create('','','', false);
    var mockHash = {
      update: function() {
        return {
          digest: function() {
            return 'whaaaaa';
          }
        }
      }
    };

    MonkeyPatcher.patch(crypto, 'createHash', function() {
      test.ok(true);
      return mockHash;
    });

    MonkeyPatcher.patch(crypto, 'createHmac', function() {
      test.ok(true);
      return mockHash;
    });
    var expected = "OAuth,oauth_version=\"1.0\",oauth_signature_method=\"HMAC-SHA1\",oauth_nonce=\"\",oauth_consumer_key=\"\",oauth_timestamp=\"\",oauth_signature=\"whaaaaa\"";

    var result = ar.generateAuthHeader('','','');
    test.deepEqual(result, expected);
    test.done();
  }
示例#2
0
    "test makeId": function(test) {

        test.expect(5);

        mp.patch(Math, 'random', function() {
            test.ok(true);
            return 'random';
        });

        mp.patch(Date, 'now', function(){
            return 'now'
        });

        mp.patch(crypto, 'createHash', function(alg) {

            test.equal(alg, 'md5');

            return {

                update: function(data) {
                    test.equal(data, process.pid + '.nowrandom')
                },

                digest: function(encoding) {
                    test.equal(encoding, 'hex');
                    return 'mock id';
                }
            }
        });

        test.equal(Session.makeId(), 'mock id');
        test.done();
    },
 setUp: function(cb) {
   MonkeyPatcher.setUp();
   MonkeyPatcher.patch(Date, 'now', function() {
     return 42;
   });
   cb();
 },
示例#4
0
 setUp: function(cb) {
     mp.patch(Date, 'now', function() {
         return now;
     });
     
     cb();
 },
示例#5
0
    setUp: function(cb) {

        mp.patch(Date, 'now', function() {
            return now;
        });

        fileServer = new FileServer("/resources", testbench.fixturesDir + '/fileserver');

        cb();
    },
示例#6
0
    "test initialize": function(test) {

        test.expect(4);

        mp.patch(Date, 'now', function() {
            test.ok(true);
            return 72000;
        });

        mp.patch(Session, 'makeId', function() {
            test.ok(true);
            return 'session-id';
        });

        var session = new Session();

        test.equal(session.getLastSaveTime(), 72000);
        test.equal(session.getId(), 'session-id');

        test.done();
    },
示例#7
0
    "test stillValid after end": function(test) {

        var now = 72000;

        mp.patch(Date, 'now', function() {
            return now;
        });

        var session = new Session();
        test.ok(session.stillValid(86400));

        session.end();
        test.ok(!session.stillValid(86400));
        test.done();
    },
示例#8
0
    "test touch": function(test) {

        var now = 72000;
        
        mp.patch(Date, 'now', function() {
            return now;
        });

        var session = new Session();

        test.equal(72000, session.getLastSaveTime());
        
        now = 73000;
        session.touch();
        test.equal(73000, session.getLastSaveTime());

        test.done();
    },
示例#9
0
    "test stillValid": function(test) {

        var now = 72000;
        
        mp.patch(Date, 'now', function() {
            return now;
        });

        var session = new Session();
        test.ok(session.stillValid(86400));

        now += (86400 * 1000) - 1;
        test.ok(session.stillValid(86400));

        now += (86400 * 1000);
        test.ok(!session.stillValid(86400));

        test.done();
    },
 tearDown: function(cb) {
   MonkeyPatcher.tearDown(cb);
 },
 setUp: function(cb) {
   MonkeyPatcher.setUp(cb);
 },
示例#12
0
 tearDown: function(cb) {
     mp.tearDown();
     cb();
 },