From 0a1434db48a5a0ce7618f9ec893c775111e306ce Mon Sep 17 00:00:00 2001 From: Victor Moraes Date: Thu, 21 Sep 2023 20:29:16 -0300 Subject: [PATCH] Fix terraform tests that were failing in the E2E tests report (#454) * Fix repository_conf_auth tests * Fix integration_logging tests --- ...resource_cyral_integration_logging_test.go | 2 +- cyral/resource_cyral_repository_conf_auth.go | 19 +++++++++++-------- ...esource_cyral_repository_conf_auth_test.go | 11 +++++------ docs/resources/repository_conf_auth.md | 2 +- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/cyral/resource_cyral_integration_logging_test.go b/cyral/resource_cyral_integration_logging_test.go index 883e39fb..6b566082 100644 --- a/cyral/resource_cyral_integration_logging_test.go +++ b/cyral/resource_cyral_integration_logging_test.go @@ -417,7 +417,7 @@ func setupLogsTest(integrationData LoggingIntegration) (string, resource.TestChe }, ), resource.TestCheckResourceAttr( - integrationELKResourceName, + integrationLogsFullTerraformResourceName, "fluent_bit.0.skip_validate", fmt.Sprint(integrationData.FluentBit.SkipValidate), ), diff --git a/cyral/resource_cyral_repository_conf_auth.go b/cyral/resource_cyral_repository_conf_auth.go index 5e602792..68c68fd5 100644 --- a/cyral/resource_cyral_repository_conf_auth.go +++ b/cyral/resource_cyral_repository_conf_auth.go @@ -19,9 +19,16 @@ const ( defaultClientTLS = "disable" defaultRepoTLS = "disable" - defaultAuthType = "ACCESS_TOKEN" + accessTokenAuthType = "ACCESS_TOKEN" + awsIAMAuthType = "AWS_IAM" + defaultAuthType = accessTokenAuthType ) +var authTypes = []string{ + accessTokenAuthType, + awsIAMAuthType, +} + type RepositoryConfAuthData struct { RepoID *string `json:"-"` AllowNativeAuth bool `json:"allowNativeAuth"` @@ -176,11 +183,6 @@ func DeleteConfAuthConfig() ResourceOperationConfig { } } -var authTypes = []string{ - "ACCESS_TOKEN", - "AWS_IAM", -} - func repositoryConfAuthResourceSchemaV0() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ @@ -217,8 +219,9 @@ func repositoryConfAuthResourceSchemaV0() *schema.Resource { Default: defaultRepoTLS, }, "auth_type": { - Description: "Authentication type for this repository. List of supported types: " + - supportedTypesMarkdown(authTypes), + Description: fmt.Sprintf("Authentication type for this repository. **Note**: `%s` is currently "+ + "only supported by `%s` repo type. List of supported values: %s", + awsIAMAuthType, MongoDB, supportedTypesMarkdown(authTypes)), Type: schema.TypeString, Optional: true, Default: defaultAuthType, diff --git a/cyral/resource_cyral_repository_conf_auth_test.go b/cyral/resource_cyral_repository_conf_auth_test.go index b4a40f15..cd017638 100644 --- a/cyral/resource_cyral_repository_conf_auth_test.go +++ b/cyral/resource_cyral_repository_conf_auth_test.go @@ -17,9 +17,9 @@ func repositoryConfAuthDependencyConfig() string { return formatBasicRepositoryIntoConfig( basicRepositoryResName, accTestName(repositoryConfAuthResourceName, "repository"), - "mysql", - "http://mysql.local/", - 3306, + "mongodb", + "http://mongodb.local/", + 27017, ) } @@ -28,6 +28,7 @@ func initialRepositoryConfAuthConfig() RepositoryConfAuthData { AllowNativeAuth: false, ClientTLS: "disable", RepoTLS: "enable", + AuthType: "ACCESS_TOKEN", } } @@ -67,6 +68,7 @@ func repositoryConfAuthMinimalConfigTest(resName string) resource.TestStep { RepositoryConfAuthData{ ClientTLS: defaultClientTLS, RepoTLS: defaultRepoTLS, + AuthType: defaultAuthType, }, ), } @@ -74,7 +76,6 @@ func repositoryConfAuthMinimalConfigTest(resName string) resource.TestStep { func TestAccRepositoryConfAuthResource(t *testing.T) { testMinimal := repositoryConfAuthMinimalConfigTest("main_test") - mainTest := setupRepositoryConfAuthTest("main_test", initialRepositoryConfAuthConfig()) mainTestUpdate1 := setupRepositoryConfAuthTest("main_test", update1RepositoryConfAuthConfig()) mainTestUpdate2 := setupRepositoryConfAuthTest("main_test", update2RepositoryConfAuthConfig()) @@ -83,11 +84,9 @@ func TestAccRepositoryConfAuthResource(t *testing.T) { ProviderFactories: providerFactories, Steps: []resource.TestStep{ testMinimal, - mainTest, mainTestUpdate1, mainTestUpdate2, - { ImportState: true, ImportStateVerify: true, diff --git a/docs/resources/repository_conf_auth.md b/docs/resources/repository_conf_auth.md index d20d5b68..10b419cd 100644 --- a/docs/resources/repository_conf_auth.md +++ b/docs/resources/repository_conf_auth.md @@ -33,7 +33,7 @@ resource "cyral_repository_conf_auth" "some_resource_name" { ### Optional - `allow_native_auth` (Boolean) Should the communication allow native authentication? -- `auth_type` (String) Authentication type for this repository. List of supported types: +- `auth_type` (String) Authentication type for this repository. **Note**: `AWS_IAM` is currently only supported by `mongodb` repo type. List of supported values: - `ACCESS_TOKEN` - `AWS_IAM` - `client_tls` (String) Is the repo Client using TLS? Default is "disable".