(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func TestMakeSessionCookieProperties(t *testing.T) { |
| 148 | ctx := base.TestCtx(t) |
| 149 | testBucket := base.GetTestBucket(t) |
| 150 | defer testBucket.Close(ctx) |
| 151 | dataStore := testBucket.GetSingleDataStore() |
| 152 | auth := NewTestAuthenticator(t, dataStore, nil, DefaultAuthenticatorOptions(ctx)) |
| 153 | |
| 154 | sessionID, err := base.GenerateRandomSecret() |
| 155 | require.NoError(t, err) |
| 156 | mockSession := &LoginSession{ |
| 157 | ID: sessionID, |
| 158 | Username: "jrascagneres", |
| 159 | Expiration: time.Now().Add(2 * time.Hour), |
| 160 | Ttl: 24 * time.Hour, |
| 161 | } |
| 162 | |
| 163 | unsecuredCookie := auth.MakeSessionCookie(mockSession, false, false, http.SameSiteDefaultMode) |
| 164 | assert.False(t, unsecuredCookie.Secure) |
| 165 | |
| 166 | securedCookie := auth.MakeSessionCookie(mockSession, true, false, http.SameSiteDefaultMode) |
| 167 | assert.True(t, securedCookie.Secure) |
| 168 | |
| 169 | httpOnlyFalseCookie := auth.MakeSessionCookie(mockSession, false, false, http.SameSiteDefaultMode) |
| 170 | assert.False(t, httpOnlyFalseCookie.HttpOnly) |
| 171 | |
| 172 | httpOnlyCookie := auth.MakeSessionCookie(mockSession, false, true, http.SameSiteDefaultMode) |
| 173 | assert.True(t, httpOnlyCookie.HttpOnly) |
| 174 | } |
| 175 | |
| 176 | // Coverage for DeleteSessionForCookie. Mock a fake cookie with default cookie name, |
| 177 | // sessionID and expiration; Try to delete the session for the cookie. DocID for session |
nothing calls this directly
no test coverage detected