mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-05 04:16:31 +02:00
Return a more helpful error message for unknown db roles (#6157)
* return a more helpful err msg * update test, print fmt * fix other test failure
This commit is contained in:
parent
8f1f0d7aab
commit
7ba7309b8b
@ -1156,8 +1156,8 @@ func TestBackend_allowedRoles(t *testing.T) {
|
||||
Data: data,
|
||||
}
|
||||
credsResp, err := b.HandleRequest(namespace.RootContext(nil), req)
|
||||
if err != logical.ErrPermissionDenied {
|
||||
t.Fatalf("expected error to be:%s got:%#v\n", logical.ErrPermissionDenied, err)
|
||||
if err == nil {
|
||||
t.Fatal("expected error because role is denied")
|
||||
}
|
||||
|
||||
// update connection with glob allowed roles connection
|
||||
@ -1254,8 +1254,8 @@ func TestBackend_allowedRoles(t *testing.T) {
|
||||
Data: data,
|
||||
}
|
||||
credsResp, err = b.HandleRequest(namespace.RootContext(nil), req)
|
||||
if err != logical.ErrPermissionDenied {
|
||||
t.Fatalf("expected error to be:%s got:%#v\n", logical.ErrPermissionDenied, err)
|
||||
if err == nil {
|
||||
t.Fatal("expected error because role is denied")
|
||||
}
|
||||
|
||||
// Get creds from allowed role, should work.
|
||||
|
||||
@ -51,7 +51,7 @@ func (b *databaseBackend) pathCredsCreateRead() framework.OperationFunc {
|
||||
// If role name isn't in the database's allowed roles, send back a
|
||||
// permission denied.
|
||||
if !strutil.StrListContains(dbConfig.AllowedRoles, "*") && !strutil.StrListContainsGlob(dbConfig.AllowedRoles, name) {
|
||||
return nil, logical.ErrPermissionDenied
|
||||
return nil, fmt.Errorf("%q is not an allowed role", name)
|
||||
}
|
||||
|
||||
// Get the Database object
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user