mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Fix MSSQL Root Rotation Statement (#4748)
* fixing default rotate statement for MSSQL * only run with ACC
This commit is contained in:
@@ -387,5 +387,5 @@ END
|
||||
`
|
||||
|
||||
const rotateRootCredentialsSQL = `
|
||||
ALTER LOGIN [%s] WITH PASSWORD = '%s'
|
||||
ALTER LOGIN [{{username}}] WITH PASSWORD = '{{password}}'
|
||||
`
|
||||
|
||||
@@ -95,6 +95,44 @@ func TestMSSQL_CreateUser(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestMSSQL_RotateRootCredentials(t *testing.T) {
|
||||
if os.Getenv("MSSQL_URL") == "" || os.Getenv("VAULT_ACC") != "1" {
|
||||
return
|
||||
}
|
||||
connURL := os.Getenv("MSSQL_URL")
|
||||
connectionDetails := map[string]interface{}{
|
||||
"connection_url": connURL,
|
||||
"username": "sa",
|
||||
"password": "yourStrong(!)Password",
|
||||
}
|
||||
|
||||
db := new()
|
||||
|
||||
connProducer := db.SQLConnectionProducer
|
||||
|
||||
_, err := db.Init(context.Background(), connectionDetails, true)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if !connProducer.Initialized {
|
||||
t.Fatal("Database should be initalized")
|
||||
}
|
||||
|
||||
newConf, err := db.RotateRootCredentials(context.Background(), nil)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
if newConf["password"] == "yourStrong(!)Password" {
|
||||
t.Fatal("password was not updated")
|
||||
}
|
||||
|
||||
err = db.Close()
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMSSQL_RevokeUser(t *testing.T) {
|
||||
if os.Getenv("MSSQL_URL") == "" || os.Getenv("VAULT_ACC") != "1" {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user