MCPcopy
hub / github.com/gofiber/fiber / Test_deleteTokenFromStorage

Function Test_deleteTokenFromStorage

middleware/csrf/csrf_test.go:2129–2158  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2127}
2128
2129func Test_deleteTokenFromStorage(t *testing.T) {
2130 t.Parallel()
2131
2132 app := fiber.New()
2133 ctx := app.AcquireCtx(&fasthttp.RequestCtx{})
2134 t.Cleanup(func() { app.ReleaseCtx(ctx) })
2135
2136 token := "token123"
2137 dummy := []byte("dummy")
2138
2139 store := session.NewStore()
2140 sm := newSessionManager(store)
2141 stm := newStorageManager(nil, true)
2142
2143 sm.setRaw(ctx, token, dummy, time.Minute)
2144 cfg := Config{Session: store}
2145 require.NoError(t, deleteTokenFromStorage(ctx, token, &cfg, sm, stm))
2146 raw := sm.getRaw(ctx, token, dummy)
2147 require.Nil(t, raw)
2148
2149 sm2 := newSessionManager(nil)
2150 stm2 := newStorageManager(nil, true)
2151
2152 require.NoError(t, stm2.setRaw(context.Background(), token, dummy, time.Minute))
2153 cfg = Config{}
2154 require.NoError(t, deleteTokenFromStorage(ctx, token, &cfg, sm2, stm2))
2155 raw, err := stm2.getRaw(context.Background(), token)
2156 require.NoError(t, err)
2157 require.Nil(t, raw)
2158}
2159
2160func Test_storageManager_logKey(t *testing.T) {
2161 t.Parallel()

Callers

nothing calls this directly

Calls 9

NewStoreFunction · 0.92
newSessionManagerFunction · 0.85
newStorageManagerFunction · 0.85
deleteTokenFromStorageFunction · 0.85
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewMethod · 0.65
setRawMethod · 0.45
getRawMethod · 0.45

Tested by

no test coverage detected