MCPcopy
hub / github.com/rs/cors / TestOptionsSuccessStatusCodeOverride

Function TestOptionsSuccessStatusCodeOverride

cors_test.go:769–792  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

767}
768
769func TestOptionsSuccessStatusCodeOverride(t *testing.T) {
770 s := New(Options{
771 OptionsSuccessStatus: http.StatusOK,
772 })
773
774 req, _ := http.NewRequest("OPTIONS", "http://example.com/foo", nil)
775 req.Header.Add("Access-Control-Request-Method", "GET")
776
777 t.Run("Handler", func(t *testing.T) {
778 res := httptest.NewRecorder()
779 s.Handler(testHandler).ServeHTTP(res, req)
780 assertResponse(t, res, http.StatusOK)
781 })
782 t.Run("HandlerFunc", func(t *testing.T) {
783 res := httptest.NewRecorder()
784 s.HandlerFunc(res, req)
785 assertResponse(t, res, http.StatusOK)
786 })
787 t.Run("Negroni", func(t *testing.T) {
788 res := httptest.NewRecorder()
789 s.ServeHTTP(res, req, testHandler)
790 assertResponse(t, res, http.StatusOK)
791 })
792}
793
794func TestAccessControlExposeHeadersPresence(t *testing.T) {
795 cases := []struct {

Callers

nothing calls this directly

Calls 5

assertResponseFunction · 0.85
ServeHTTPMethod · 0.80
HandlerMethod · 0.80
HandlerFuncMethod · 0.80
NewFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…