Fix interface conversion panic during database creds revoke (#4850)

This commit is contained in:
Jim Kalafut 2018-06-28 09:42:04 -07:00 committed by Brian Kassouf
parent e3bf33b5c7
commit eb70ad032a
2 changed files with 4 additions and 2 deletions

View file

@ -603,7 +603,7 @@ func TestBackend_basic(t *testing.T) {
"username": credsResp.Data["username"],
"role": "plugin-role-test",
"db_name": "plugin-test",
"revocation_statements": []string(nil),
"revocation_statements": []interface{}(nil),
},
},
})

View file

@ -111,7 +111,9 @@ func (b *databaseBackend) secretCredsRevoke() framework.OperationFunc {
if statementsRaw, ok := req.Secret.InternalData["revocation_statements"]; !ok {
return nil, fmt.Errorf("error during revoke: could not find role with name %q or embedded revocation statement data", req.Secret.InternalData["role"])
} else {
statements.Revocation = statementsRaw.([]string)
for _, v := range statementsRaw.([]interface{}) {
statements.Revocation = append(statements.Revocation, v.(string))
}
}
}