Skip to content

Commit bddf4a1

Browse files
authored
feat(events): send user and token name as actorName (#2324)
Signed-off-by: Miguel Martinez <[email protected]>
1 parent 0f0cd5c commit bddf4a1

File tree

48 files changed

+72
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+72
-19
lines changed

app/controlplane/pkg/auditor/events/apitoken_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ func TestAPITokenEvents(t *testing.T) {
108108
auditor.WithOrgID(orgUUID),
109109
}
110110
if tt.actor == auditor.ActorTypeAPIToken {
111-
opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, ""))
111+
opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, "", testAPITokenName))
112112
} else {
113-
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
113+
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
114114
}
115115

116116
eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)

app/controlplane/pkg/auditor/events/events_test.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright 2024 The Chainloop Authors.
2+
// Copyright 2024-2025 The Chainloop Authors.
33
//
44
// Licensed under the Apache License, Version 2.0 (the "License");
55
// you may not use this file except in compliance with the License.
@@ -23,7 +23,11 @@ import (
2323

2424
var updateGolden bool
2525

26-
const testEmail = "[email protected]"
26+
const (
27+
testEmail = "[email protected]"
28+
testName = "John Doe"
29+
testAPITokenName = "test-token"
30+
)
2731

2832
func TestMain(m *testing.M) {
2933
flag.BoolVar(&updateGolden, "update-golden", false, "update the expected golden files")

app/controlplane/pkg/auditor/events/group_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ func TestGroupEvents(t *testing.T) {
153153
}
154154

155155
if tt.actor == auditor.ActorTypeUser {
156-
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
156+
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
157157
} else {
158-
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, ""))
158+
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, "", testAPITokenName))
159159
}
160160

161161
eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)

app/controlplane/pkg/auditor/events/project_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ func TestProjectEvents(t *testing.T) {
162162
auditor.WithOrgID(orgUUID),
163163
}
164164
if tt.actor == auditor.ActorTypeUser {
165-
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
165+
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
166166
} else {
167-
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, ""))
167+
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, "", testAPITokenName))
168168
}
169169

170170
eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_created.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8+
"ActorName": "John Doe",
89
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
910
"Description": "[email protected] has created the API token test-token",
1011
"Info": {

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_created_with_description.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8+
"ActorName": "John Doe",
89
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
910
"Description": "[email protected] has created the API token test-token",
1011
"Info": {

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_created_with_expiration_date.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8+
"ActorName": "John Doe",
89
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
910
"Description": "[email protected] has created the API token test-token expiring at 2025-01-01T00:00:00Z",
1011
"Info": {

app/controlplane/pkg/auditor/events/testdata/apitokens/api_token_revoked.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ActorType": "API_TOKEN",
66
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
77
"ActorEmail": "",
8+
"ActorName": "test-token",
89
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
910
"Description": " has revoked the API token test-token",
1011
"Info": {

app/controlplane/pkg/auditor/events/testdata/groups/group_created.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8+
"ActorName": "John Doe",
89
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
910
"Description": "[email protected] has created the group test-group",
1011
"Info": {

app/controlplane/pkg/auditor/events/testdata/groups/group_deleted.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"ActorType": "USER",
66
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
77
"ActorEmail": "[email protected]",
8+
"ActorName": "John Doe",
89
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
910
"Description": "[email protected] has deleted the group test-group",
1011
"Info": {

0 commit comments

Comments
 (0)