diff options
author | Rasmus Dahlberg <rasmus@mullvad.net> | 2022-04-01 02:27:52 +0200 |
---|---|---|
committer | Rasmus Dahlberg <rasmus@mullvad.net> | 2022-04-01 02:56:42 +0200 |
commit | aa903b2f5356f35a486a8e7e6ef92e9db332748e (patch) | |
tree | 3fff6448da782fdebffe9d24bf9b70edca14d396 /pkg/instance/instance_test.go | |
parent | b09d20111227be5e6d5126ec905b44a7a4e96b0d (diff) |
fix non-compliant use of HTTP status code 405
See RFC 7231, ยง6.5.5.
Diffstat (limited to 'pkg/instance/instance_test.go')
-rw-r--r-- | pkg/instance/instance_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
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) + } + } +} |