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/cmd/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions app/controlplane/pkg/auditor/events/events_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// Copyright 2024 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.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package events_test

import (
"flag"
"os"
"testing"
)

var updateGolden bool

const testEmail = "john@cyberdyne.io"

func TestMain(m *testing.M) {
flag.BoolVar(&updateGolden, "update-golden", false, "update the expected golden files")
// Parse the flags
flag.Parse()
os.Exit(m.Run())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ActionType": "WorkflowContractContractAttached",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

"ActorType": "API_TOKEN",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has attached the workflow test-workflow to the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract",
"workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_name": "test-workflow"
},
"Digest": "sha256:1107737635a6c56e4fe4143d678783ab06c0321192f62f56ae1a2d76dea57321"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ActionType": "WorkflowContractContractAttached",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"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": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract",
"workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_name": "test-workflow"
},
"Digest": "sha256:e3fe1a29d29f1427121c5023b5d643eb4f457aa7eacfc212b4cacce49c813512"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ActionType": "WorkflowContractCreated",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has created the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract"
},
"Digest": "sha256:94f1ad7880f9d5bfcbe6f3a5f3d63cfa714123cd8549f9dba2ac3cc62dd5273f"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ActionType": "WorkflowContractCreated",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has created the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract"
},
"Digest": "sha256:5036a6f579dbad881aeb656e4e6a402cff272e154ff5b9e7aa1631004458c07a"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ActionType": "WorkflowContractDeleted",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has deleted the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract"
},
"Digest": "sha256:6ecfc282f25617197cb98e5ee9a3695fd9f12de8a1b54fc01e90ed40cf024421"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"ActionType": "WorkflowContractDeleted",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has deleted the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract"
},
"Digest": "sha256:84d36161f79c03eea04a85262661a87f149f2ae2812000d46f5c9a994726ef7f"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ActionType": "WorkflowContractUpdated",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has updated the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract",
"new_revision_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"new_revision": 1,
"new_description": "test description"
},
"Digest": "sha256:db328afdbdc39f80f12f433e2740c6de395a3f84bb517a109935929a4178511d"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"ActionType": "WorkflowContractUpdated",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "API Token 2089bb36-e27b-428b-8009-d015c8737c55 has updated the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract",
"new_revision_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"new_revision": 1,
"new_description": "test description"
},
"Digest": "sha256:e289498cc45655632b4eef97fedd932a3c78323a6540809cd645e05cebcf3608"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ActionType": "WorkflowContractContractDetached",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorEmail": "john@cyberdyne.io",
"OrgID": "1089bb36-e27b-428b-8009-d015c8737c54",
"Description": "john@cyberdyne.io has detached the workflow test-workflow from the workflow contract test-contract",
"Info": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract",
"workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_name": "test-workflow"
},
"Digest": "sha256:c625fbc253b26e5f2cd3158f2b1eaf9be552a8d9d9f414addac36b1da7396661"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ActionType": "WorkflowContractContractDetached",
"TargetType": "WorkflowContract",
"TargetID": "1089bb36-e27b-428b-8009-d015c8737c54",
"ActorType": "API_TOKEN",
"ActorID": "2089bb36-e27b-428b-8009-d015c8737c55",
"ActorEmail": "",
"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": {
"workflow_contract_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_contract_name": "test-contract",
"workflow_id": "1089bb36-e27b-428b-8009-d015c8737c54",
"workflow_name": "test-workflow"
},
"Digest": "sha256:3abb7051833ec7052a7339ec632eed241c9adf216efe8f3f276d01ba29cc3732"
}
14 changes: 2 additions & 12 deletions app/controlplane/pkg/auditor/events/user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package events_test

import (
"encoding/json"
"flag"
"os"
"path/filepath"
"testing"
Expand All @@ -30,15 +29,6 @@ import (
"github.com/stretchr/testify/require"
)

var updateGolden bool

func TestMain(m *testing.M) {
flag.BoolVar(&updateGolden, "update-golden", false, "update the expected golden files")
// Parse the flags
flag.Parse()
os.Exit(m.Run())
}

func TestUserEvents(t *testing.T) {
userUUID, err := uuid.Parse("1089bb36-e27b-428b-8009-d015c8737c54")
require.NoError(t, err)
Expand All @@ -59,7 +49,7 @@ func TestUserEvents(t *testing.T) {
Email: testEmail,
},
},
expected: "testdata/user_signs_up.json",
expected: "testdata/users/user_signs_up.json",
},
{
name: "User logs in",
Expand All @@ -70,7 +60,7 @@ func TestUserEvents(t *testing.T) {
},
LoggedIn: time.Date(2024, time.January, 1, 0, 0, 0, 0, time.UTC),
},
expected: "testdata/user_logs_in.json",
expected: "testdata/users/user_logs_in.json",
},
}

Expand Down
Loading
Loading