Skip to content

Commit

Permalink
Address CR
Browse files Browse the repository at this point in the history
- rename handler name prefix "site" to "cluster"
- rename DbServers to DBServers
- removed URI field b/c it is not needed in front
- update test
  • Loading branch information
kimlisa committed Apr 30, 2021
1 parent 88fcee4 commit 099fd45
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 19 deletions.
6 changes: 3 additions & 3 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func NewHandler(cfg Config, opts ...HandlerOption) (*RewritingHandler, error) {
h.GET("/webapi/sites/:site/namespaces/:namespace/nodes", h.WithClusterAuth(h.siteNodesGet))

// Get applications.
h.GET("/webapi/sites/:site/apps", h.WithClusterAuth(h.siteAppsGet))
h.GET("/webapi/sites/:site/apps", h.WithClusterAuth(h.clusterAppsGet))

// active sessions handlers
h.GET("/webapi/sites/:site/namespaces/:namespace/connect", h.WithClusterAuth(h.siteNodeConnect)) // connect to an active session (via websocket)
Expand All @@ -306,10 +306,10 @@ func NewHandler(cfg Config, opts ...HandlerOption) (*RewritingHandler, error) {
h.GET("/webapi/sites/:site/context", h.WithClusterAuth(h.getUserContext))

// Database access handlers.
h.GET("/webapi/sites/:site/databases", h.WithClusterAuth(h.siteDatabasesGet))
h.GET("/webapi/sites/:site/databases", h.WithClusterAuth(h.clusterDatabasesGet))

// Kube access handlers.
h.GET("/webapi/sites/:site/kubernetes", h.WithClusterAuth(h.siteKubesGet))
h.GET("/webapi/sites/:site/kubernetes", h.WithClusterAuth(h.clusterKubesGet))

// OIDC related callback handlers
h.GET("/webapi/oidc/login/web", h.WithRedirect(h.oidcLoginWeb))
Expand Down
3 changes: 1 addition & 2 deletions lib/web/apiserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,6 @@ func TestSiteDatabasesGet(t *testing.T) {
Desc: "test-description",
Procotol: "test-protocol",
Type: types.DatabaseTypeSelfHosted,
URI: "test-uri",
Labels: []ui.Label{{Name: "test-field", Value: "test-value"}},
}, dbs[0])
}
Expand All @@ -1854,7 +1853,7 @@ func TestSiteKubesGet(t *testing.T) {
proxy := env.proxies[0]
pack := proxy.authPack(t, "[email protected]")

endpoint := pack.clt.Endpoint("webapi", "sites", env.server.ClusterName(), "kubes")
endpoint := pack.clt.Endpoint("webapi", "sites", env.server.ClusterName(), "kubernetes")
re, err := pack.clt.Get(context.Background(), endpoint, url.Values{})
require.NoError(t, err)

Expand Down
4 changes: 2 additions & 2 deletions lib/web/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import (
"github.com/julienschmidt/httprouter"
)

// siteAppsGet returns a list of applications in a form the UI can present.
func (h *Handler) siteAppsGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
// clusterAppsGet returns a list of applications in a form the UI can present.
func (h *Handler) clusterAppsGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
appClusterName := p.ByName("site")

// Get a list of application servers.
Expand Down
8 changes: 4 additions & 4 deletions lib/web/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/julienschmidt/httprouter"
)

// siteKubesGet returns a list of kube clusters in a form the UI can present.
func (h *Handler) siteKubesGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
// clusterKubesGet returns a list of kube clusters in a form the UI can present.
func (h *Handler) clusterKubesGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
clt, err := ctx.GetUserClient(site)
if err != nil {
return nil, trace.Wrap(err)
Expand All @@ -42,8 +42,8 @@ func (h *Handler) siteKubesGet(w http.ResponseWriter, r *http.Request, p httprou
return ui.MakeKubes(h.auth.clusterName, kubeServers), nil
}

// siteDatabasesGet returns a list of db servers in a form the UI can present.
func (h *Handler) siteDatabasesGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
// clusterDatabasesGet returns a list of db servers in a form the UI can present.
func (h *Handler) clusterDatabasesGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, ctx *SessionContext, site reversetunnel.RemoteSite) (interface{}, error) {
clt, err := ctx.GetUserClient(site)
if err != nil {
return nil, trace.Wrap(err)
Expand Down
5 changes: 1 addition & 4 deletions lib/web/ui/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,8 @@ type Database struct {
Desc string `json:"desc"`
// Procotol is the database description.
Procotol string `json:"protocol"`
// Type is the database type, self-hosted or AWS RDS.
// Type is the database type, self-hosted or cloud-hosted.
Type string `json:"type"`
// URI is the database connection address.
URI string `json:"uri"`
// Labels is a map of static and dynamic labels associated with an database.
Labels []Label `json:"labels"`
}
Expand Down Expand Up @@ -183,7 +181,6 @@ func MakeDatabases(clusterName string, servers []types.DatabaseServer) []Databas
Desc: server.GetDescription(),
Procotol: server.GetProtocol(),
Type: server.GetType(),
URI: server.GetURI(),
Labels: uiLabels,
})
}
Expand Down
6 changes: 3 additions & 3 deletions lib/web/ui/usercontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ type userACL struct {
Nodes access `json:"nodes"`
// AppServers defines access to application servers
AppServers access `json:"appServers"`
// DbServers defines access to database servers.
DbServers access `json:"dbServers"`
// DBServers defines access to database servers.
DBServers access `json:"dbServers"`
// KubeServers defines access to kubernetes servers.
KubeServers access `json:"kubeServers"`
// SSH defines access to servers
Expand Down Expand Up @@ -193,7 +193,7 @@ func NewUserContext(user types.User, userRoles services.RoleSet) (*UserContext,
acl := userACL{
AccessRequests: requestAccess,
AppServers: appServerAccess,
DbServers: dbServerAccess,
DBServers: dbServerAccess,
KubeServers: kubeServerAccess,
AuthConnectors: authConnectors,
TrustedClusters: trustedClusterAccess,
Expand Down
2 changes: 1 addition & 1 deletion lib/web/ui/usercontext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (s *UserContextSuite) TestNewUserContext(c *check.C) {
c.Assert(userContext.ACL.AuthConnectors, check.DeepEquals, allowed)
c.Assert(userContext.ACL.TrustedClusters, check.DeepEquals, allowed)
c.Assert(userContext.ACL.AppServers, check.DeepEquals, denied)
c.Assert(userContext.ACL.DbServers, check.DeepEquals, denied)
c.Assert(userContext.ACL.DBServers, check.DeepEquals, denied)
c.Assert(userContext.ACL.KubeServers, check.DeepEquals, denied)
c.Assert(userContext.ACL.Events, check.DeepEquals, denied)
c.Assert(userContext.ACL.Sessions, check.DeepEquals, denied)
Expand Down

0 comments on commit 099fd45

Please sign in to comment.