MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestCacheControlMaxAgeFail

Function TestCacheControlMaxAgeFail

auth/oidc_test.go:851–888  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

849}
850
851func TestCacheControlMaxAgeFail(t *testing.T) {
852 tests := []struct {
853 name string
854 header http.Header
855 wantMaxAge time.Duration
856 wantOK bool
857 }{{
858 name: "Cache-Control header with max-age directive that has non-integer value",
859 header: http.Header{
860 "Cache-Control": []string{"max-age=foo"},
861 },
862 wantMaxAge: 0,
863 wantOK: false,
864 }, {
865 name: "Cache-Control header with max-age directive that has emnpty value",
866 header: http.Header{
867 "Cache-Control": []string{"max-age="},
868 },
869 wantMaxAge: 0,
870 wantOK: false,
871 }, {
872 name: "Cache-Control header with max-age directive that has no value",
873 header: http.Header{
874 "Cache-Control": []string{"max-age"},
875 },
876 wantMaxAge: 0,
877 wantOK: false,
878 }}
879
880 for _, tc := range tests {
881 t.Run(tc.name, func(t *testing.T) {
882 maxAge, ok, err := cacheControlMaxAge(tc.header)
883 require.Error(t, err, "No error checking max age and expiry")
884 assert.Equal(t, tc.wantMaxAge, maxAge, "max age mismatch")
885 assert.Equal(t, tc.wantOK, ok, " incorrect ok value")
886 })
887 }
888}
889
890func TestGetDiscoveryEndpoint(t *testing.T) {
891 tests := []struct {

Callers

nothing calls this directly

Calls 4

cacheControlMaxAgeFunction · 0.85
RunMethod · 0.65
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected