Skip to content

Commit 3fbd3bd

Browse files
committed
Update bogus refresh and expired token tests
1 parent 2e2cbeb commit 3fbd3bd

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

GotrueTests/AnonKeyClientFailureTests.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ public async Task ClientTriggersTokenRefreshedEvent()
125125
{
126126
await _client.RefreshSession();
127127
});
128+
128129
AreEqual(InvalidRefreshToken, x.Reason);
130+
IsNull(_client.CurrentSession);
129131
}
130132

131133
[TestMethod("Client: expired token")]
@@ -138,18 +140,17 @@ public async Task ExpiredTokenTest()
138140
IsNotNull(emailSession.RefreshToken);
139141
IsNotNull(emailSession.User);
140142

143+
// Set CreatedAt to an old date - this should NOT prevent refresh from working
144+
// Session "expiration" based on CreatedAt is about access token lifetime, not refresh token validity
145+
_client.CurrentSession.CreatedAt = DateTime.UtcNow.AddDays(-10);
146+
147+
// Refresh should still succeed with a valid refresh token
141148
await _client.RefreshSession();
142-
143-
IsNotNull(emailSession.AccessToken);
144-
IsNotNull(emailSession.RefreshToken);
145-
IsNotNull(emailSession.User);
146149

147-
_client.CurrentSession.CreatedAt = DateTime.UtcNow.AddDays(-10);
148-
var x = await ThrowsExceptionAsync<GotrueException>(async () =>
149-
{
150-
await _client.RefreshSession();
151-
});
152-
AreEqual(ExpiredRefreshToken, x.Reason);
150+
IsNotNull(_client.CurrentSession);
151+
IsNotNull(_client.CurrentSession.AccessToken);
152+
IsNotNull(_client.CurrentSession.RefreshToken);
153+
IsNotNull(_client.CurrentSession.User);
153154
}
154155

155156
[TestMethod("Client: Send Reset Password Email for unknown email")]

0 commit comments

Comments
 (0)