diff --git a/databases.go b/databases.go index cd02a38..254395e 100644 --- a/databases.go +++ b/databases.go @@ -62,6 +62,12 @@ const ( SQLModeTraditional = "TRADITIONAL" ) +// SQL Auth constants allow for MySQL-specific user auth plugins +const ( + SQLAuthPluginNative = "mysql_native_password" + SQLAuthPluginCachingSHA2 = "caching_sha2_password" +) + // DatabasesService is an interface for interfacing with the databases endpoints // of the DigitalOcean API. // See: https://developers.digitalocean.com/documentation/v2#databases diff --git a/databases_test.go b/databases_test.go index 6391291..b4e259d 100644 --- a/databases_test.go +++ b/databases_test.go @@ -1306,18 +1306,18 @@ func TestDatabases_CreateDatabaseUserWithMySQLSettings(t *testing.T) { path := fmt.Sprintf("/v2/databases/%s/users", dbID) - responseJSON := []byte(`{ + responseJSON := []byte(fmt.Sprintf(`{ "user": { "name": "foo", "mysql_settings": { - "auth_plugin": "native" + "auth_plugin": "%s" } } - }`) + }`, SQLAuthPluginNative)) expectedUser := &DatabaseUser{ Name: "foo", MySQLSettings: &DatabaseMySQLUserSettings{ - AuthPlugin: "native", + AuthPlugin: SQLAuthPluginNative, }, } @@ -1343,21 +1343,21 @@ func TestDatabases_ListDatabaseUsersWithMySQLSettings(t *testing.T) { path := fmt.Sprintf("/v2/databases/%s/users", dbID) - responseJSON := []byte(`{ + responseJSON := []byte(fmt.Sprintf(`{ "users": [ { "name": "foo", "mysql_settings": { - "auth_plugin": "native" + "auth_plugin": "%s" } } ] - }`) + }`, SQLAuthPluginNative)) expectedUsers := []DatabaseUser{ { Name: "foo", MySQLSettings: &DatabaseMySQLUserSettings{ - AuthPlugin: "native", + AuthPlugin: SQLAuthPluginNative, }, }, } @@ -1382,18 +1382,18 @@ func TestDatabases_GetDatabaseUserWithMySQLSettings(t *testing.T) { path := fmt.Sprintf("/v2/databases/%s/users/%s", dbID, userID) - responseJSON := []byte(`{ + responseJSON := []byte(fmt.Sprintf(`{ "user": { "name": "foo", "mysql_settings": { - "auth_plugin": "native" + "auth_plugin": "%s" } } - }`) + }`, SQLAuthPluginNative)) expectedUser := &DatabaseUser{ Name: "foo", MySQLSettings: &DatabaseMySQLUserSettings{ - AuthPlugin: "native", + AuthPlugin: SQLAuthPluginNative, }, }