Remove IsAdmin() method from meta.User interface

The method was only called in tests.
pull/9439/head
Mark Rushakoff 2018-02-13 16:47:48 -08:00
parent 56b4a91acf
commit f7fc6a6501
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 {