MCPcopy
hub / github.com/ory/kratos / TestIsNotAuthenticatedSecurecookie

Function TestIsNotAuthenticatedSecurecookie

session/handler_test.go:351–379  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

349}
350
351func 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
381func TestIsNotAuthenticated(t *testing.T) {
382 t.Parallel()

Callers

nothing calls this directly

Calls 11

NewFastRegistryWithMocksFunction · 0.92
NewClientWithCookiesFunction · 0.92
sendFunction · 0.85
IsNotAuthenticatedMethod · 0.80
MustSetMethod · 0.80
GETMethod · 0.65
SessionHandlerMethod · 0.65
CloseMethod · 0.65
NowMethod · 0.65
AddMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected