@@ -11,6 +11,7 @@ import (
11
11
stdmysql "github.com/go-sql-driver/mysql"
12
12
mysqlhelper "github.com/hashicorp/vault/helper/testhelpers/mysql"
13
13
dbplugin "github.com/hashicorp/vault/sdk/database/dbplugin/v5"
14
+ dbtesting "github.com/hashicorp/vault/sdk/database/dbplugin/v5/testing"
14
15
"github.com/hashicorp/vault/sdk/database/helper/credsutil"
15
16
"github.com/hashicorp/vault/sdk/database/helper/dbutil"
16
17
"github.com/hashicorp/vault/sdk/helper/strutil"
@@ -20,7 +21,27 @@ import (
20
21
var _ dbplugin.Database = (* MySQL )(nil )
21
22
22
23
func TestMySQL_Initialize (t * testing.T ) {
23
- rootPassword := "#secret!%25#{@}"
24
+ type testCase struct {
25
+ rootPassword string
26
+ }
27
+
28
+ tests := map [string ]testCase {
29
+ "non-special characters in root password" : {
30
+ rootPassword : "B44a30c4C04D0aAaE140" ,
31
+ },
32
+ "special characters in root password" : {
33
+ rootPassword : "#secret!%25#{@}" ,
34
+ },
35
+ }
36
+
37
+ for name , test := range tests {
38
+ t .Run (name , func (t * testing.T ) {
39
+ testInitialize (t , test .rootPassword )
40
+ })
41
+ }
42
+ }
43
+
44
+ func testInitialize (t * testing.T , rootPassword string ) {
24
45
cleanup , connURL := mysqlhelper .PrepareTestContainer (t , false , rootPassword )
25
46
defer cleanup ()
26
47
@@ -131,7 +152,7 @@ func TestMySQL_Initialize(t *testing.T) {
131
152
for name , test := range tests {
132
153
t .Run (name , func (t * testing.T ) {
133
154
db := newMySQL (DefaultUserNameTemplate )
134
- defer db . Close ( )
155
+ defer dbtesting . AssertClose ( t , db )
135
156
initResp , err := db .Initialize (context .Background (), test .initRequest )
136
157
if test .expectErr && err == nil {
137
158
t .Fatalf ("err expected, got nil" )
0 commit comments