From 7e71eac6878a864142fda4712e43a1ad4e49028d Mon Sep 17 00:00:00 2001 From: Andrew Bulat Date: Tue, 16 Jan 2024 13:01:28 +0000 Subject: [PATCH] Fixes race condition in `authbase0` test case There was an intentional change in realtime code regarding populating `TokenDetails.issued` field based on `timestamp` field provided by the request [1]. Starting from this change, provided `timestamp` field can now used to set the `TokenDetails.issued` field. It is done to "Make it easier to construct reliable tests for eg token expiry and revocation, by controlling the timestamp we pass in." This does, however, mean that in order for time-sensitive tests to work properly and avoid race conditions, we need to always either set `queryTime: true` or set `queryTime: false`. We need to ensure that we use the same value everywhere, so that the realtime code returns `TokenDetails.issued` based on consistent data when we need to check it. This commit does that for the tests where we use `TokenDetails.issued` in assertions. Resolves #1578 [1] https://github.com/ably/realtime/commit/359930d97f19d8b1f0604c1d6c1827b187759f67 --- test/realtime/auth.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/realtime/auth.test.js b/test/realtime/auth.test.js index eacae1f9a..95e9e7112 100644 --- a/test/realtime/auth.test.js +++ b/test/realtime/auth.test.js @@ -64,7 +64,7 @@ define(['ably', 'shared_helper', 'async', 'chai'], function (Ably, helper, async * Base token generation case */ it('authbase0', function (done) { - var realtime = helper.AblyRealtime(); + var realtime = helper.AblyRealtime({ queryTime: true }); whenPromiseSettles(realtime.auth.requestToken(), function (err, tokenDetails) { if (err) { closeAndFinish(done, realtime, err);