@@ -373,26 +373,19 @@ void main() {
373
373
final session =
374
374
'{"access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2ODAzNDE3MDUsInN1YiI6IjRkMjU4M2RhLThkZTQtNDlkMy05Y2QxLTM3YTlhNzRmNTViZCIsImVtYWlsIjoiZmFrZTE2ODAzMzgxMDVAZW1haWwuY29tIiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCIsInByb3ZpZGVycyI6WyJlbWFpbCJdfSwidXNlcl9tZXRhZGF0YSI6eyJIZWxsbyI6IldvcmxkIn0sInJvbGUiOiIiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJwYXNzd29yZCIsInRpbWVzdGFtcCI6MTY4MDMzODEwNX1dLCJzZXNzaW9uX2lkIjoiYzhiOTg2Y2UtZWJkZC00ZGUxLWI4MjAtZjIyOWYyNjg1OGIwIn0.0x1rFlPKbIU1rZPY1SH_FNSZaXerfkFA1Y-EOlhuzUs","expires_in":3600,"refresh_token":"-yeS4omysFs9tpUYBws9Rg","token_type":"bearer","provider_token":null,"provider_refresh_token":null,"user":{"id":"4d2583da-8de4-49d3-9cd1-37a9a74f55bd","app_metadata":{"provider":"email","providers":["email"]},"user_metadata":{"Hello":"World"},"aud":"","email":"
[email protected] ","phone":"","created_at":"2023-04-01T08:35:05.208586Z","confirmed_at":null,"email_confirmed_at":"2023-04-01T08:35:05.220096086Z","phone_confirmed_at":null,"last_sign_in_at":"2023-04-01T08:35:05.222755878Z","role":"","updated_at":"2023-04-01T08:35:05.226938Z"},"expiresAt":1680341705}';
375
375
376
- ///These 3 are bundled and in sum 4 refresh token requests are made, because the first 3 fail in [RetryTestHttpClient]
377
- final future1 = Future .wait ([
378
- client.recoverSession (session),
376
+ ///These 3 are bundled and in sum 1 refresh token requests is made, because the first 3 fail in [RetryTestHttpClient]
377
+ final responses = await Future .wait ([
379
378
client.recoverSession (session),
380
379
client.recoverSession (session),
381
380
]);
382
381
383
- await expectLater (future1, throwsA (isA <ClientException >()));
384
- expect (httpClient.retryCount, 1 );
385
-
386
- /// Again these 3 are bundled and only one refresh token request is made
387
- final future2 = Future .wait ([
388
- client.recoverSession (session),
389
- client.recoverSession (session),
390
- client.recoverSession (session),
391
- ]);
382
+ expect (responses[0 ].session? .accessToken, isNotNull);
383
+ expect (
384
+ responses[0 ].session? .accessToken,
385
+ responses[1 ].session? .accessToken,
386
+ );
392
387
393
- await expectLater (future2, throwsA (isA <ClientException >()));
394
- expect (client.onAuthStateChange, emits (isA <AuthState >()));
395
- expect (httpClient.retryCount, 2 );
388
+ expect (httpClient.retryCount, 4 );
396
389
});
397
390
398
391
test ('Sign out on wrong refresh token' , () async {
@@ -410,10 +403,10 @@ void main() {
410
403
]),
411
404
);
412
405
413
- final session =
406
+ final expiredSession =
414
407
getSessionData (DateTime .now ().subtract (Duration (hours: 1 )));
415
408
416
- await expectLater (client.recoverSession (session .sessionString),
409
+ await expectLater (client.recoverSession (expiredSession .sessionString),
417
410
throwsA (isA <AuthException >()));
418
411
expect (stream, emitsError (isA <AuthException >()));
419
412
0 commit comments