2015-04-03 05:21:33 +00:00
|
|
|
package http
|
|
|
|
|
|
|
|
import (
|
2021-06-11 17:18:16 +00:00
|
|
|
"net/http"
|
2015-04-03 05:21:33 +00:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hashicorp/vault/vault"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestHelp(t *testing.T) {
|
|
|
|
core, _, token := vault.TestCoreUnsealed(t)
|
|
|
|
ln, addr := TestServer(t, core)
|
|
|
|
defer ln.Close()
|
|
|
|
TestServerAuth(t, addr, token)
|
|
|
|
|
2022-03-24 19:19:14 +00:00
|
|
|
// request without /v1/ prefix
|
|
|
|
resp := testHttpGet(t, token, addr+"/?help=1")
|
|
|
|
testResponseStatus(t, resp, 404)
|
|
|
|
|
|
|
|
resp = testHttpGet(t, "", addr+"/v1/sys/mounts?help=1")
|
2021-11-23 01:06:59 +00:00
|
|
|
if resp.StatusCode != http.StatusForbidden {
|
|
|
|
t.Fatal("expected permission denied with no token")
|
2021-06-11 17:18:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resp = testHttpGet(t, token, addr+"/v1/sys/mounts?help=1")
|
2015-04-03 05:21:33 +00:00
|
|
|
|
|
|
|
var actual map[string]interface{}
|
|
|
|
testResponseStatus(t, resp, 200)
|
|
|
|
testResponseBody(t, resp, &actual)
|
|
|
|
if _, ok := actual["help"]; !ok {
|
|
|
|
t.Fatalf("bad: %#v", actual)
|
|
|
|
}
|
|
|
|
}
|