@@ -12,11 +12,13 @@ import (
1212
1313 . "github.com/onsi/ginkgo"
1414 . "github.com/onsi/gomega"
15+ "github.com/pusher/oauth2_proxy/cookie"
1516 "github.com/pusher/oauth2_proxy/pkg/apis/options"
1617 sessionsapi "github.com/pusher/oauth2_proxy/pkg/apis/sessions"
1718 "github.com/pusher/oauth2_proxy/pkg/cookies"
1819 "github.com/pusher/oauth2_proxy/pkg/sessions"
19− "github.com/pusher/oauth2_proxy/pkg/sessions/cookie"
20+ sessionscookie "github.com/pusher/oauth2_proxy/pkg/sessions/cookie"
21+ "github.com/pusher/oauth2_proxy/pkg/sessions/utils"
2022)
2123
2224func TestSessionStore(t *testing.T) {
@@ -200,13 +202,16 @@ var _ = Describe("NewSessionStore", func() {
200202 SessionStoreInterfaceTests()
201203 })
202204
203− Context("with encryption enabled", func() {
205+ Context("with a cipher", func() {
204206 BeforeEach(func() {
205207 secret := make([]byte, 32)
206208 _, err := rand.Read(secret)
207209 Expect(err).ToNot(HaveOccurred())
208210 cookieOpts.CookieSecret = base64.URLEncoding.EncodeToString(secret)
209− opts.EnableCipher = true
211+ cipher, err := cookie.NewCipher(utils.SecretBytes(cookieOpts.CookieSecret))
212+ Expect(err).ToNot(HaveOccurred())
213+ Expect(cipher).ToNot(BeNil())
214+ opts.Cipher = cipher
210215
211216 ss, err = sessions.NewSessionStore(opts, cookieOpts)
212217 Expect(err).ToNot(HaveOccurred())
@@ -214,19 +219,6 @@ var _ = Describe("NewSessionStore", func() {
214219
215220 SessionStoreInterfaceTests()
216221 })
217−
218− Context("with encryption enabled, but no secret", func() {
219− BeforeEach(func() {
220− opts.EnableCipher = true
221− })
222−
223− It("returns an error", func() {
224− ss, err := sessions.NewSessionStore(opts, cookieOpts)
225− Expect(err).To(HaveOccurred())
226− Expect(err.Error()).To(Equal("unable to create cipher: crypto/aes: invalid key size 0"))
227− Expect(ss).To(BeNil())
228− })
229− })
230222 }
231223
232224 BeforeEach(func() {
@@ -264,7 +256,7 @@ var _ = Describe("NewSessionStore", func() {
264256 It("creates a cookie.SessionStore", func() {
265257 ss, err := sessions.NewSessionStore(opts, cookieOpts)
266258 Expect(err).NotTo(HaveOccurred())
267− Expect(ss).To(BeAssignableToTypeOf(&cookie.SessionStore{}))
259+ Expect(ss).To(BeAssignableToTypeOf(&sessionscookie.SessionStore{}))
268260 })
269261
270262 Context("the cookie.SessionStore", func() {