Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ FEATURES:

BUGS:

* Fix pki crl config resource ignoring updates of fields to their default values ([#2607](https://github.com/hashicorp/terraform-provider-vault/pull/2607))
* Fix pki config resources to allow unsetting of fields (to empty fields) ([#2558](https://github.com/hashicorp/terraform-provider-vault/pull/2558))
* Fix tune auth mounts to allow unsetting of fields (setting fields to empty values) ([#2605](https://github.com/hashicorp/terraform-provider-vault/pull/2605))

Expand Down
2 changes: 1 addition & 1 deletion vault/resource_pki_secret_backend_crl_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func pkiSecretBackendCrlConfigUpdate(ctx context.Context, d *schema.ResourceData
path := d.Id()
fields := buildConfigCRLFields(meta)

data := util.GetAPIRequestDataWithSliceOk(d, fields)
data := util.GetAPIRequestDataWithSliceOkExists(d, fields)
log.Printf("[DEBUG] Updating CRL config on PKI secret path %q", path)
_, err := client.Logical().Write(path, data)
if err != nil {
Expand Down
32 changes: 31 additions & 1 deletion vault/resource_pki_secret_backend_crl_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func setupCRLConfigTest(t *testing.T, preCheck func(), ignoreImportFields ...str
if os.Getenv(testutil.EnvVarTfAccEnt) != "" {
unifiedCrl = true
}
meta := testProvider.Meta().(*provider.ProviderMeta)
steps := []resource.TestStep{
{
Config: testPkiSecretBackendCrlConfigConfig_defaults(rootPath),
Expand All @@ -160,8 +161,16 @@ func setupCRLConfigTest(t *testing.T, preCheck func(), ignoreImportFields ...str
Config: testPkiSecretBackendCrlConfigConfig_explicit(rootPath, unifiedCrl, 100),
Check: getCRLConfigChecks(resourceName, true, unifiedCrl, 100),
},
testutil.GetImportTestStep(resourceName, false, nil, ignoreImportFields...),
}
if meta.IsAPISupported(provider.VaultVersion112) {
steps = append(steps, resource.TestStep{
Config: testPkiSecretBackendCrlConfigConfig_autoRebuildDisabled(rootPath, unifiedCrl, 50),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "auto_rebuild", "false"),
),
})
}
steps = append(steps, testutil.GetImportTestStep(resourceName, false, nil, ignoreImportFields...))
resource.Test(t, resource.TestCase{
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(context.Background(), t),
PreCheck: preCheck,
Expand Down Expand Up @@ -232,3 +241,24 @@ resource "vault_pki_secret_backend_crl_config" "test" {
}
`, testPkiSecretBackendCrlConfigConfig_base(rootPath), strconv.FormatBool(unifiedCrl), maxCrlEntries)
}

func testPkiSecretBackendCrlConfigConfig_autoRebuildDisabled(rootPath string, unifiedCrl bool, maxCrlEntries int) string {
return fmt.Sprintf(`
%[1]s

resource "vault_pki_secret_backend_crl_config" "test" {
backend = vault_pki_secret_backend_root_cert.test-ca.backend
expiry = "72h"
disable = true
ocsp_disable = false
ocsp_expiry = "23h"
auto_rebuild = false
enable_delta = true
delta_rebuild_interval = "18m"
cross_cluster_revocation = %[2]s
unified_crl = %[2]s
unified_crl_on_existing_paths = %[2]s
max_crl_entries = %[3]d
}
`, testPkiSecretBackendCrlConfigConfig_base(rootPath), strconv.FormatBool(unifiedCrl), maxCrlEntries)
}