mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-03-12 00:41:52 -05:00
Merge pull request #6548 from dragonchaser/issue-3753-issues-with-audit-storage_id_missing
add storage id to audit log for spaces
This commit is contained in:
6
changelog/unreleased/add-storage-id-to-audit-log.md
Normal file
6
changelog/unreleased/add-storage-id-to-audit-log.md
Normal file
@@ -0,0 +1,6 @@
|
||||
Enhancement: We added the storage id to the audit log for spaces
|
||||
|
||||
We added the storage id to the audit log for spaces
|
||||
|
||||
https://github.com/owncloud/ocis/pull/6548
|
||||
https://github.com/owncloud/ocis/issues/3753
|
||||
@@ -462,7 +462,7 @@ var testCases = []struct {
|
||||
SystemEvent: events.Event{
|
||||
Event: events.SpaceCreated{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "space-123"},
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
Owner: userID("uid-123"),
|
||||
Root: resourceID("pro-1", "sto-123", "iid-123"),
|
||||
Name: "test-space",
|
||||
@@ -476,9 +476,9 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "2286-11-20T17:46:40Z", "user 'uid-123' created a space 'space-123' with name 'test-space'", "space_created")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "2286-11-20T17:46:40Z", "user 'uid-123' created a space 'space-123' with name 'test-space' (storage: 'storage-1')", "space_created")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "space-123")
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
// AuditEventFileRestored fields
|
||||
require.Equal(t, "uid-123", ev.Owner)
|
||||
require.Equal(t, "pro-1$sto-123!iid-123", ev.RootItem)
|
||||
@@ -490,7 +490,7 @@ var testCases = []struct {
|
||||
SystemEvent: events.Event{
|
||||
Event: events.SpaceRenamed{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "space-123"},
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
Owner: userID("uid-123"),
|
||||
Name: "new-name",
|
||||
},
|
||||
@@ -500,9 +500,9 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' renamed space 'space-123' to 'new-name'", "space_renamed")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' renamed space 'space-123' to 'new-name' (storage: 'storage-1')", "space_renamed")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "space-123")
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
// AuditEventSpaceRenamed fields
|
||||
require.Equal(t, "new-name", ev.NewName)
|
||||
},
|
||||
@@ -511,7 +511,7 @@ var testCases = []struct {
|
||||
SystemEvent: events.Event{
|
||||
Event: events.SpaceDisabled{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "space-123"},
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -519,16 +519,16 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' disabled the space 'space-123'", "space_disabled")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' disabled the space 'space-123' (storage: 'storage-1')", "space_disabled")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "space-123")
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
},
|
||||
}, {
|
||||
Alias: "Space enabled",
|
||||
SystemEvent: events.Event{
|
||||
Event: events.SpaceEnabled{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "space-123"},
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -536,16 +536,16 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' (re-) enabled the space 'space-123'", "space_enabled")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "", "user 'uid-123' (re-) enabled the space 'space-123' (storage: 'storage-1')", "space_enabled")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "space-123")
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
},
|
||||
}, {
|
||||
Alias: "Space deleted",
|
||||
SystemEvent: events.Event{
|
||||
Event: events.SpaceDeleted{
|
||||
Executant: userID("uid-123"),
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "space-123"},
|
||||
ID: &provider.StorageSpaceId{OpaqueId: "storage-1$space-123"},
|
||||
},
|
||||
},
|
||||
CheckAuditEvent: func(t *testing.T, b []byte) {
|
||||
@@ -553,9 +553,9 @@ var testCases = []struct {
|
||||
require.NoError(t, json.Unmarshal(b, &ev))
|
||||
|
||||
// AuditEvent fields
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' deleted the space 'space-123'", "space_deleted")
|
||||
checkBaseAuditEvent(t, ev.AuditEvent, "", "0001-01-01T00:00:00Z", "user 'uid-123' deleted the space 'space-123' (storage: 'storage-1')", "space_deleted")
|
||||
// AuditEventSpaces fields
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "space-123")
|
||||
checkSpacesAuditEvent(t, ev.AuditEventSpaces, "storage-1$space-123")
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/cs3org/reva/v2/pkg/storagespace"
|
||||
)
|
||||
|
||||
// short identifiers for audit actions
|
||||
@@ -139,43 +140,51 @@ func MessageFileVersionRestored(executant, item, version string) string {
|
||||
|
||||
// MessageSpaceCreated returns the human readable string that describes the action
|
||||
func MessageSpaceCreated(executant, spaceID, name string) string {
|
||||
return fmt.Sprintf("user '%s' created a space '%s' with name '%s'", executant, spaceID, name)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' created a space '%s' with name '%s' (storage: '%s')", executant, spaceID, name, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceRenamed returns the human readable string that describes the action
|
||||
func MessageSpaceRenamed(executant, spaceID, name string) string {
|
||||
return fmt.Sprintf("user '%s' renamed space '%s' to '%s'", executant, spaceID, name)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' renamed space '%s' to '%s' (storage: '%s')", executant, spaceID, name, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceDisabled returns the human readable string that describes the action
|
||||
func MessageSpaceDisabled(executant, spaceID string) string {
|
||||
return fmt.Sprintf("user '%s' disabled the space '%s'", executant, spaceID)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' disabled the space '%s' (storage: '%s')", executant, spaceID, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceEnabled returns the human readable string that describes the action
|
||||
func MessageSpaceEnabled(executant, spaceID string) string {
|
||||
return fmt.Sprintf("user '%s' (re-) enabled the space '%s'", executant, spaceID)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' (re-) enabled the space '%s' (storage: '%s')", executant, spaceID, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceDeleted returns the human readable string that describes the action
|
||||
func MessageSpaceDeleted(executant, spaceID string) string {
|
||||
return fmt.Sprintf("user '%s' deleted the space '%s'", executant, spaceID)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' deleted the space '%s' (storage: '%s')", executant, spaceID, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceShared returns the human readable string that describes the action
|
||||
func MessageSpaceShared(executant, spaceID, grantee string) string {
|
||||
return fmt.Sprintf("user '%s' shared the space '%s' with '%s'", executant, spaceID, grantee)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' shared the space '%s' with '%s' (storage: '%s')", executant, spaceID, grantee, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceUnshared returns the human readable string that describes the action
|
||||
func MessageSpaceUnshared(executant, spaceID, grantee string) string {
|
||||
return fmt.Sprintf("user '%s' unshared the space '%s' with '%s'", executant, spaceID, grantee)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' unshared the space '%s' with '%s' (storage: '%s')", executant, spaceID, grantee, storagID)
|
||||
}
|
||||
|
||||
// MessageSpaceUpdated returns the human readable string that describes the action
|
||||
func MessageSpaceUpdated(executant, spaceID, name string, quota uint64, opaque map[string]string) string {
|
||||
return fmt.Sprintf("user '%s' updated space '%s'. name: '%s', quota: '%d', opaque: '%s'",
|
||||
executant, spaceID, name, quota, opaque)
|
||||
storagID, spaceID := storagespace.SplitStorageID(spaceID)
|
||||
return fmt.Sprintf("user '%s' updated space '%s'. name: '%s', quota: '%d', opaque: '%s' (storage: '%s')",
|
||||
executant, spaceID, name, quota, opaque, storagID)
|
||||
}
|
||||
|
||||
// MessageUserCreated returns the human readable string that describes the action
|
||||
Reference in New Issue
Block a user