add mysql auth plugin consts

also use them in the tests
This commit is contained in:
Greg Mankes 2019-11-18 12:27:37 -05:00
parent 1b8be0b83d
commit 59175fb1ae
2 changed files with 18 additions and 12 deletions

View File

@ -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

View File

@ -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,
},
}