(t *testing.T)
| 349 | } |
| 350 | |
| 351 | func TestIsNotAuthenticatedSecurecookie(t *testing.T) { |
| 352 | t.Parallel() |
| 353 | |
| 354 | ctx := context.Background() |
| 355 | conf, reg := pkg.NewFastRegistryWithMocks(t) |
| 356 | r := httprouterx.NewTestRouterPublic(t) |
| 357 | r.GET("/public/with-callback", reg.SessionHandler().IsNotAuthenticated(send(http.StatusOK), send(http.StatusBadRequest))) |
| 358 | |
| 359 | ts := httptest.NewServer(r) |
| 360 | defer ts.Close() |
| 361 | conf.MustSet(ctx, config.ViperKeyPublicBaseURL, ts.URL) |
| 362 | |
| 363 | c := testhelpers.NewClientWithCookies(t) |
| 364 | c.Jar.SetCookies(urlx.ParseOrPanic(ts.URL), []*http.Cookie{ |
| 365 | { |
| 366 | Name: config.DefaultSessionCookieName, |
| 367 | // This is an invalid cookie because it is generated by a very random secret |
| 368 | Value: "MTU3Mjg4Njg0MXxEdi1CQkFFQ180SUFBUkFCRUFBQU52LUNBQUVHYzNSeWFXNW5EQVVBQTNOcFpBWnpkSEpwYm1jTUd3QVpUWFZXVUhSQlZVeExXRWRUUmxkVVoyUkpUVXhzY201SFNBPT187kdI3dMP-ep389egDR2TajYXGG-6xqC2mAlgnBi0vsg=", |
| 369 | HttpOnly: true, |
| 370 | Path: "/", |
| 371 | Expires: time.Now().Add(time.Hour), |
| 372 | }, |
| 373 | }) |
| 374 | |
| 375 | res, err := c.Get(ts.URL + "/public/with-callback") |
| 376 | require.NoError(t, err) |
| 377 | |
| 378 | assert.EqualValues(t, http.StatusOK, res.StatusCode) |
| 379 | } |
| 380 | |
| 381 | func TestIsNotAuthenticated(t *testing.T) { |
| 382 | t.Parallel() |
nothing calls this directly
no test coverage detected