mirror of
https://github.com/minio/minio.git
synced 2025-11-09 13:39:46 -05:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user