Add the policy name to the audit logs tags when doing policy-based API calls. Add retention settings to tags (#20638)

* Add the policy name to the audit log tags when doing policy-based API calls

* Audit log the retention settings requested in the API call

* Audit log of retention on PutObjectRetention API path too
This commit is contained in:
Mark Theunissen
2024-11-26 04:17:12 +11:00
committed by GitHub
parent c07e5b49d4
commit d202fdd022
5 changed files with 112 additions and 1 deletions

View File

@@ -611,3 +611,72 @@ func TestFilterObjectLockMetadata(t *testing.T) {
}
}
}
func TestToString(t *testing.T) {
days := uint64(30)
daysPtr := &days
years := uint64(2)
yearsPtr := &years
tests := []struct {
name string
c Config
want string
}{
{
name: "happy case",
c: Config{
ObjectLockEnabled: "Enabled",
},
want: "Enabled: true",
},
{
name: "with default retention days",
c: Config{
ObjectLockEnabled: "Enabled",
Rule: &struct {
DefaultRetention DefaultRetention `xml:"DefaultRetention"`
}{
DefaultRetention: DefaultRetention{
Mode: RetGovernance,
Days: daysPtr,
},
},
},
want: "Enabled: true, Mode: GOVERNANCE, Days: 30",
},
{
name: "with default retention years",
c: Config{
ObjectLockEnabled: "Enabled",
Rule: &struct {
DefaultRetention DefaultRetention `xml:"DefaultRetention"`
}{
DefaultRetention: DefaultRetention{
Mode: RetCompliance,
Years: yearsPtr,
},
},
},
want: "Enabled: true, Mode: COMPLIANCE, Years: 2",
},
{
name: "disabled case",
c: Config{
ObjectLockEnabled: "Disabled",
},
want: "Enabled: false",
},
{
name: "empty case",
c: Config{},
want: "Enabled: false",
},
}
for _, tt := range tests {
got := tt.c.String()
if got != tt.want {
t.Errorf("test: %s, got: '%v', want: '%v'", tt.name, got, tt.want)
}
}
}