Skip to content

Commit

Permalink
Add misssing last_updated attribute field
Browse files Browse the repository at this point in the history
  • Loading branch information
stevendpclark committed May 27, 2024
1 parent 8c32ffe commit d7c9885
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ const (
FieldAuthenticators = "authenticators"
FieldEnableSentinelParsing = "enable_sentinel_parsing"
FieldAuditFields = "audit_fields"
FieldLastUpdated = "last_updated"

/*
common environment variables
Expand Down
6 changes: 6 additions & 0 deletions vault/data_source_pki_secret_backend_config_est.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ func pkiSecretBackendConfigEstDataSource() *schema.Resource {
Type: schema.TypeString,
},
},
consts.FieldLastUpdated: {
Type: schema.TypeString,
Computed: true,
Description: "A read-only timestamp representing the last time the configuration was updated",
},
},
}
}
Expand Down Expand Up @@ -118,6 +123,7 @@ func readEstConfig(ctx context.Context, d *schema.ResourceData, client *api.Clie
consts.FieldLabelToPathPolicy,
consts.FieldEnableSentinelParsing,
consts.FieldAuditFields,
consts.FieldLastUpdated,
}

for _, k := range keyComputedFields {
Expand Down
1 change: 1 addition & 0 deletions vault/data_source_pki_secret_backend_config_est_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func TestAccDataSourcePKISecretConfigEst(t *testing.T) {
resource.TestCheckResourceAttrSet(dataName, consts.FieldEnabled),
resource.TestCheckResourceAttrSet(dataName, consts.FieldDefaultMount),
resource.TestCheckResourceAttrSet(dataName, consts.FieldEnableSentinelParsing),
resource.TestCheckResourceAttrSet(dataName, consts.FieldLastUpdated),
),
},
},
Expand Down
5 changes: 5 additions & 0 deletions vault/resource_pki_secret_backend_config_est.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ func pkiSecretBackendConfigEstResource() *schema.Resource {
Type: schema.TypeString,
},
},
consts.FieldLastUpdated: {
Type: schema.TypeString,
Computed: true, // read-only property
Description: "A read-only timestamp representing the last time the configuration was updated",
},
},
}
}
Expand Down
4 changes: 4 additions & 0 deletions vault/resource_pki_secret_backend_config_est_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestAccPKISecretBackendConfigEst_Empty(t *testing.T) {
resource.TestCheckResourceAttr(resourceBackend, consts.FieldAuthenticators+".0.%", "2"),
resource.TestCheckNoResourceAttr(resourceBackend, consts.FieldAuthenticators+".0.cert"),
resource.TestCheckNoResourceAttr(resourceBackend, consts.FieldAuthenticators+".0.userpass"),
resource.TestCheckResourceAttrSet(dataName, consts.FieldLastUpdated),

// Validate we read back the data back as we did upon creation
resource.TestCheckResourceAttr(dataName, consts.FieldBackend, backend),
Expand All @@ -55,6 +56,7 @@ func TestAccPKISecretBackendConfigEst_Empty(t *testing.T) {
resource.TestCheckResourceAttr(dataName, consts.FieldAuthenticators+".0.%", "2"),
resource.TestCheckNoResourceAttr(dataName, consts.FieldAuthenticators+".0.cert"),
resource.TestCheckNoResourceAttr(dataName, consts.FieldAuthenticators+".0.userpass"),
resource.TestCheckResourceAttrSet(dataName, consts.FieldLastUpdated),
),
},
testutil.GetImportTestStep(resourceBackend, false, nil),
Expand Down Expand Up @@ -99,6 +101,7 @@ func TestAccPKISecretBackendConfigEst_AllFields(t *testing.T) {
resource.TestCheckResourceAttr(resourceBackend, consts.FieldAuthenticators+".0.userpass.accessor", "test2"),
resource.TestCheckResourceAttr(resourceBackend, consts.FieldEnableSentinelParsing, "true"),
resource.TestCheckResourceAttr(resourceBackend, consts.FieldAuditFields+".#", "20"),
resource.TestCheckResourceAttrSet(dataName, consts.FieldLastUpdated),

// Validate that the data property can read back everything filled in
resource.TestCheckResourceAttr(dataName, consts.FieldBackend, backend),
Expand All @@ -117,6 +120,7 @@ func TestAccPKISecretBackendConfigEst_AllFields(t *testing.T) {
resource.TestCheckResourceAttr(dataName, consts.FieldAuthenticators+".0.userpass.accessor", "test2"),
resource.TestCheckResourceAttr(dataName, consts.FieldEnableSentinelParsing, "true"),
resource.TestCheckResourceAttr(dataName, consts.FieldAuditFields+".#", "20"),
resource.TestCheckResourceAttrSet(dataName, consts.FieldLastUpdated),
),
},
testutil.GetImportTestStep(resourceBackend, false, nil),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/pki_secret_backend_config_est.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ The following arguments are supported:
* `label_to_path_policy` - A pairing of EST label to the configured EST behavior for it

* `audit_fields` - Fields parsed from the CSR that appear in the audit and can be used by sentinel policies

* `last_updated` - A read-only timestamp representing the last time the configuration was updated

<a id="nestedatt--authenticators"></a>
### Nested Schema for `authenticators`
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/pki_secret_backend_config_est.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ The following arguments are supported:

## Attributes Reference

No additional attributes are exported by this resource.
* `last_updated` - A read-only timestamp representing the last time the configuration was updated

## Import

Expand Down

0 comments on commit d7c9885

Please sign in to comment.