1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-06-23 00:40:46 +02:00

Refreshing with an invalid session should work

I would like this test to pass, but it currently doesn't. With the 
current implementation, there is a race, if the session is locked, but 
releases before the "handleObtainLockError" starts, then you'll get an 
error, which is not desirable
This commit is contained in:
Joel Speed
2021-12-03 23:44:18 +00:00
parent 1478fefe92
commit 327211cec9

View File

@ -613,7 +613,7 @@ var _ = Describe("Stored Session Suite", func() {
ObtainError: errors.New("not able to obtain lock"), ObtainError: errors.New("not able to obtain lock"),
}, },
}), }),
Entry("when obtaining lock failed", refreshSessionIfNeededTableInput{ Entry("when obtaining lock failed with a valid session", refreshSessionIfNeededTableInput{
refreshPeriod: 1 * time.Minute, refreshPeriod: 1 * time.Minute,
session: &sessionsapi.SessionState{ session: &sessionsapi.SessionState{
RefreshToken: noRefresh, RefreshToken: noRefresh,
@ -630,6 +630,24 @@ var _ = Describe("Stored Session Suite", func() {
ObtainError: errors.New("not able to obtain lock"), ObtainError: errors.New("not able to obtain lock"),
}, },
}), }),
Entry("when obtaining lock failed with an invalid session", refreshSessionIfNeededTableInput{
refreshPeriod: 1 * time.Minute,
session: &sessionsapi.SessionState{
RefreshToken: noRefresh,
CreatedAt: &createdPast,
ExpiresOn: &createdPast,
Lock: &TestLock{
ObtainError: errors.New("not able to obtain lock"),
},
},
expectedErr: nil,
expectRefreshed: true,
expectValidated: false,
expectedLockState: TestLock{
PeekedCount: 2,
ObtainError: errors.New("not able to obtain lock"),
},
}),
Entry("when the session is not refreshed by the provider", refreshSessionIfNeededTableInput{ Entry("when the session is not refreshed by the provider", refreshSessionIfNeededTableInput{
refreshPeriod: 1 * time.Minute, refreshPeriod: 1 * time.Minute,
session: &sessionsapi.SessionState{ session: &sessionsapi.SessionState{