mirror of
https://github.com/rqlite/rqlite.git
synced 2022-10-30 02:37:32 +03:00
Clean up unncessary conditional. Add explicit auth/ tests for empty credentials/anonymous case
This commit is contained in:
@@ -227,10 +227,19 @@ func Test_AuthPermsAA(t *testing.T) {
|
||||
if store.AA("nonexistent", "password1", "foo") {
|
||||
t.Fatalf("nonexistent authenticated and authorized for foo")
|
||||
}
|
||||
|
||||
if !store.AA("nonexistent", "password1", "qux") {
|
||||
t.Fatalf("nonexistent not authenticated and authorized for qux")
|
||||
}
|
||||
|
||||
// explicit check of anonymous user
|
||||
if !store.AA("", "", "qux") {
|
||||
t.Fatalf("anonymous incorrectly not authorized")
|
||||
}
|
||||
if store.AA("", "", "foo") {
|
||||
t.Fatalf("anonymous incorrectly authorized")
|
||||
}
|
||||
|
||||
if !store.AA("username1", "password1", "foo") {
|
||||
t.Fatalf("username1 not authenticated and authorized for foo")
|
||||
}
|
||||
|
||||
@@ -182,12 +182,9 @@ func (s *Service) checkCommandPerm(c *Command, perm string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
var username string
|
||||
var password string
|
||||
if c.Credentials == nil {
|
||||
username = ""
|
||||
password = ""
|
||||
} else {
|
||||
username := ""
|
||||
password := ""
|
||||
if c.Credentials != nil {
|
||||
username = c.Credentials.GetUsername()
|
||||
password = c.Credentials.GetPassword()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user