From b770aeca6334aa7f669acca31c08ca3438b6a6a7 Mon Sep 17 00:00:00 2001 From: Joel Speed Date: Thu, 16 May 2019 17:25:41 +0100 Subject: [PATCH] Clean up persistent SessionStore tests --- pkg/sessions/session_store_test.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkg/sessions/session_store_test.go b/pkg/sessions/session_store_test.go index ff074e2..b4e36ca 100644 --- a/pkg/sessions/session_store_test.go +++ b/pkg/sessions/session_store_test.go @@ -122,7 +122,7 @@ var _ = Describe("NewSessionStore", func() { Expect(err).ToNot(HaveOccurred()) }) - It("sets a `set-cookie` header in the response and session to not be loadable after clear", func() { + It("sets a `set-cookie` header in the response", func() { Expect(response.Header().Get("Set-Cookie")).ToNot(BeEmpty()) }) @@ -169,8 +169,9 @@ var _ = Describe("NewSessionStore", func() { }) } + // The following should only be for server stores PersistentSessionStoreTests := func() { - Context("when Clear is called the session should not be recoverable", func() { + Context("when Clear is called on a persistent store", func() { var loadedAfterClear *sessionsapi.SessionState BeforeEach(func() { req := httptest.NewRequest("GET", "http://example.com/", nil) @@ -185,16 +186,21 @@ var _ = Describe("NewSessionStore", func() { err = ss.Clear(response, request) Expect(err).ToNot(HaveOccurred()) - // The following should only be for server stores loadReq := httptest.NewRequest("GET", "http://example.com/", nil) for _, c := range resultCookies { loadReq.AddCookie(c) } + loadedAfterClear, err = ss.Load(loadReq) + // If we have cleared the session, Load should fail + Expect(err).To(HaveOccurred()) }) - It("sets a `set-cookie` header in the response and session to not be loadable after clear", func() { + It("sets a `set-cookie` header in the response", func() { Expect(response.Header().Get("Set-Cookie")).ToNot(BeEmpty()) + }) + + It("attempting to Load returns an empty session", func() { Expect(loadedAfterClear).To(BeNil()) })