route/cmd/routed/server_test.go

30 lines
563 B
Go
Raw Normal View History

2017-12-15 18:18:13 +00:00
package main
2017-10-06 17:54:09 +00:00
import (
"net/http"
"testing"
)
func TestDirector(t *testing.T) {
s := &Server{}
req, err := http.NewRequest("GET", "https://cetacean.club/", nil)
if err != nil {
t.Fatal(err)
}
req.Header.Add("X-Forwarded-For", "Rick-James")
req.Header.Add("X-Client-Ip", "56.32.51.84")
s.Director(req)
for _, header := range []string{"X-Forwarded-For", "X-Client-Ip"} {
t.Run(header, func(t *testing.T) {
val := req.Header.Get(header)
if val != "" {
t.Fatalf("expected header %q to have no value, got: %v", header, val)
}
})
}
}