Skip to content

Commit

Permalink
Update Preflight test to negroni
Browse files Browse the repository at this point in the history
  • Loading branch information
hariharan-uno committed Oct 16, 2014
1 parent ccee371 commit 3584de0
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package cors
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -164,7 +165,6 @@ func Test_DefaultAllowHeaders(t *testing.T) {
}
}

/*
func Test_Preflight(t *testing.T) {
recorder := NewRecorder()
n := negroni.New()
Expand All @@ -174,13 +174,17 @@ func Test_Preflight(t *testing.T) {
AllowHeaders: []string{"Origin", "X-whatever", "X-CaseSensitive"},
}
n.Use(negroni.HandlerFunc(opts.Allow))
// TODO: Rewrite handler in negroni
m.Options("foo", func(res http.ResponseWriter) {
res.WriteHeader(500)
mux := http.NewServeMux()
mux.HandleFunc("/foo", func(w http.ResponseWriter, req *http.Request) {
if req.Method == "OPTIONS" {
w.WriteHeader(500)
return
}
return
})
n.UseHandler(mux)

r, _ := http.NewRequest("OPTIONS", "foo", nil)
r, _ := http.NewRequest("OPTIONS", "/foo", nil)
r.Header.Add(headerRequestMethod, "PUT")
r.Header.Add(headerRequestHeaders, "X-whatever, x-casesensitive")
n.ServeHTTP(recorder, r)
Expand Down Expand Up @@ -210,7 +214,7 @@ func Test_Preflight(t *testing.T) {
t.Errorf("Status code is expected to be 200, found %d", recorder.Code)
}
}
*/

func Benchmark_WithoutCORS(b *testing.B) {
recorder := httptest.NewRecorder()
n := negroni.New()
Expand Down

0 comments on commit 3584de0

Please sign in to comment.