From b4964e64fcf3b7e5694bb425719387c29179e7b4 Mon Sep 17 00:00:00 2001 From: EspenAlbert Date: Fri, 24 May 2024 15:43:09 +0100 Subject: [PATCH] add PR comments/suggestions --- ...ce_federated_settings_identity_provider.go | 4 ++-- ...source_federated_settings_connected_org.go | 4 ++-- ...e_federated_settings_connected_org_test.go | 19 ++++++++++--------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go b/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go index c03538ef36..6eebc7130f 100644 --- a/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go +++ b/internal/service/federatedsettingsidentityprovider/resource_federated_settings_identity_provider.go @@ -22,7 +22,7 @@ const OIDC = "OIDC" func Resource() *schema.Resource { return &schema.Resource{ - CreateContext: noOpCreate, + CreateContext: resourceCreateNotAllowed, ReadContext: resourceMongoDBAtlasFederatedSettingsIdentityProviderRead, UpdateContext: resourceMongoDBAtlasFederatedSettingsIdentityProviderUpdate, DeleteContext: resourceMongoDBAtlasFederatedSettingsIdentityProviderDelete, @@ -112,7 +112,7 @@ func Resource() *schema.Resource { } } -func noOpCreate(_ context.Context, _ *schema.ResourceData, _ any) diag.Diagnostics { +func resourceCreateNotAllowed(_ context.Context, _ *schema.ResourceData, _ any) diag.Diagnostics { return diag.FromErr(errors.New("this resource must be imported")) } diff --git a/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org.go b/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org.go index 5f0d6f5525..1a73aa1a5e 100644 --- a/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org.go +++ b/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org.go @@ -16,7 +16,7 @@ import ( func Resource() *schema.Resource { return &schema.Resource{ - CreateContext: noOpCreate, + CreateContext: resourceCreateNotAllowed, ReadContext: resourceMongoDBAtlasFederatedSettingsOrganizationConfigRead, UpdateContext: resourceMongoDBAtlasFederatedSettingsOrganizationConfigUpdate, DeleteContext: resourceMongoDBAtlasFederatedSettingsOrganizationConfigDelete, @@ -58,7 +58,7 @@ func Resource() *schema.Resource { } } -func noOpCreate(_ context.Context, _ *schema.ResourceData, _ any) diag.Diagnostics { +func resourceCreateNotAllowed(_ context.Context, _ *schema.ResourceData, _ any) diag.Diagnostics { return diag.FromErr(errors.New("this resource must be imported")) } diff --git a/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org_test.go b/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org_test.go index d7b57fcd84..c55f38c5a9 100644 --- a/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org_test.go +++ b/internal/service/federatedsettingsorgconfig/resource_federated_settings_connected_org_test.go @@ -13,12 +13,12 @@ import ( "github.com/mongodb/terraform-provider-mongodbatlas/internal/testutil/acc" ) -func TestAccFederatedSettingsOrgCreate_createError(t *testing.T) { +func TestAccFederatedSettingsOrg_createError(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, Steps: []resource.TestStep{ { - Config: configBasic("not-used", "not-used", "not-used"), + Config: configBasic("not-used", "not-used", "not-used", "not-used"), ExpectError: regexp.MustCompile("this resource must be imported"), }, }, @@ -38,14 +38,15 @@ func basicTestCase(tb testing.TB) *resource.TestCase { federationSettingsID = os.Getenv("MONGODB_ATLAS_FEDERATION_SETTINGS_ID") orgID = os.Getenv("MONGODB_ATLAS_FEDERATED_ORG_ID") idpID = os.Getenv("MONGODB_ATLAS_FEDERATED_IDP_ID") + associatedDomain = os.Getenv("MONGODB_ATLAS_FEDERATED_SETTINGS_ASSOCIATED_DOMAIN") ) return &resource.TestCase{ - PreCheck: func() { acc.PreCheckFederatedSettings(tb) }, + PreCheck: func() { acc.PreCheckFederatedSettingsIdentityProvider(tb) }, ProtoV6ProviderFactories: acc.TestAccProviderV6Factories, Steps: []resource.TestStep{ { - Config: configBasic(federationSettingsID, orgID, idpID), + Config: configBasic(federationSettingsID, orgID, idpID, associatedDomain), ResourceName: resourceName, ImportStateIdFunc: importStateIDFunc(federationSettingsID, orgID), ImportState: true, @@ -53,7 +54,7 @@ func basicTestCase(tb testing.TB) *resource.TestCase { ImportStatePersist: true, // ensure update will be tested in the next step }, { - Config: configBasic(federationSettingsID, orgID, idpID), + Config: configBasic(federationSettingsID, orgID, idpID, associatedDomain), Check: resource.ComposeTestCheckFunc( checkExists(resourceName), resource.TestCheckResourceAttr(resourceName, "federation_settings_id", federationSettingsID), @@ -63,7 +64,7 @@ func basicTestCase(tb testing.TB) *resource.TestCase { ), }, { - Config: configBasic(federationSettingsID, orgID, idpID), + Config: configBasic(federationSettingsID, orgID, idpID, associatedDomain), ResourceName: resourceName, ImportStateIdFunc: importStateIDFunc(federationSettingsID, orgID), ImportState: true, @@ -104,13 +105,13 @@ func importStateIDFunc(federationSettingsID, orgID string) resource.ImportStateI } } -func configBasic(federationSettingsID, orgID, identityProviderID string) string { +func configBasic(federationSettingsID, orgID, identityProviderID, associatedDomain string) string { return fmt.Sprintf(` resource "mongodbatlas_federated_settings_org_config" "test" { federation_settings_id = "%[1]s" org_id = "%[2]s" domain_restriction_enabled = false - domain_allow_list = ["reorganizeyourworld.com", "cfn-test-domain.com"] + domain_allow_list = [%[4]q] identity_provider_id = "%[3]s" - }`, federationSettingsID, orgID, identityProviderID) + }`, federationSettingsID, orgID, identityProviderID, associatedDomain) }