-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the new
ListResources
in the webapi layer (#11019)
Supports pagination and filtering for the web UI Part of RFD 55
- Loading branch information
Showing
7 changed files
with
280 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -537,7 +537,7 @@ func (s *WebSuite) TestSAMLSuccess(c *C) { | |
|
||
err = s.server.Auth().CreateSAMLConnector(connector) | ||
c.Assert(err, IsNil) | ||
s.server.Auth().SetClock(clockwork.NewFakeClockAt(time.Date(2017, 05, 10, 18, 53, 0, 0, time.UTC))) | ||
s.server.Auth().SetClock(clockwork.NewFakeClockAt(time.Date(2017, 5, 10, 18, 53, 0, 0, time.UTC))) | ||
clt := s.clientNoRedirects() | ||
|
||
csrfToken := "2ebcb768d0090ea4368e42880c970b61865c326172a4a2343b645cf5d7f20992" | ||
|
@@ -773,6 +773,7 @@ func TestClusterNodesGet(t *testing.T) { | |
nodes := clusterNodesGetResponse{} | ||
require.NoError(t, json.Unmarshal(re.Bytes(), &nodes)) | ||
require.Len(t, nodes.Items, 1) | ||
require.Equal(t, 1, nodes.TotalCount) | ||
|
||
// Get nodes using shortcut. | ||
re, err = pack.clt.Get(context.Background(), pack.clt.Endpoint("webapi", "sites", currentSiteShortcut, "nodes"), url.Values{}) | ||
|
@@ -2247,7 +2248,8 @@ func TestClusterDatabasesGet(t *testing.T) { | |
require.NoError(t, err) | ||
|
||
type testResponse struct { | ||
Items []ui.Database `json:"items"` | ||
Items []ui.Database `json:"items"` | ||
TotalCount int `json:"totalCount"` | ||
} | ||
|
||
// No db registered. | ||
|
@@ -2277,6 +2279,7 @@ func TestClusterDatabasesGet(t *testing.T) { | |
resp = testResponse{} | ||
require.NoError(t, json.Unmarshal(re.Bytes(), &resp)) | ||
require.Len(t, resp.Items, 1) | ||
require.Equal(t, 1, resp.TotalCount) | ||
require.EqualValues(t, ui.Database{ | ||
Name: "test-db-name", | ||
Desc: "test-description", | ||
|
@@ -2297,7 +2300,8 @@ func TestClusterKubesGet(t *testing.T) { | |
require.NoError(t, err) | ||
|
||
type testResponse struct { | ||
Items []ui.Kube `json:"items"` | ||
Items []ui.KubeCluster `json:"items"` | ||
TotalCount int `json:"totalCount"` | ||
} | ||
|
||
// No kube registered. | ||
|
@@ -2332,12 +2336,70 @@ func TestClusterKubesGet(t *testing.T) { | |
resp = testResponse{} | ||
require.NoError(t, json.Unmarshal(re.Bytes(), &resp)) | ||
require.Len(t, resp.Items, 1) | ||
require.EqualValues(t, ui.Kube{ | ||
require.Equal(t, 1, resp.TotalCount) | ||
require.EqualValues(t, ui.KubeCluster{ | ||
Name: "test-kube-name", | ||
Labels: []ui.Label{{Name: "test-field", Value: "test-value"}}, | ||
}, resp.Items[0]) | ||
} | ||
|
||
func TestClusterAppsGet(t *testing.T) { | ||
env := newWebPack(t, 1) | ||
|
||
proxy := env.proxies[0] | ||
pack := proxy.authPack(t, "[email protected]") | ||
|
||
type testResponse struct { | ||
Items []ui.App `json:"items"` | ||
TotalCount int `json:"totalCount"` | ||
} | ||
|
||
resource := &types.AppServerV3{ | ||
Metadata: types.Metadata{Name: "test-app"}, | ||
Kind: types.KindAppServer, | ||
Version: types.V2, | ||
Spec: types.AppServerSpecV3{ | ||
HostID: "hostid", | ||
App: &types.AppV3{ | ||
Metadata: types.Metadata{ | ||
Name: "name", | ||
Description: "description", | ||
Labels: map[string]string{"test-field": "test-value"}, | ||
}, | ||
Spec: types.AppSpecV3{ | ||
URI: "https://console.aws.amazon.com", // sets field awsConsole to true | ||
PublicAddr: "publicaddrs", | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
// Register a app service. | ||
_, err := env.server.Auth().UpsertApplicationServer(context.Background(), resource) | ||
require.NoError(t, err) | ||
|
||
// Make the call. | ||
endpoint := pack.clt.Endpoint("webapi", "sites", env.server.ClusterName(), "apps") | ||
re, err := pack.clt.Get(context.Background(), endpoint, url.Values{}) | ||
require.NoError(t, err) | ||
|
||
// Test correct response. | ||
resp := testResponse{} | ||
require.NoError(t, json.Unmarshal(re.Bytes(), &resp)) | ||
require.Len(t, resp.Items, 1) | ||
require.Equal(t, 1, resp.TotalCount) | ||
require.EqualValues(t, ui.App{ | ||
Name: resource.Spec.App.GetName(), | ||
Description: resource.Spec.App.GetDescription(), | ||
URI: resource.Spec.App.GetURI(), | ||
PublicAddr: resource.Spec.App.GetPublicAddr(), | ||
Labels: []ui.Label{{Name: "test-field", Value: "test-value"}}, | ||
FQDN: resource.Spec.App.GetPublicAddr(), | ||
ClusterID: env.server.ClusterName(), | ||
AWSConsole: true, | ||
}, resp.Items[0]) | ||
} | ||
|
||
// TestApplicationAccessDisabled makes sure application access can be disabled | ||
// via modules. | ||
func TestApplicationAccessDisabled(t *testing.T) { | ||
|
@@ -3594,8 +3656,8 @@ func newWebPack(t *testing.T, numProxies int) *webPack { | |
} | ||
|
||
func createProxy(ctx context.Context, t *testing.T, proxyID string, node *regular.Server, authServer *auth.TestTLSServer, | ||
hostSigners []ssh.Signer, clock clockwork.FakeClock) *proxy { | ||
|
||
hostSigners []ssh.Signer, clock clockwork.FakeClock, | ||
) *proxy { | ||
// create reverse tunnel service: | ||
client, err := authServer.NewClient(auth.TestIdentity{ | ||
I: auth.BuiltinRole{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.