From aebc76e6730d4c44c0ab2add29343eb4ec343db8 Mon Sep 17 00:00:00 2001 From: Lloyd Hilaiel <lloyd@hilaiel.com> Date: Thu, 29 Mar 2012 01:52:40 -0600 Subject: [PATCH] (test fix) when checking that certificate duration is correct based on 'ephemeral' argument to cert_key api, allow a 200ms window to account for a small elapsed time between setting of iat and exp - which occurs on a system under load or slower virtualized environments (like travisci) --- tests/session-duration-test.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/session-duration-test.js b/tests/session-duration-test.js index 0e5fdd825..bc0fc4596 100755 --- a/tests/session-duration-test.js +++ b/tests/session-duration-test.js @@ -178,6 +178,11 @@ suite.addBatch({ var kp = jwk.KeyPair.generate("RS", 64); +assert.within = function(got, expected, margin) { + assert.ok(got + margin > expected); + assert.ok(got - margin < expected); +} + suite.addBatch({ "cert_key invoked with ephemeral = false": { topic: wsapi.post('/wsapi/cert_key', { @@ -197,7 +202,9 @@ suite.addBatch({ var cert = new jws.JWS(); cert.parse(r.body); var pl = JSON.parse(cert.payload); - assert.strictEqual(pl.exp - pl.iat, config.get('certificate_validity_ms')); + assert.within(pl.exp - pl.iat, + config.get('certificate_validity_ms'), + 200); } } }); @@ -221,7 +228,9 @@ suite.addBatch({ var cert = new jws.JWS(); cert.parse(r.body); var pl = JSON.parse(cert.payload); - assert.strictEqual(pl.exp - pl.iat, config.get('ephemeral_session_duration_ms')); + assert.within(pl.exp - pl.iat, + config.get('ephemeral_session_duration_ms'), + 200); } } }); -- GitLab