MCPcopy
hub / github.com/oauth2-proxy/oauth2-proxy / TestProcessCookieRefreshNotSet

Function TestProcessCookieRefreshNotSet

oauthproxy_test.go:962–982  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

960}
961
962func TestProcessCookieRefreshNotSet(t *testing.T) {
963 pcTest, err := NewProcessCookieTestWithOptionsModifiers(func(opts *options.Options) {
964 opts.Cookie.Expire = time.Duration(23) * time.Hour
965 })
966 if err != nil {
967 t.Fatal(err)
968 }
969
970 reference := time.Now().Add(time.Duration(-2) * time.Hour)
971
972 startSession := &sessions.SessionState{Email: "michael.bland@gsa.gov", AccessToken: "my_access_token", CreatedAt: &reference}
973 err = pcTest.SaveSession(startSession)
974 assert.NoError(t, err)
975
976 session, err := pcTest.LoadCookiedSession()
977 assert.Equal(t, nil, err)
978 if session.Age() < time.Duration(-2)*time.Hour {
979 t.Errorf("cookie too young %v", session.Age())
980 }
981 assert.Equal(t, startSession.Email, session.Email)
982}
983
984func TestProcessCookieFailIfCookieExpired(t *testing.T) {
985 pcTest, err := NewProcessCookieTestWithOptionsModifiers(func(opts *options.Options) {

Callers

nothing calls this directly

Calls 4

AgeMethod · 0.80
SaveSessionMethod · 0.45
LoadCookiedSessionMethod · 0.45

Tested by

no test coverage detected