Skip to content

Commit

Permalink
Fixes race condition in authbase0 test case
Browse files Browse the repository at this point in the history
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] ably/realtime@359930d
  • Loading branch information
VeskeR committed Mar 26, 2024
1 parent 093fa3d commit 7e71eac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/realtime/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7e71eac

Please sign in to comment.