@@ -12,11 +12,13 @@ import (
12
12
13
13
. "github.com/onsi/ginkgo"
14
14
. "github.com/onsi/gomega"
15
+ "github.com/pusher/oauth2_proxy/cookie"
15
16
"github.com/pusher/oauth2_proxy/pkg/apis/options"
16
17
sessionsapi "github.com/pusher/oauth2_proxy/pkg/apis/sessions"
17
18
"github.com/pusher/oauth2_proxy/pkg/cookies"
18
19
"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"
20
22
)
21
23
22
24
func TestSessionStore (t * testing.T ) {
@@ -200,33 +202,23 @@ var _ = Describe("NewSessionStore", func() {
200
202
SessionStoreInterfaceTests ()
201
203
})
202
204
203
- Context ("with encryption enabled " , func () {
205
+ Context ("with a cipher " , func () {
204
206
BeforeEach (func () {
205
207
secret := make ([]byte , 32 )
206
208
_ , err := rand .Read (secret )
207
209
Expect (err ).ToNot (HaveOccurred ())
208
210
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
210
215
211
216
ss , err = sessions .NewSessionStore (opts , cookieOpts )
212
217
Expect (err ).ToNot (HaveOccurred ())
213
218
})
214
219
215
220
SessionStoreInterfaceTests ()
216
221
})
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
- })
230
222
}
231
223
232
224
BeforeEach (func () {
@@ -264,7 +256,7 @@ var _ = Describe("NewSessionStore", func() {
264
256
It ("creates a cookie.SessionStore" , func () {
265
257
ss , err := sessions .NewSessionStore (opts , cookieOpts )
266
258
Expect (err ).NotTo (HaveOccurred ())
267
- Expect (ss ).To (BeAssignableToTypeOf (& cookie .SessionStore {}))
259
+ Expect (ss ).To (BeAssignableToTypeOf (& sessionscookie .SessionStore {}))
268
260
})
269
261
270
262
Context ("the cookie.SessionStore" , func () {
0 commit comments