Fix role related tests after rebase

pull/10616/head
Michael Desa 2017-11-06 11:31:44 -05:00
parent 9b194168a6
commit bd4d5c6cc3
3 changed files with 22 additions and 21 deletions

View File

@ -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)

View File

@ -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")

View File

@ -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,
},
},
},