From c0b8a9eddbeedfec9f44959943b6027e66b19669 Mon Sep 17 00:00:00 2001 From: Mike Palmiotto Date: Thu, 13 Apr 2023 14:33:23 -0400 Subject: [PATCH] Add minimum_retention_months to config endpoint (#20150) --- changelog/20150.txt | 4 ++++ vault/activity_log_test.go | 39 +++++++++++++++++--------------- vault/logical_system_activity.go | 13 ++++++----- 3 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 changelog/20150.txt diff --git a/changelog/20150.txt b/changelog/20150.txt new file mode 100644 index 000000000..0ea8259f9 --- /dev/null +++ b/changelog/20150.txt @@ -0,0 +1,4 @@ +```release-note:improvement +api: `/sys/internal/counters/config` endpoint now contains read-only +`minimum_retention_months`. +``` diff --git a/vault/activity_log_test.go b/vault/activity_log_test.go index 5ffbbb18b..02d11e368 100644 --- a/vault/activity_log_test.go +++ b/vault/activity_log_test.go @@ -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 { @@ -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 { @@ -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 { diff --git a/vault/logical_system_activity.go b/vault/logical_system_activity.go index 5b97ceece..64f3cb693 100644 --- a/vault/logical_system_activity.go +++ b/vault/logical_system_activity.go @@ -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 }