@@ -36,7 +36,7 @@ func TestBasicSessionStore(t *testing.T) {
36
36
require .Equal (t , StateReserved , s1 .State )
37
37
38
38
// Move session 1 to the created state. This should succeed.
39
- err = db .ShiftState (s1 .ID , StateCreated )
39
+ err = db .ShiftState (ctx , s1 .ID , StateCreated )
40
40
require .NoError (t , err )
41
41
42
42
// Show that the session is now in the created state.
@@ -46,7 +46,7 @@ func TestBasicSessionStore(t *testing.T) {
46
46
47
47
// Trying to move session 1 again should have no effect since it is
48
48
// already in the created state.
49
- require .NoError (t , db .ShiftState (s1 .ID , StateCreated ))
49
+ require .NoError (t , db .ShiftState (ctx , s1 .ID , StateCreated ))
50
50
51
51
// Reserve and create a few more sessions. We increment the time by one
52
52
// second between each session to ensure that the created at time is
@@ -107,7 +107,7 @@ func TestBasicSessionStore(t *testing.T) {
107
107
require .Equal (t , session1 .State , StateCreated )
108
108
109
109
// Now revoke the session and assert that the state is revoked.
110
- require .NoError (t , db .ShiftState (s1 .ID , StateRevoked ))
110
+ require .NoError (t , db .ShiftState (ctx , s1 .ID , StateRevoked ))
111
111
s1 , err = db .GetSession (ctx , s1 .LocalPublicKey )
112
112
require .NoError (t , err )
113
113
require .Equal (t , s1 .State , StateRevoked )
@@ -198,6 +198,7 @@ func TestBasicSessionStore(t *testing.T) {
198
198
// TestLinkingSessions tests that session linking works as expected.
199
199
func TestLinkingSessions (t * testing.T ) {
200
200
t .Parallel ()
201
+ ctx := context .Background ()
201
202
202
203
// Set up a new DB.
203
204
clock := clock .NewTestClock (testTime )
@@ -227,7 +228,7 @@ func TestLinkingSessions(t *testing.T) {
227
228
require .ErrorContains (t , err , "is still active" )
228
229
229
230
// Revoke the first session.
230
- require .NoError (t , db .ShiftState (s1 .ID , StateRevoked ))
231
+ require .NoError (t , db .ShiftState (ctx , s1 .ID , StateRevoked ))
231
232
232
233
// Persisting the second linked session should now work.
233
234
_ , err = reserveSession (db , "session 2" , withLinkedGroupID (& s1 .GroupID ))
@@ -255,10 +256,10 @@ func TestLinkedSessions(t *testing.T) {
255
256
// first session.
256
257
s1 := createSession (t , db , "session 1" )
257
258
258
- require .NoError (t , db .ShiftState (s1 .ID , StateRevoked ))
259
+ require .NoError (t , db .ShiftState (ctx , s1 .ID , StateRevoked ))
259
260
s2 := createSession (t , db , "session 2" , withLinkedGroupID (& s1 .GroupID ))
260
261
261
- require .NoError (t , db .ShiftState (s2 .ID , StateRevoked ))
262
+ require .NoError (t , db .ShiftState (ctx , s2 .ID , StateRevoked ))
262
263
s3 := createSession (t , db , "session 3" , withLinkedGroupID (& s2 .GroupID ))
263
264
264
265
// Assert that the session ID to group ID index works as expected.
@@ -277,7 +278,7 @@ func TestLinkedSessions(t *testing.T) {
277
278
// To ensure that different groups don't interfere with each other,
278
279
// let's add another set of linked sessions not linked to the first.
279
280
s4 := createSession (t , db , "session 4" )
280
- require .NoError (t , db .ShiftState (s4 .ID , StateRevoked ))
281
+ require .NoError (t , db .ShiftState (ctx , s4 .ID , StateRevoked ))
281
282
s5 := createSession (t , db , "session 5" , withLinkedGroupID (& s4 .GroupID ))
282
283
require .NotEqual (t , s4 .GroupID , s1 .GroupID )
283
284
@@ -319,7 +320,7 @@ func TestStateShift(t *testing.T) {
319
320
require .Equal (t , time.Time {}, s1 .RevokedAt )
320
321
321
322
// Shift the state of the session to StateRevoked.
322
- err = db .ShiftState (s1 .ID , StateRevoked )
323
+ err = db .ShiftState (ctx , s1 .ID , StateRevoked )
323
324
require .NoError (t , err )
324
325
325
326
// This should have worked. Since it is now in a terminal state, the
@@ -334,13 +335,13 @@ func TestStateShift(t *testing.T) {
334
335
// should not have changed though.
335
336
prevTime := clock .Now ()
336
337
clock .SetTime (prevTime .Add (time .Second ))
337
- err = db .ShiftState (s1 .ID , StateRevoked )
338
+ err = db .ShiftState (ctx , s1 .ID , StateRevoked )
338
339
require .NoError (t , err )
339
340
require .True (t , prevTime .Equal (s1 .RevokedAt ))
340
341
341
342
// Trying to shift the state from a terminal state back to StateCreated
342
343
// should also fail since this is not a legal state transition.
343
- err = db .ShiftState (s1 .ID , StateCreated )
344
+ err = db .ShiftState (ctx , s1 .ID , StateCreated )
344
345
require .ErrorContains (t , err , "illegal session state transition" )
345
346
}
346
347
@@ -394,7 +395,7 @@ func createSession(t *testing.T, db Store, label string,
394
395
s , err := reserveSession (db , label , mods ... )
395
396
require .NoError (t , err )
396
397
397
- err = db .ShiftState (s .ID , StateCreated )
398
+ err = db .ShiftState (context . Background (), s .ID , StateCreated )
398
399
require .NoError (t , err )
399
400
400
401
s , err = db .GetSessionByID (context .Background (), s .ID )
0 commit comments