File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,9 +32,12 @@ type Sessions struct {
3232 CookieFactory * CookieFactory
3333}
3434
35- func NewSessions (cache Cache [* conceal.Text , Identity ]) * Sessions {
35+ // NewSessions creates a new Sessions for managing sessions and cookies
36+ // associated with those sessions.
37+ func NewSessions (cookies * CookieFactory , cache Cache [* conceal.Text , Identity ]) * Sessions {
3638 return & Sessions {
37- Cache : cache ,
39+ Cache : cache ,
40+ CookieFactory : cookies ,
3841 }
3942}
4043
Original file line number Diff line number Diff line change @@ -29,15 +29,12 @@ func TestSessions_Create(t *testing.T) {
2929
3030 cache := & mockCache {storage : make (map [string ]Identity )}
3131
32- // initialize the cookie factory
33- sessions := & Sessions {
34- Cache : cache ,
35- CookieFactory : & CookieFactory {
36- Name : "session-token" ,
37- Secure : true ,
38- Clock : testNow ,
39- },
40- }
32+ // initialize the sessions manager with the cache and a cookie factory
33+ sessions := NewSessions (& CookieFactory {
34+ Name : "session-token" ,
35+ Secure : true ,
36+ Clock : testNow ,
37+ }, cache )
4138
4239 id := Identity (12345 )
4340 ttl := 1 * time .Hour
@@ -66,8 +63,9 @@ func TestSessions_Create(t *testing.T) {
6663func TestSessions_Match (t * testing.T ) {
6764 t .Parallel ()
6865
66+ cookies := (* CookieFactory )(nil )
6967 cache := & mockCache {storage : make (map [string ]Identity )}
70- sessions := NewSessions (cache )
68+ sessions := NewSessions (cookies , cache )
7169
7270 id := Identity (12345 )
7371 token := conceal .UUIDv4 ()
You can’t perform that action at this time.
0 commit comments