diff --git a/internal/sdkprovider/service/opensearch/opensearch_security_plugin_config_test.go b/internal/sdkprovider/service/opensearch/opensearch_security_plugin_config_test.go index 2c3b58d95..8600d661b 100644 --- a/internal/sdkprovider/service/opensearch/opensearch_security_plugin_config_test.go +++ b/internal/sdkprovider/service/opensearch/opensearch_security_plugin_config_test.go @@ -13,9 +13,6 @@ import ( acc "github.com/aiven/terraform-provider-aiven/internal/acctest" ) -// openSearchSecurityPluginTestPassword is the password used for the OpenSearch Security Plugin Config tests. -const openSearchSecurityPluginTestPassword = "ThisIsATest123^=^" - // TestAccAivenOpenSearchSecurityPluginConfig_basic tests the basic functionality of the OpenSearch Security Plugin // Config resource. func TestAccAivenOpenSearchSecurityPluginConfig_basic(t *testing.T) { @@ -53,14 +50,14 @@ resource "aiven_opensearch_security_plugin_config" "foo" { admin_password = "%s" depends_on = [aiven_opensearch.bar, aiven_opensearch_user.foo] -}`, os.Getenv("AIVEN_PROJECT_NAME"), rName, openSearchSecurityPluginTestPassword), +}`, os.Getenv("AIVEN_PROJECT_NAME"), rName, openSearchTestPassword), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "project", os.Getenv("AIVEN_PROJECT_NAME")), resource.TestCheckResourceAttr( resourceName, "service_name", fmt.Sprintf("test-acc-sr-os-sec-plugin-%s", rName), ), resource.TestCheckResourceAttr( - resourceName, "admin_password", openSearchSecurityPluginTestPassword, + resourceName, "admin_password", openSearchTestPassword, ), resource.TestCheckResourceAttr(resourceName, "available", "true"), resource.TestCheckResourceAttr(resourceName, "enabled", "true"), @@ -88,14 +85,14 @@ resource "aiven_opensearch_security_plugin_config" "foo" { admin_password = "%s" depends_on = [aiven_opensearch.bar] -}`, os.Getenv("AIVEN_PROJECT_NAME"), rName, openSearchSecurityPluginTestPassword), +}`, os.Getenv("AIVEN_PROJECT_NAME"), rName, openSearchTestPassword), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "project", os.Getenv("AIVEN_PROJECT_NAME")), resource.TestCheckResourceAttr( resourceName, "service_name", fmt.Sprintf("test-acc-sr-os-sec-plugin-%s", rName), ), resource.TestCheckResourceAttr( - resourceName, "admin_password", openSearchSecurityPluginTestPassword, + resourceName, "admin_password", openSearchTestPassword, ), resource.TestCheckResourceAttr(resourceName, "available", "true"), resource.TestCheckResourceAttr(resourceName, "enabled", "true"), @@ -129,7 +126,7 @@ resource "aiven_opensearch_security_plugin_config" "foo" { admin_password = "%s" depends_on = [aiven_opensearch.bar, aiven_opensearch_user.foo] -}`, os.Getenv("AIVEN_PROJECT_NAME"), rName, openSearchSecurityPluginTestPassword), +}`, os.Getenv("AIVEN_PROJECT_NAME"), rName, openSearchTestPassword), ExpectError: regexp.MustCompile("when the OpenSearch Security Plugin is enabled"), }, }, diff --git a/internal/sdkprovider/service/opensearch/opensearch_user_test.go b/internal/sdkprovider/service/opensearch/opensearch_user_test.go index 87da3b0c4..bcad62731 100644 --- a/internal/sdkprovider/service/opensearch/opensearch_user_test.go +++ b/internal/sdkprovider/service/opensearch/opensearch_user_test.go @@ -15,6 +15,9 @@ import ( "github.com/aiven/terraform-provider-aiven/internal/schemautil" ) +// openSearchTestPassword is the password used for the OpenSearch tests. +const openSearchTestPassword = "ThisIsATest123^=^" + func TestAccAivenOpenSearchUser_basic(t *testing.T) { resourceName := "aiven_opensearch_user.foo" rName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum) @@ -31,7 +34,7 @@ func TestAccAivenOpenSearchUser_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "service_name", fmt.Sprintf("test-acc-sr-%s", rName)), resource.TestCheckResourceAttr(resourceName, "project", os.Getenv("AIVEN_PROJECT_NAME")), resource.TestCheckResourceAttr(resourceName, "username", fmt.Sprintf("user-%s", rName)), - resource.TestCheckResourceAttr(resourceName, "password", "Test$1234"), + resource.TestCheckResourceAttr(resourceName, "password", openSearchTestPassword), ), }, }, @@ -72,14 +75,14 @@ func testAccCheckAivenOpenSearchUserResourceDestroy(s *terraform.State) error { func testAccOpenSearchUserResource(name string) string { return fmt.Sprintf(` data "aiven_project" "foo" { - project = "%s" + project = "%[1]s" } resource "aiven_opensearch" "bar" { project = data.aiven_project.foo.project cloud_name = "google-europe-west1" plan = "startup-4" - service_name = "test-acc-sr-%s" + service_name = "test-acc-sr-%[2]s" maintenance_window_dow = "monday" maintenance_window_time = "10:00:00" } @@ -87,13 +90,13 @@ resource "aiven_opensearch" "bar" { resource "aiven_opensearch_user" "foo" { service_name = aiven_opensearch.bar.service_name project = data.aiven_project.foo.project - username = "user-%s" - password = "Test$1234" + username = "user-%[2]s" + password = "%[3]s" } data "aiven_opensearch_user" "user" { service_name = aiven_opensearch_user.foo.service_name project = aiven_opensearch_user.foo.project username = aiven_opensearch_user.foo.username -}`, os.Getenv("AIVEN_PROJECT_NAME"), name, name) +}`, os.Getenv("AIVEN_PROJECT_NAME"), name, openSearchTestPassword) }