From aa903b2f5356f35a486a8e7e6ef92e9db332748e Mon Sep 17 00:00:00 2001 From: Rasmus Dahlberg Date: Fri, 1 Apr 2022 02:27:52 +0200 Subject: fix non-compliant use of HTTP status code 405 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See RFC 7231, ยง6.5.5. --- pkg/instance/instance_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 pkg/instance/instance_test.go (limited to 'pkg/instance/instance_test.go') diff --git a/pkg/instance/instance_test.go b/pkg/instance/instance_test.go new file mode 100644 index 0000000..00d996d --- /dev/null +++ b/pkg/instance/instance_test.go @@ -0,0 +1,23 @@ +package instance + +import ( + "net/http" + "testing" +) + +func CheckHTTPMethod(t *testing.T) { + var instance Instance + for _, table := range []struct { + method string + wantOK bool + }{ + {wantOK: false, method: http.MethodHead}, + {wantOK: true, method: http.MethodPost}, + {wantOK: true, method: http.MethodGet}, + } { + ok := instance.checkHTTPMethod(table.method) + if got, want := ok, table.wantOK; got != want { + t.Errorf("%s: got %v but wanted %v", table.method, got, want) + } + } +} -- cgit v1.2.3