pomerium/proxy/handlers_test.go
Bobby DeSimone ebc1453292
proxy: use internal/httputil for error handling (#36)
- General formatting and comment cleanup.
- Inject pomerium version at compiletime via template package.
2019-01-30 12:22:03 -08:00

26 lines
653 B
Go

package proxy
import (
"fmt"
"net/http"
"net/http/httptest"
"testing"
)
func TestProxy_RobotsTxt(t *testing.T) {
proxy := Proxy{}
req, err := http.NewRequest("GET", "/robots.txt", nil)
if err != nil {
t.Fatal(err)
}
rr := httptest.NewRecorder()
handler := http.HandlerFunc(proxy.RobotsTxt)
handler.ServeHTTP(rr, req)
if status := rr.Code; status != http.StatusOK {
t.Errorf("handler returned wrong status code: got %v want %v", status, http.StatusOK)
}
expected := fmt.Sprintf("User-agent: *\nDisallow: /")
if rr.Body.String() != expected {
t.Errorf("handler returned wrong body: got %v want %v", rr.Body.String(), expected)
}
}