2018-10-19 16:04:07 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2018-10-19 16:04:07 +00:00
|
|
|
)
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
func TestHTTPHandlers_ACLLegacy(t *testing.T) {
|
2020-12-07 18:42:55 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("too slow for testing.Short")
|
|
|
|
}
|
|
|
|
|
2018-10-19 16:04:07 +00:00
|
|
|
t.Parallel()
|
2020-03-31 19:59:56 +00:00
|
|
|
a := NewTestAgent(t, "")
|
2018-10-19 16:04:07 +00:00
|
|
|
defer a.Shutdown()
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
type testCase struct {
|
|
|
|
method string
|
|
|
|
path string
|
2018-10-19 16:04:07 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
run := func(t *testing.T, tc testCase) {
|
|
|
|
req, err := http.NewRequest(tc.method, tc.path, nil)
|
|
|
|
require.NoError(t, err)
|
2018-10-19 16:04:07 +00:00
|
|
|
resp := httptest.NewRecorder()
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
a.srv.h.ServeHTTP(resp, req)
|
2021-10-26 19:20:57 +00:00
|
|
|
require.Equal(t, http.StatusGone, resp.Code)
|
2021-07-20 21:07:40 +00:00
|
|
|
require.Contains(t, resp.Body.String(), "the legacy ACL system was removed")
|
2020-12-07 18:42:55 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
var testCases = []testCase{
|
|
|
|
{method: http.MethodPut, path: "/v1/acl/create"},
|
|
|
|
{method: http.MethodPut, path: "/v1/acl/update"},
|
|
|
|
{method: http.MethodPut, path: "/v1/acl/destroy/ID"},
|
|
|
|
{method: http.MethodGet, path: "/v1/acl/info/ID"},
|
|
|
|
{method: http.MethodPut, path: "/v1/acl/clone/ID"},
|
|
|
|
{method: http.MethodGet, path: "/v1/acl/list"},
|
2018-10-19 16:04:07 +00:00
|
|
|
}
|
|
|
|
|
2021-07-20 21:07:40 +00:00
|
|
|
for _, tc := range testCases {
|
|
|
|
t.Run(tc.method+tc.path, func(t *testing.T) {
|
|
|
|
run(t, tc)
|
|
|
|
})
|
2018-10-19 16:04:07 +00:00
|
|
|
}
|
|
|
|
}
|