1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-08-10 22:51:31 +02:00

Improve error message when no cookie is found

This commit is contained in:
Joel Speed
2021-10-13 18:48:09 +01:00
parent 6cc7da8993
commit d8deaa124b
5 changed files with 34 additions and 14 deletions

View File

@@ -452,21 +452,38 @@ func SessionStoreInterfaceTests(in *testInput) {
})
Context("when Load is called", func() {
BeforeEach(func() {
req := httptest.NewRequest("GET", "http://example.com/", nil)
resp := httptest.NewRecorder()
err := in.ss().Save(resp, req, in.session)
Expect(err).ToNot(HaveOccurred())
Context("with a valid session cookie in the request", func() {
BeforeEach(func() {
req := httptest.NewRequest("GET", "http://example.com/", nil)
resp := httptest.NewRecorder()
err := in.ss().Save(resp, req, in.session)
Expect(err).ToNot(HaveOccurred())
for _, cookie := range resp.Result().Cookies() {
in.request.AddCookie(cookie)
}
})
for _, cookie := range resp.Result().Cookies() {
in.request.AddCookie(cookie)
}
Context("before the refresh period", func() {
LoadSessionTests(in)
})
})
Context("before the refresh period", func() {
LoadSessionTests(in)
})
Context("with no cookies in the request", func() {
var loadedSession *sessionsapi.SessionState
var loadErr error
BeforeEach(func() {
loadedSession, loadErr = in.ss().Load(in.request)
})
It("returns an empty session", func() {
Expect(loadedSession).To(BeNil())
})
It("should return a no cookie error", func() {
Expect(loadErr).To(MatchError(http.ErrNoCookie))
})
})
})
}