From 98d9b5f5894a7281585236381eb8e9fe24a76004 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Tue, 18 Aug 2015 13:33:26 -0700 Subject: [PATCH] Fix tests after #846 Change checkResponse to only expect the configured X-Content-Type-Options header if it doesn't receive a 405 error, which means the handler isn't registered for that method. Signed-off-by: Aaron Lehmann --- registry/handlers/api_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/registry/handlers/api_test.go b/registry/handlers/api_test.go index f3f40aac9..991682206 100644 --- a/registry/handlers/api_test.go +++ b/registry/handlers/api_test.go @@ -1248,8 +1248,10 @@ func checkResponse(t *testing.T, msg string, resp *http.Response, expectedStatus t.FailNow() } - // We expect the headers included in the configuration - if !reflect.DeepEqual(resp.Header["X-Content-Type-Options"], []string{"nosniff"}) { + // We expect the headers included in the configuration, unless the + // status code is 405 (Method Not Allowed), which means the handler + // doesn't even get called. + if resp.StatusCode != 405 && !reflect.DeepEqual(resp.Header["X-Content-Type-Options"], []string{"nosniff"}) { t.Logf("missing or incorrect header X-Content-Type-Options %s", msg) maybeDumpResponse(t, resp)