Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/controlplane/pkg/auditor/events/apitoken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func TestAPITokenEvents(t *testing.T) {
auditor.WithOrgID(orgUUID),
}
if tt.actor == auditor.ActorTypeAPIToken {
opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, ""))
opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, "", testAPITokenName))
} else {
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
}

eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)
Expand Down
8 changes: 6 additions & 2 deletions app/controlplane/pkg/auditor/events/events_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 The Chainloop Authors.
// Copyright 2024-2025 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -23,7 +23,11 @@ import (

var updateGolden bool

const testEmail = "john@cyberdyne.io"
const (
testEmail = "john@cyberdyne.io"
testName = "John Doe"
testAPITokenName = "test-token"
)

func TestMain(m *testing.M) {
flag.BoolVar(&updateGolden, "update-golden", false, "update the expected golden files")
Expand Down
4 changes: 2 additions & 2 deletions app/controlplane/pkg/auditor/events/group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ func TestGroupEvents(t *testing.T) {
}

if tt.actor == auditor.ActorTypeUser {
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
} else {
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, ""))
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, "", testAPITokenName))
}

eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)
Expand Down
4 changes: 2 additions & 2 deletions app/controlplane/pkg/auditor/events/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ func TestProjectEvents(t *testing.T) {
auditor.WithOrgID(orgUUID),
}
if tt.actor == auditor.ActorTypeUser {
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
} else {
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, ""))
opts = append(opts, auditor.WithActor(auditor.ActorTypeSystem, uuid.Nil, "", testAPITokenName))
}

eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the API token test-token",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the API token test-token",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the API token test-token expiring at 2025-01-01T00:00:00Z",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": " has revoked the API token test-token",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the group test-group",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has deleted the group test-group",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has added user test@example.com to the group test-group as a maintainer",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has removed user test@example.com from the group test-group",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated user test@example.com in the group test-group",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated the group test-group",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated the group test-group",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has added user 'test@example.com' to the project 'test-project' with role 'viewer'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has added user 'test@example.com' to the project 'test-project' with role 'admin'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "SYSTEM",
"ActorID": null,
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "system@chainloop.dev has added user 'test@example.com' to the project 'test-project' with role 'viewer'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has removed user 'test@example.com' from the project 'test-project'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "SYSTEM",
"ActorID": null,
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "system@chainloop.dev has removed user 'test@example.com' from the project 'test-project'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated user 'test@example.com' role in project 'test-project' from 'viewer' to 'admin'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "SYSTEM",
"ActorID": null,
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "system@chainloop.dev has updated user 'test@example.com' role in project 'test-project' from 'viewer' to 'admin'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has logged in",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io role changed from 'role:org:owner' to 'role:org:member'",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has signed up",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has attached the workflow test-workflow to the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has attached the workflow test-workflow to the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has created the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has deleted the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has deleted the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has updated the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has detached the workflow test-workflow from the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has detached the workflow test-workflow from the workflow contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the workflow test-workflow on project test-project with the contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has created the workflow test-workflow on project test-project with the contract test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has deleted the workflow test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has deleted the workflow test-contract",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated the workflow test-contract on project test-project",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has updated the workflow test-contract on project test-project",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "USER",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"ActorName": "John Doe",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated the workflow test-contract on project test-project",
"Info": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"ActorType": "API_TOKEN",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "",
"ActorName": "test-token",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 1089bb36-e27b-428b-8009-d015c8737c54 has updated the workflow test-contract on project test-project",
"Info": {
Expand Down
4 changes: 2 additions & 2 deletions app/controlplane/pkg/auditor/events/user_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2024 The Chainloop Authors.
// Copyright 2024-2025 The Chainloop Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -82,7 +82,7 @@ func TestUserEvents(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts := []auditor.GeneratorOption{
auditor.WithActor(auditor.ActorTypeUser, userUUID, testEmail),
auditor.WithActor(auditor.ActorTypeUser, userUUID, testEmail, testName),
auditor.WithOrgID(orgUUID),
}

Expand Down
4 changes: 2 additions & 2 deletions app/controlplane/pkg/auditor/events/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ func TestWorkflowEvents(t *testing.T) {
auditor.WithOrgID(orgUUID),
}
if tt.actor == auditor.ActorTypeAPIToken {
opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, ""))
opts = append(opts, auditor.WithActor(auditor.ActorTypeAPIToken, tt.actorID, "", testAPITokenName))
} else {
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail))
opts = append(opts, auditor.WithActor(auditor.ActorTypeUser, tt.actorID, testEmail, testName))
}

eventPayload, err := auditor.GenerateAuditEvent(tt.event, opts...)
Expand Down
Loading
Loading