'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(); }
"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(); },
setUp: function(cb) { mp.patch(Date, 'now', function() { return now; }); cb(); },
setUp: function(cb) { mp.patch(Date, 'now', function() { return now; }); fileServer = new FileServer("/resources", testbench.fixturesDir + '/fileserver'); cb(); },
"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(); },
"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(); },
"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(); },
"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); },
tearDown: function(cb) { mp.tearDown(); cb(); },