mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
DBPW - Copy newdbplugin package to dbplugin/v5 (#10151)
This is part 1 of 4 for renaming the `newdbplugin` package. This copies the existing package to the new location but keeps the current one in place so we can migrate the existing references over more easily.
This commit is contained in:
@@ -9,14 +9,13 @@ import (
|
||||
|
||||
stdmysql "github.com/go-sql-driver/mysql"
|
||||
mysqlhelper "github.com/hashicorp/vault/helper/testhelpers/mysql"
|
||||
|
||||
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
|
||||
"github.com/hashicorp/vault/sdk/database/helper/credsutil"
|
||||
"github.com/hashicorp/vault/sdk/database/helper/dbutil"
|
||||
"github.com/hashicorp/vault/sdk/database/newdbplugin"
|
||||
"github.com/hashicorp/vault/sdk/helper/strutil"
|
||||
)
|
||||
|
||||
var _ newdbplugin.Database = (*MySQL)(nil)
|
||||
var _ dbplugin.Database = (*MySQL)(nil)
|
||||
|
||||
func TestMySQL_Initialize(t *testing.T) {
|
||||
cleanup, connURL := mysqlhelper.PrepareTestContainer(t, false, "secret")
|
||||
@@ -26,7 +25,7 @@ func TestMySQL_Initialize(t *testing.T) {
|
||||
"connection_url": connURL,
|
||||
}
|
||||
|
||||
initReq := newdbplugin.InitializeRequest{
|
||||
initReq := dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -52,7 +51,7 @@ func TestMySQL_Initialize(t *testing.T) {
|
||||
"max_open_connections": "5",
|
||||
}
|
||||
|
||||
initReq = newdbplugin.InitializeRequest{
|
||||
initReq = dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -73,12 +72,12 @@ func TestMySQL_CreateUser(t *testing.T) {
|
||||
t.Fatalf("unable to generate password: %s", err)
|
||||
}
|
||||
|
||||
createReq := newdbplugin.NewUserRequest{
|
||||
UsernameConfig: newdbplugin.UsernameMetadata{
|
||||
createReq := dbplugin.NewUserRequest{
|
||||
UsernameConfig: dbplugin.UsernameMetadata{
|
||||
DisplayName: "test",
|
||||
RoleName: "test",
|
||||
},
|
||||
Statements: newdbplugin.Statements{
|
||||
Statements: dbplugin.Statements{
|
||||
Commands: []string{},
|
||||
},
|
||||
Password: password,
|
||||
@@ -103,7 +102,7 @@ func TestMySQL_CreateUser(t *testing.T) {
|
||||
"connection_url": connURL,
|
||||
}
|
||||
|
||||
initReq := newdbplugin.InitializeRequest{
|
||||
initReq := dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -126,7 +125,7 @@ func TestMySQL_CreateUser(t *testing.T) {
|
||||
"connection_url": connURL,
|
||||
}
|
||||
|
||||
initReq := newdbplugin.InitializeRequest{
|
||||
initReq := dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -188,12 +187,12 @@ func testCreateUser(t *testing.T, db *MySQL, connURL string) {
|
||||
t.Fatalf("unable to generate password: %s", err)
|
||||
}
|
||||
|
||||
createReq := newdbplugin.NewUserRequest{
|
||||
UsernameConfig: newdbplugin.UsernameMetadata{
|
||||
createReq := dbplugin.NewUserRequest{
|
||||
UsernameConfig: dbplugin.UsernameMetadata{
|
||||
DisplayName: "test",
|
||||
RoleName: "test",
|
||||
},
|
||||
Statements: newdbplugin.Statements{
|
||||
Statements: dbplugin.Statements{
|
||||
Commands: test.createStmts,
|
||||
},
|
||||
Password: password,
|
||||
@@ -256,7 +255,7 @@ func TestMySQL_RotateRootCredentials(t *testing.T) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
initReq := newdbplugin.InitializeRequest{
|
||||
initReq := dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -271,11 +270,11 @@ func TestMySQL_RotateRootCredentials(t *testing.T) {
|
||||
t.Fatal("Database should be initialized")
|
||||
}
|
||||
|
||||
updateReq := newdbplugin.UpdateUserRequest{
|
||||
updateReq := dbplugin.UpdateUserRequest{
|
||||
Username: "root",
|
||||
Password: &newdbplugin.ChangePassword{
|
||||
Password: &dbplugin.ChangePassword{
|
||||
NewPassword: "different_sercret",
|
||||
Statements: newdbplugin.Statements{
|
||||
Statements: dbplugin.Statements{
|
||||
Commands: test.statements,
|
||||
},
|
||||
},
|
||||
@@ -331,7 +330,7 @@ func TestMySQL_DeleteUser(t *testing.T) {
|
||||
"connection_url": connURL,
|
||||
}
|
||||
|
||||
initReq := newdbplugin.InitializeRequest{
|
||||
initReq := dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -349,12 +348,12 @@ func TestMySQL_DeleteUser(t *testing.T) {
|
||||
t.Fatalf("unable to generate password: %s", err)
|
||||
}
|
||||
|
||||
createReq := newdbplugin.NewUserRequest{
|
||||
UsernameConfig: newdbplugin.UsernameMetadata{
|
||||
createReq := dbplugin.NewUserRequest{
|
||||
UsernameConfig: dbplugin.UsernameMetadata{
|
||||
DisplayName: "test",
|
||||
RoleName: "test",
|
||||
},
|
||||
Statements: newdbplugin.Statements{
|
||||
Statements: dbplugin.Statements{
|
||||
Commands: []string{`
|
||||
CREATE USER '{{name}}'@'%' IDENTIFIED BY '{{password}}';
|
||||
GRANT SELECT ON *.* TO '{{name}}'@'%';`,
|
||||
@@ -377,9 +376,9 @@ func TestMySQL_DeleteUser(t *testing.T) {
|
||||
t.Fatalf("Could not connect with new credentials: %s", err)
|
||||
}
|
||||
|
||||
deleteReq := newdbplugin.DeleteUserRequest{
|
||||
deleteReq := dbplugin.DeleteUserRequest{
|
||||
Username: userResp.Username,
|
||||
Statements: newdbplugin.Statements{
|
||||
Statements: dbplugin.Statements{
|
||||
Commands: test.revokeStmts,
|
||||
},
|
||||
}
|
||||
@@ -436,7 +435,7 @@ func TestMySQL_UpdateUser(t *testing.T) {
|
||||
"connection_url": connURL,
|
||||
}
|
||||
|
||||
initReq := newdbplugin.InitializeRequest{
|
||||
initReq := dbplugin.InitializeRequest{
|
||||
Config: connectionDetails,
|
||||
VerifyConnection: true,
|
||||
}
|
||||
@@ -456,11 +455,11 @@ func TestMySQL_UpdateUser(t *testing.T) {
|
||||
t.Fatalf("unable to generate password: %s", err)
|
||||
}
|
||||
|
||||
updateReq := newdbplugin.UpdateUserRequest{
|
||||
updateReq := dbplugin.UpdateUserRequest{
|
||||
Username: dbUser,
|
||||
Password: &newdbplugin.ChangePassword{
|
||||
Password: &dbplugin.ChangePassword{
|
||||
NewPassword: newPassword,
|
||||
Statements: newdbplugin.Statements{
|
||||
Statements: dbplugin.Statements{
|
||||
Commands: test.rotateStmts,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user