Skip to content

Commit

Permalink
FABC-408 Add CORS support
Browse files Browse the repository at this point in the history
Cleanup test

Change-Id: I87fc45ce73be16a859169ad034e1c2cd3a3b8253
Signed-off-by: Gari Singh <gari.r.singh@gmail.com>
  • Loading branch information
mastersingh24 committed Apr 4, 2019
1 parent 71ce992 commit e59884d
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions lib/server_whitebox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ package lib

import (
"context"
"fmt"
"net"
"net/http"
"net/http/httptest"
"os"
Expand Down Expand Up @@ -226,19 +224,9 @@ func TestCORS(t *testing.T) {
},
}

fakeCounter := &metricsfakes.Counter{}
fakeCounter.WithReturns(fakeCounter)
fakeHist := &metricsfakes.Histogram{}
fakeHist.WithReturns(fakeHist)

for _, test := range tests {
_test := test
t.Run("", func(t *testing.T) {
lis, err := net.Listen("tcp", "localhost:0")
if err != nil {
t.Fatalf("Failed to create listener: %s", err)
}
t.Log(lis.Addr().String())
s := &Server{
Config: &ServerConfig{
CORS: _test.cors,
Expand All @@ -247,7 +235,7 @@ func TestCORS(t *testing.T) {
handler := http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
rw.WriteHeader(http.StatusOK)
})
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("http://%s", lis.Addr().String()), nil)
req := httptest.NewRequest(http.MethodGet, "http://localhost", nil)
req.Header.Set("Origin", _test.origin)
rw := httptest.NewRecorder()
s.cors(handler).ServeHTTP(rw, req)
Expand Down

0 comments on commit e59884d

Please sign in to comment.