Skip to content

Commit 337000a

Browse files
gaultierory-bot
authored andcommitted
fix: fix expires_at timestamp not in UTC leading to local test failures
GitOrigin-RevId: 560d958391b12ace6db9d4c05074719e96e0329e
1 parent ae2dda1 commit 337000a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

persistence/sql/persister_consent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ func (p *Persister) ConfirmLoginSession(ctx context.Context, loginSession *flow.
455455

456456
loginSession.NID = p.NetworkID(ctx)
457457
loginSession.AuthenticatedAt = sqlxx.NullTime(time.Time(loginSession.AuthenticatedAt).Truncate(time.Second))
458-
loginSession.ExpiresAt = sqlxx.NullTime(time.Now().Truncate(time.Second).Add(p.config.GetAuthenticationSessionLifespan(ctx)))
458+
loginSession.ExpiresAt = sqlxx.NullTime(time.Now().Truncate(time.Second).Add(p.config.GetAuthenticationSessionLifespan(ctx)).UTC())
459459

460460
if p.Connection(ctx).Dialect.Name() == "mysql" {
461461
// MySQL does not support UPSERT.

persistence/sql/persister_nid_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ func (s *PersisterTestSuite) TestConfirmLoginSession() {
187187
require.NoError(t, r.Persister().ConfirmLoginSession(s.t1, ls))
188188
actual := &flow.LoginSession{}
189189
require.NoError(t, r.Persister().Connection(context.Background()).Find(actual, ls.ID))
190+
191+
require.True(t, time.Time(ls.AuthenticatedAt).UTC().Equal(time.Time(actual.AuthenticatedAt).UTC()))
192+
require.True(t, time.Time(ls.ExpiresAt).UTC().Equal(time.Time(actual.ExpiresAt).UTC()))
193+
190194
exp, _ := json.Marshal(ls)
191195
act, _ := json.Marshal(actual)
192196
require.JSONEq(t, string(exp), string(act))

0 commit comments

Comments
 (0)