From bd4d5c6cc3c5379285adb68c67bca460e431c4a9 Mon Sep 17 00:00:00 2001 From: Michael Desa Date: Mon, 6 Nov 2017 11:31:44 -0500 Subject: [PATCH] Fix role related tests after rebase --- server/me.go | 2 +- server/organizations.go | 5 +++-- server/users_test.go | 36 ++++++++++++++++++------------------ 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/server/me.go b/server/me.go index 2cb49fc18a..41f627c304 100644 --- a/server/me.go +++ b/server/me.go @@ -220,7 +220,7 @@ func (s *Service) Me(w http.ResponseWriter, r *http.Request) { if !hasRoleInDefaultOrganization(usr) { usr.Roles = append(usr.Roles, chronograf.Role{ Organization: "0", - Name: MemberRoleName, + Name: roles.MemberRoleName, }) if err := s.Store.Users(ctx).Update(ctx, usr); err != nil { unknownErrorWithMessage(w, err, s.Logger) diff --git a/server/organizations.go b/server/organizations.go index a61274c8dd..abac14776b 100644 --- a/server/organizations.go +++ b/server/organizations.go @@ -8,6 +8,7 @@ import ( "github.com/bouk/httprouter" "github.com/influxdata/chronograf" + "github.com/influxdata/chronograf/roles" ) func parseOrganizationID(id string) (uint64, error) { @@ -36,11 +37,11 @@ func (r *organizationRequest) ValidUpdate() error { func (r *organizationRequest) ValidDefaultRole() error { if r.DefaultRole == "" { - r.DefaultRole = MemberRoleName + r.DefaultRole = roles.MemberRoleName } switch r.DefaultRole { - case MemberRoleName, ViewerRoleName, EditorRoleName, AdminRoleName: + case roles.MemberRoleName, roles.ViewerRoleName, roles.EditorRoleName, roles.AdminRoleName: return nil default: return fmt.Errorf("default role must be member, viewer, editor, or admin") diff --git a/server/users_test.go b/server/users_test.go index 48669be228..e1e221b322 100644 --- a/server/users_test.go +++ b/server/users_test.go @@ -177,11 +177,11 @@ func TestService_NewUser(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - Name: AdminRoleName, + Name: roles.AdminRoleName, Organization: "bobbetta org", }, { - Name: ViewerRoleName, + Name: roles.ViewerRoleName, Organization: "billieta org", }, }, @@ -198,11 +198,11 @@ func TestService_NewUser(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - Name: AdminRoleName, + Name: roles.AdminRoleName, Organization: "bobbetta org", }, { - Name: ViewerRoleName, + Name: roles.ViewerRoleName, Organization: "billieta org", }, }, @@ -229,11 +229,11 @@ func TestService_NewUser(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - Name: AdminRoleName, + Name: roles.AdminRoleName, Organization: "bobbetta org", }, { - Name: ViewerRoleName, + Name: roles.ViewerRoleName, Organization: "bobbetta org", }, }, @@ -250,11 +250,11 @@ func TestService_NewUser(t *testing.T) { Scheme: "oauth2", Roles: []chronograf.Role{ { - Name: AdminRoleName, + Name: roles.AdminRoleName, Organization: "bobbetta org", }, { - Name: ViewerRoleName, + Name: roles.ViewerRoleName, Organization: "bobbetta org", }, }, @@ -547,7 +547,7 @@ func TestService_UpdateUser(t *testing.T) { Provider: "github", Scheme: "oauth2", Roles: []chronograf.Role{ - EditorRole, + roles.EditorRole, }, }, nil default: @@ -567,11 +567,11 @@ func TestService_UpdateUser(t *testing.T) { ID: 1336, Roles: []chronograf.Role{ { - Name: AdminRoleName, + Name: roles.AdminRoleName, Organization: "bobbetta org", }, { - Name: ViewerRoleName, + Name: roles.ViewerRoleName, Organization: "billieta org", }, }, @@ -599,7 +599,7 @@ func TestService_UpdateUser(t *testing.T) { Provider: "github", Scheme: "oauth2", Roles: []chronograf.Role{ - EditorRole, + roles.EditorRole, }, }, nil default: @@ -619,11 +619,11 @@ func TestService_UpdateUser(t *testing.T) { ID: 1336, Roles: []chronograf.Role{ { - Name: AdminRoleName, + Name: roles.AdminRoleName, Organization: "bobbetta org", }, { - Name: ViewerRoleName, + Name: roles.ViewerRoleName, Organization: "bobbetta org", }, }, @@ -651,7 +651,7 @@ func TestService_UpdateUser(t *testing.T) { Provider: "github", Scheme: "oauth2", Roles: []chronograf.Role{ - EditorRole, + roles.EditorRole, }, }, nil default: @@ -672,7 +672,7 @@ func TestService_UpdateUser(t *testing.T) { ID: 1336, SuperAdmin: true, Roles: []chronograf.Role{ - AdminRole, + roles.AdminRole, }, }, }, @@ -698,7 +698,7 @@ func TestService_UpdateUser(t *testing.T) { Provider: "github", Scheme: "oauth2", Roles: []chronograf.Role{ - EditorRole, + roles.EditorRole, }, }, nil default: @@ -719,7 +719,7 @@ func TestService_UpdateUser(t *testing.T) { ID: 1336, SuperAdmin: true, Roles: []chronograf.Role{ - AdminRole, + roles.AdminRole, }, }, },