Skip to content

Commit

Permalink
Fix plan change func in acceptance tests
Browse files Browse the repository at this point in the history
Also change how SAML settings is deleted. No longer allowed to delete the entire YAML object so now we disable the settings instead.
  • Loading branch information
alexhung committed May 20, 2024
1 parent 7c3f7c2 commit fd66b16
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ func TestAccGeneralSecurity_UpgradeFromSDKv2(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(fqrn, "enable_anonymous_access", "true"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: generalSecurityTemplateFull,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestAccLdapGroupSettingV2_full(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "description_attribute", "description"),
resource.TestCheckResourceAttr(fqrn, "strategy", "STATIC"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
Config: LdapSettingTemplateFullUpdate,
Expand All @@ -85,7 +85,7 @@ func TestAccLdapGroupSettingV2_full(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "description_attribute", "description"),
resource.TestCheckResourceAttr(fqrn, "strategy", "DYNAMIC"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ResourceName: fqrn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestAccLdapSettingV2_full_no_search(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "user_dn_pattern", params["user_dn_pattern"].(string)),
resource.TestCheckResourceAttr(fqrn, "email_attribute", "mail_attr"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ResourceName: fqrn,
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestAccLdapSettingV2_full_with_search(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "search_filter", "(uid={0})"),
resource.TestCheckResourceAttr(fqrn, "search_base", params["search_base"].(string)),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ResourceName: fqrn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ func TestAccPropertySet_UpgradeFromSDKv2(t *testing.T) {
},
Config: config,
Check: resource.ComposeTestCheckFunc(verifyPropertySet(fqrn, testData)),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ func TestAccProxy_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckNoResourceAttr(fqrn, "redirect_to_hosts"),
resource.TestCheckNoResourceAttr(fqrn, "services"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func TestAccRepositoryLayout_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "folder_integration_revision_regexp", "SNAPSHOT"),
resource.TestCheckResourceAttr(fqrn, "file_integration_revision_regexp", "SNAPSHOT|(?:(?:[0-9]{8}.[0-9]{6})-(?:[0-9]+))"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ func resourceSamlSettingsUpdate(ctx context.Context, d *schema.ResourceData, m i
func resourceSamlSettingsDelete(_ context.Context, _ *schema.ResourceData, m interface{}) diag.Diagnostics {
var content = `
security:
samlSettings: ~
samlSettings:
enableIntegration: false
`

err := SendConfigurationPatch([]byte(content), m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,7 @@ func testAccSamlSettingsDestroy(id string) func(*terraform.State) error {
return fmt.Errorf("error: failed to retrieve data from <base_url>/artifactory/api/saml/config during Read")
}

if samlSettings.AllowUserToAccessProfile != false {
return fmt.Errorf("error: SAML SSO setting, allow user to access profile, is still enabled")
}
if samlSettings.SyncGroups != false {
return fmt.Errorf("error: SAML SSO setting, sync groups, is still enabled")
}
if samlSettings.NoAutoUserCreation != false {
return fmt.Errorf("error: SAML SSO setting, no auto user creation, is still enabled")
}
if samlSettings.EnableIntegration != false {
if samlSettings.EnableIntegration {
return fmt.Errorf("error: SAML SSO integration is still enabled")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func TestAccRemoteUpgradeFromVersionWithNoDisableProxyAttr(t *testing.T) {
ProtoV6ProviderFactories: acctest.ProtoV6MuxProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func TestAccCertificate_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "issued_to", "Unknown"),
resource.TestCheckResourceAttr(fqrn, "valid_until", "2029-05-14T10:03:26.000Z"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6MuxProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ func TestAccDistributionPublicKey_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "fingerprint", "10:16:2c:c5:1c:db:d0:59:ad:86:d3:66:dc:d1:d9:02:65:03:a8:25"),
resource.TestCheckResourceAttr(fqrn, "issued_by", "alan <[email protected]>"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: keyBasic,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ func TestAccGroup_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckNoResourceAttr(fqrn, "users_names"),
resource.TestCheckResourceAttr(fqrn, "watch_manager", "false"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ EOF
resource.TestCheckResourceAttr(fqrn, "passphrase", "password"),
resource.TestCheckResourceAttr(fqrn, "unavailable", "false"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6MuxProviderFactories,
Config: keyPairConfig,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ func TestAccPermissionTarget_MigrateFromFrameworkBackToSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "build.#", "1"),
resource.TestCheckResourceAttr(fqrn, "release_bundle.#", "1"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6MuxProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func TestAccScopedToken_UpgradeGH_792(t *testing.T) {
resource.TestCheckResourceAttrSet(fqrn, "issued_at"),
resource.TestCheckResourceAttrSet(fqrn, "issuer"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6MuxProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down Expand Up @@ -136,13 +136,13 @@ func TestAccScopedToken_UpgradeGH_818(t *testing.T) {
resource.TestCheckResourceAttrSet(fqrn, "issued_at"),
resource.TestCheckResourceAttrSet(fqrn, "issuer"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6MuxProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down Expand Up @@ -196,13 +196,13 @@ func scopedTokenUpgradeTestCase(version string, t *testing.T) (*testing.T, resou
resource.TestCheckResourceAttrSet(fqrn, "issued_at"),
resource.TestCheckResourceAttrSet(fqrn, "issuer"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ func TestAccManagedUser_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "internal_password_disabled", "false"),
resource.TestCheckNoResourceAttr(fqrn, "groups"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: userNoGroups,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ func TestAccUnmanagedUser_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "internal_password_disabled", "false"),
resource.TestCheckNoResourceAttr(fqrn, "groups"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: config,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ func TestAccUser_UpgradeFromSDKv2(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "internal_password_disabled", "false"),
resource.TestCheckNoResourceAttr(fqrn, "groups"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: userNoGroups,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down Expand Up @@ -99,13 +99,13 @@ func TestAccUser_UpgradeFrom10_7_0(t *testing.T) {
resource.TestCheckResourceAttr(fqrn, "internal_password_disabled", "false"),
resource.TestCheckNoResourceAttr(fqrn, "groups"),
),
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
{
ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories,
Config: userNoGroups,
PlanOnly: true,
ConfigPlanChecks: testutil.ConfigPlanChecks,
ConfigPlanChecks: testutil.ConfigPlanChecks(""),
},
},
})
Expand Down

0 comments on commit fd66b16

Please sign in to comment.