Merge pull request #9439 from influxdata/mr-metauser-isadmin

Remove IsAdmin() method from meta.User interface
pull/9445/head
Mark Rushakoff 2018-02-14 09:05:17 -08:00 committed by GitHub
commit 26545b33d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -599,7 +599,7 @@ func TestMetaClient_CreateUser(t *testing.T) {
if exp, got := "fred", u.ID(); exp != got {
t.Fatalf("unexpected user name: exp: %s got: %s", exp, got)
}
if !u.IsAdmin() {
if !isAdmin(u) {
t.Fatalf("expected user to be admin")
}
@ -650,7 +650,7 @@ func TestMetaClient_CreateUser(t *testing.T) {
if exp, got := "wilma", u.ID(); exp != got {
t.Fatalf("unexpected user name: exp: %s got: %s", exp, got)
}
if u.IsAdmin() {
if isAdmin(u) {
t.Fatalf("expected user not to be an admin")
}
@ -670,7 +670,7 @@ func TestMetaClient_CreateUser(t *testing.T) {
if exp, got := "wilma", u.ID(); exp != got {
t.Fatalf("unexpected user name: exp: %s got: %s", exp, got)
}
if !u.IsAdmin() {
if !isAdmin(u) {
t.Fatalf("expected user to be an admin")
}
@ -686,7 +686,7 @@ func TestMetaClient_CreateUser(t *testing.T) {
if exp, got := "wilma", u.ID(); exp != got {
t.Fatalf("unexpected user name: exp: %s got: %s", exp, got)
}
if u.IsAdmin() {
if isAdmin(u) {
t.Fatalf("expected user not to be an admin")
}
@ -1163,3 +1163,8 @@ func testTempDir(skip int) string {
}
return dir
}
func isAdmin(u meta.User) bool {
ui := u.(*meta.UserInfo)
return ui.Admin
}

View File

@ -1579,17 +1579,12 @@ type UserInfo struct {
type User interface {
query.Authorizer
ID() string
IsAdmin() bool
}
func (u *UserInfo) ID() string {
return u.Name
}
func (u *UserInfo) IsAdmin() bool {
return u.Admin
}
// AuthorizeDatabase returns true if the user is authorized for the given privilege on the given database.
func (ui *UserInfo) AuthorizeDatabase(privilege influxql.Privilege, database string) bool {
if ui.Admin || privilege == influxql.NoPrivileges {