mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
Check ErrPluginStaticUnsupported for fallback to RotateRootCredentials (#11585)
This commit is contained in:
@@ -152,7 +152,7 @@ func (d databaseVersionWrapper) changePasswordLegacy(ctx context.Context, userna
|
||||
err = d.changeUserPasswordLegacy(ctx, username, passwordChange)
|
||||
|
||||
// If changing the root user's password but SetCredentials is unimplemented, fall back to RotateRootCredentials
|
||||
if isRootUser && status.Code(err) == codes.Unimplemented {
|
||||
if isRootUser && (err == v4.ErrPluginStaticUnsupported || status.Code(err) == codes.Unimplemented) {
|
||||
saveConfig, err = d.changeRootUserPasswordLegacy(ctx, passwordChange)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
v4 "github.com/hashicorp/vault/sdk/database/dbplugin"
|
||||
v5 "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
"github.com/stretchr/testify/mock"
|
||||
@@ -672,7 +673,7 @@ func TestUpdateUser_legacyDB(t *testing.T) {
|
||||
expectedConfig: nil,
|
||||
expectErr: true,
|
||||
},
|
||||
"change password - RotateRootCredentials": {
|
||||
"change password - RotateRootCredentials (gRPC Unimplemented)": {
|
||||
req: v5.UpdateUserRequest{
|
||||
Username: "existing_user",
|
||||
Password: &v5.ChangePassword{
|
||||
@@ -696,6 +697,30 @@ func TestUpdateUser_legacyDB(t *testing.T) {
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
"change password - RotateRootCredentials (ErrPluginStaticUnsupported)": {
|
||||
req: v5.UpdateUserRequest{
|
||||
Username: "existing_user",
|
||||
Password: &v5.ChangePassword{
|
||||
NewPassword: "newpassowrd",
|
||||
},
|
||||
},
|
||||
isRootUser: true,
|
||||
|
||||
setCredentialsErr: v4.ErrPluginStaticUnsupported,
|
||||
setCredentialsCalls: 1,
|
||||
|
||||
rotateRootConfig: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
rotateRootCalls: 1,
|
||||
|
||||
renewUserCalls: 0,
|
||||
|
||||
expectedConfig: map[string]interface{}{
|
||||
"foo": "bar",
|
||||
},
|
||||
expectErr: false,
|
||||
},
|
||||
"change password - RotateRootCredentials failed": {
|
||||
req: v5.UpdateUserRequest{
|
||||
Username: "existing_user",
|
||||
|
||||
Reference in New Issue
Block a user