Skip to content

Commit

Permalink
Add minimum_retention_months to config endpoint (#20150)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalmi authored Apr 13, 2023
1 parent fc21d35 commit 002a59a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
4 changes: 4 additions & 0 deletions changelog/20150.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```release-note:improvement
api: `/sys/internal/counters/config` endpoint now contains read-only
`minimum_retention_months`.
```
39 changes: 21 additions & 18 deletions vault/activity_log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -834,12 +834,13 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) {
t.Fatalf("err: %v", err)
}
defaults := map[string]interface{}{
"default_report_months": 12,
"retention_months": 24,
"enabled": activityLogEnabledDefaultValue,
"queries_available": false,
"reporting_enabled": core.censusLicensingEnabled,
"billing_start_timestamp": core.GetBillingStart(),
"default_report_months": 12,
"retention_months": 24,
"enabled": activityLogEnabledDefaultValue,
"queries_available": false,
"reporting_enabled": core.censusLicensingEnabled,
"billing_start_timestamp": core.GetBillingStart(),
"minimum_retention_months": core.activityLog.configOverrides.MinimumRetentionMonths,
}

if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 {
Expand Down Expand Up @@ -917,12 +918,13 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) {
t.Fatalf("err: %v", err)
}
expected := map[string]interface{}{
"default_report_months": 1,
"retention_months": 2,
"enabled": "enable",
"queries_available": false,
"reporting_enabled": false,
"billing_start_timestamp": core.GetBillingStart(),
"default_report_months": 1,
"retention_months": 2,
"enabled": "enable",
"queries_available": false,
"reporting_enabled": core.censusLicensingEnabled,
"billing_start_timestamp": core.GetBillingStart(),
"minimum_retention_months": core.activityLog.configOverrides.MinimumRetentionMonths,
}

if diff := deep.Equal(resp.Data, expected); len(diff) > 0 {
Expand Down Expand Up @@ -955,12 +957,13 @@ func TestActivityLog_API_ConfigCRUD(t *testing.T) {
}

defaults := map[string]interface{}{
"default_report_months": 12,
"retention_months": 24,
"enabled": activityLogEnabledDefaultValue,
"queries_available": false,
"reporting_enabled": false,
"billing_start_timestamp": core.GetBillingStart(),
"default_report_months": 12,
"retention_months": 24,
"enabled": activityLogEnabledDefaultValue,
"queries_available": false,
"reporting_enabled": core.censusLicensingEnabled,
"billing_start_timestamp": core.GetBillingStart(),
"minimum_retention_months": core.activityLog.configOverrides.MinimumRetentionMonths,
}

if diff := deep.Equal(resp.Data, defaults); len(diff) > 0 {
Expand Down
13 changes: 7 additions & 6 deletions vault/logical_system_activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,13 @@ func (b *SystemBackend) handleActivityConfigRead(ctx context.Context, req *logic

return &logical.Response{
Data: map[string]interface{}{
"default_report_months": config.DefaultReportMonths,
"retention_months": config.RetentionMonths,
"enabled": config.Enabled,
"queries_available": qa,
"reporting_enabled": b.Core.censusLicensingEnabled,
"billing_start_timestamp": b.Core.GetBillingStart(),
"default_report_months": config.DefaultReportMonths,
"retention_months": config.RetentionMonths,
"enabled": config.Enabled,
"queries_available": qa,
"reporting_enabled": b.Core.censusLicensingEnabled,
"billing_start_timestamp": b.Core.GetBillingStart(),
"minimum_retention_months": a.configOverrides.MinimumRetentionMonths,
},
}, nil
}
Expand Down

0 comments on commit 002a59a

Please sign in to comment.