(t *testing.T)
| 791 | } |
| 792 | |
| 793 | func Test_Middleware_ResetWithContext(t *testing.T) { |
| 794 | t.Parallel() |
| 795 | |
| 796 | handler, store := NewWithStore() |
| 797 | app := fiber.New() |
| 798 | app.Use(handler) |
| 799 | |
| 800 | app.Get("/reset", func(c fiber.Ctx) error { |
| 801 | sess := FromContext(c) |
| 802 | originalID := sess.ID() |
| 803 | sess.Set("key", "value") |
| 804 | if err := sess.ResetWithContext(t.Context()); err != nil { |
| 805 | return err |
| 806 | } |
| 807 | // Assert the actual effect: data is cleared and a new ID is issued. |
| 808 | if sess.ID() == originalID || sess.Get("key") != nil { |
| 809 | return c.SendStatus(fiber.StatusInternalServerError) |
| 810 | } |
| 811 | return c.SendStatus(fiber.StatusOK) |
| 812 | }) |
| 813 | |
| 814 | h := app.Handler() |
| 815 | ctx := &fasthttp.RequestCtx{} |
| 816 | ctx.Request.Header.SetMethod(fiber.MethodGet) |
| 817 | ctx.Request.SetRequestURI("/reset") |
| 818 | h(ctx) |
| 819 | require.Equal(t, fiber.StatusOK, ctx.Response.StatusCode()) |
| 820 | _ = store |
| 821 | } |
| 822 | |
| 823 | func Test_Middleware_RegenerateWithContext(t *testing.T) { |
| 824 | t.Parallel() |
nothing calls this directly
no test coverage detected