mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 11:38:02 +00:00
[DBPW 4/X] Update DB engine to support v4 and v5 interfaces with password policies (#9878)
This commit is contained in:
@@ -4,10 +4,11 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/helper/namespace"
|
||||
postgreshelper "github.com/hashicorp/vault/helper/testhelpers/postgresql"
|
||||
"github.com/hashicorp/vault/sdk/database/dbplugin"
|
||||
"github.com/hashicorp/vault/sdk/database/newdbplugin"
|
||||
"github.com/hashicorp/vault/sdk/framework"
|
||||
"github.com/hashicorp/vault/sdk/logical"
|
||||
)
|
||||
@@ -92,18 +93,22 @@ func TestBackend_RotateRootCredentials_WAL_rollback(t *testing.T) {
|
||||
}
|
||||
|
||||
// Get a connection to the database plugin
|
||||
pc, err := dbBackend.GetConnection(context.Background(),
|
||||
dbi, err := dbBackend.GetConnection(context.Background(),
|
||||
config.StorageView, "plugin-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Alter the database password so it no longer matches what is in storage
|
||||
_, _, err = pc.SetCredentials(context.Background(), dbplugin.Statements{},
|
||||
dbplugin.StaticUserConfig{
|
||||
Username: databaseUser,
|
||||
Password: "newSecret",
|
||||
})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
updateReq := newdbplugin.UpdateUserRequest{
|
||||
Username: databaseUser,
|
||||
Password: &newdbplugin.ChangePassword{
|
||||
NewPassword: "newSecret",
|
||||
},
|
||||
}
|
||||
_, err = dbi.database.UpdateUser(ctx, updateReq, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -335,17 +340,21 @@ func TestBackend_RotateRootCredentials_WAL_no_rollback_2(t *testing.T) {
|
||||
}
|
||||
|
||||
// Get a connection to the database plugin
|
||||
pc, err := dbBackend.GetConnection(context.Background(), config.StorageView, "plugin-test")
|
||||
dbi, err := dbBackend.GetConnection(context.Background(), config.StorageView, "plugin-test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Alter the database password
|
||||
_, _, err = pc.SetCredentials(context.Background(), dbplugin.Statements{},
|
||||
dbplugin.StaticUserConfig{
|
||||
Username: databaseUser,
|
||||
Password: "newSecret",
|
||||
})
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
|
||||
defer cancel()
|
||||
updateReq := newdbplugin.UpdateUserRequest{
|
||||
Username: databaseUser,
|
||||
Password: &newdbplugin.ChangePassword{
|
||||
NewPassword: "newSecret",
|
||||
},
|
||||
}
|
||||
_, err = dbi.database.UpdateUser(ctx, updateReq, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user