diff --git a/internal/services/redis/redis_cache_resource.go b/internal/services/redis/redis_cache_resource.go index ca6538e790eb..0dffb2b669d2 100644 --- a/internal/services/redis/redis_cache_resource.go +++ b/internal/services/redis/redis_cache_resource.go @@ -720,9 +720,8 @@ func resourceRedisCacheRead(d *pluginsdk.ResourceData, meta interface{}) error { return fmt.Errorf("setting `redis_configuration`: %+v", err) } - enableSslPort := !*props.EnableNonSslPort - d.Set("primary_connection_string", getRedisConnectionString(*props.HostName, *props.SslPort, *keysResp.Model.PrimaryKey, enableSslPort)) - d.Set("secondary_connection_string", getRedisConnectionString(*props.HostName, *props.SslPort, *keysResp.Model.SecondaryKey, enableSslPort)) + d.Set("primary_connection_string", getRedisConnectionString(*props.HostName, *props.SslPort, *keysResp.Model.PrimaryKey, true)) + d.Set("secondary_connection_string", getRedisConnectionString(*props.HostName, *props.SslPort, *keysResp.Model.SecondaryKey, true)) d.Set("primary_access_key", keysResp.Model.PrimaryKey) d.Set("secondary_access_key", keysResp.Model.SecondaryKey) diff --git a/internal/services/redis/redis_cache_resource_test.go b/internal/services/redis/redis_cache_resource_test.go index fc3ca9daa6d3..d5bd281fd20d 100644 --- a/internal/services/redis/redis_cache_resource_test.go +++ b/internal/services/redis/redis_cache_resource_test.go @@ -6,7 +6,6 @@ package redis_test import ( "context" "fmt" - "strings" "testing" "github.com/hashicorp/go-azure-sdk/resource-manager/redis/2023-04-01/redis" @@ -31,8 +30,6 @@ func TestAccRedisCache_basic(t *testing.T) { check.That(data.ResourceName).Key("minimum_tls_version").Exists(), check.That(data.ResourceName).Key("primary_connection_string").Exists(), check.That(data.ResourceName).Key("secondary_connection_string").Exists(), - testCheckSSLInConnectionString(data.ResourceName, "primary_connection_string", true), - testCheckSSLInConnectionString(data.ResourceName, "secondary_connection_string", true), ), }, data.ImportStep(), @@ -48,8 +45,6 @@ func TestAccRedisCache_withoutSSL(t *testing.T) { Config: r.basic(data, false), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - testCheckSSLInConnectionString(data.ResourceName, "primary_connection_string", false), - testCheckSSLInConnectionString(data.ResourceName, "secondary_connection_string", false), ), }, data.ImportStep(), @@ -1491,23 +1486,3 @@ resource "azurerm_redis_cache" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) } - -func testCheckSSLInConnectionString(resourceName string, propertyName string, requireSSL bool) acceptance.TestCheckFunc { - return func(s *acceptance.State) error { - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("Not found: %s", resourceName) - } - - connectionString := rs.Primary.Attributes[propertyName] - if strings.Contains(connectionString, fmt.Sprintf("ssl=%t", requireSSL)) { - return nil - } - if strings.Contains(connectionString, fmt.Sprintf("ssl=%t", !requireSSL)) { - return fmt.Errorf("Bad: wrong SSL setting in connection string: %s", propertyName) - } - - return fmt.Errorf("Bad: missing SSL setting in connection string: %s", propertyName) - } -}