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

Function Test_Session_getExtractorInfo

middleware/session/session_test.go:813–849  ·  view source on GitHub ↗

Test_Session_getExtractorInfo exercises the extractor-resolution branches directly, including the nil-config safe default and single (non-chained) configured extractors.

(t *testing.T)

Source from the content-addressed store, hash-verified

811// directly, including the nil-config safe default and single (non-chained)
812// configured extractors.
813func Test_Session_getExtractorInfo(t *testing.T) {
814 t.Parallel()
815
816 t.Run("nil config returns safe cookie default", func(t *testing.T) {
817 t.Parallel()
818 sess := &Session{}
819 got := sess.getExtractorInfo()
820 require.Len(t, got, 1)
821 require.Equal(t, extractors.SourceCookie, got[0].Source)
822 require.Equal(t, "session_id", got[0].Key)
823 })
824
825 t.Run("single cookie extractor", func(t *testing.T) {
826 t.Parallel()
827 store := NewStore(Config{Extractor: extractors.FromCookie("session_id")})
828 sess := &Session{config: store}
829 got := sess.getExtractorInfo()
830 require.Len(t, got, 1)
831 require.Equal(t, extractors.SourceCookie, got[0].Source)
832 })
833
834 t.Run("single header extractor", func(t *testing.T) {
835 t.Parallel()
836 store := NewStore(Config{Extractor: extractors.FromHeader("x-session-id")})
837 sess := &Session{config: store}
838 got := sess.getExtractorInfo()
839 require.Len(t, got, 1)
840 require.Equal(t, extractors.SourceHeader, got[0].Source)
841 })
842
843 t.Run("single read-only extractor yields no writable sink", func(t *testing.T) {
844 t.Parallel()
845 store := NewStore(Config{Extractor: extractors.FromQuery("session_id")})
846 sess := &Session{config: store}
847 require.Empty(t, sess.getExtractorInfo())
848 })
849}
850
851func Test_Session_Save_IdleTimeout(t *testing.T) {
852 t.Parallel()

Callers

nothing calls this directly

Calls 6

getExtractorInfoMethod · 0.95
FromCookieFunction · 0.92
FromHeaderFunction · 0.92
FromQueryFunction · 0.92
NewStoreFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected