@@ -11,7 +11,6 @@ import (
11
11
"github.com/nais/api/internal/auditlogger/audittype"
12
12
"github.com/nais/api/internal/auth/authz"
13
13
"github.com/nais/api/internal/database"
14
- "github.com/nais/api/internal/logger"
15
14
"github.com/nais/api/internal/slug"
16
15
"github.com/sirupsen/logrus"
17
16
"github.com/sirupsen/logrus/hooks/test"
@@ -35,19 +34,18 @@ func Test_Logf(t *testing.T) {
35
34
ctx := context .Background ()
36
35
db := database .NewMockDatabase (t )
37
36
msg := "some message"
38
- componentName := logger .ComponentNameGraphqlApi
39
37
40
38
t .Run ("missing audit action" , func (t * testing.T ) {
41
39
testLogger , hook := test .NewNullLogger ()
42
40
43
41
auditlogger .
44
- New (db , componentName , testLogger ).
42
+ New (db , testLogger ).
45
43
Logf (ctx , []auditlogger.Target {}, auditlogger.Fields {}, msg )
46
44
47
45
want := []* logrus.Entry {
48
46
{
49
47
Message : "unable to create auditlog entry: missing or invalid audit action" ,
50
- Data : logrus.Fields {"component" : componentName },
48
+ Data : logrus.Fields {},
51
49
Level : logrus .ErrorLevel ,
52
50
},
53
51
}
@@ -63,7 +61,7 @@ func Test_Logf(t *testing.T) {
63
61
Action : audittype .AuditActionAzureGroupAddMember ,
64
62
}
65
63
auditlogger .
66
- New (db , componentName , log ).
64
+ New (db , log ).
67
65
Logf (ctx , []auditlogger.Target {}, fields , msg )
68
66
})
69
67
@@ -73,7 +71,7 @@ func Test_Logf(t *testing.T) {
73
71
74
72
teamSlug := slug .Slug ("team-slug" )
75
73
reconcilerName := "github:teams"
76
- componentName := logger . ComponentName ( "github:teams" )
74
+ systemName := "some:system"
77
75
actorIdentity := "actor"
78
76
action := audittype .AuditActionAzureGroupAddMember
79
77
@@ -82,7 +80,7 @@ func Test_Logf(t *testing.T) {
82
80
auditlogger .UserTarget (userEmail ),
83
81
auditlogger .TeamTarget (teamSlug ),
84
82
auditlogger .ReconcilerTarget (reconcilerName ),
85
- auditlogger .ComponentTarget ( componentName ),
83
+ auditlogger .SystemTarget ( systemName ),
86
84
}
87
85
88
86
authenticatedUser := authz .NewMockAuthenticatedUser (t )
@@ -97,19 +95,18 @@ func Test_Logf(t *testing.T) {
97
95
}
98
96
99
97
db := database .NewMockDatabase (t )
100
- db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , componentName , & actorIdentity , audittype .AuditLogsTargetTypeUser , userEmail , action , msg ).Return (nil ).Once ()
101
- db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , componentName , & actorIdentity , audittype .AuditLogsTargetTypeTeam , teamSlug .String (), action , msg ).Return (nil ).Once ()
102
- db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , componentName , & actorIdentity , audittype .AuditLogsTargetTypeReconciler , reconcilerName , action , msg ).Return (nil ).Once ()
103
- db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , componentName , & actorIdentity , audittype .AuditLogsTargetTypeSystem , string ( componentName ) , action , msg ).Return (nil ).Once ()
98
+ db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , & actorIdentity , audittype .AuditLogsTargetTypeUser , userEmail , action , msg ).Return (nil ).Once ()
99
+ db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , & actorIdentity , audittype .AuditLogsTargetTypeTeam , teamSlug .String (), action , msg ).Return (nil ).Once ()
100
+ db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , & actorIdentity , audittype .AuditLogsTargetTypeReconciler , reconcilerName , action , msg ).Return (nil ).Once ()
101
+ db .EXPECT ().CreateAuditLogEntry (ctx , correlationID , & actorIdentity , audittype .AuditLogsTargetTypeSystem , systemName , action , msg ).Return (nil ).Once ()
104
102
105
103
auditlogger .
106
- New (db , componentName , testLogger ).
104
+ New (db , testLogger ).
107
105
Logf (ctx , targets , fields , msg )
108
106
109
107
want := []* logrus.Entry {
110
108
{
111
109
Data : logrus.Fields {
112
- "component" : componentName ,
113
110
"action" : action ,
114
111
"actor" : actorIdentity ,
115
112
"correlation_id" : correlationID .String (),
@@ -121,7 +118,6 @@ func Test_Logf(t *testing.T) {
121
118
},
122
119
{
123
120
Data : logrus.Fields {
124
- "component" : componentName ,
125
121
"action" : action ,
126
122
"actor" : actorIdentity ,
127
123
"correlation_id" : correlationID .String (),
@@ -133,7 +129,6 @@ func Test_Logf(t *testing.T) {
133
129
},
134
130
{
135
131
Data : logrus.Fields {
136
- "component" : componentName ,
137
132
"action" : action ,
138
133
"actor" : actorIdentity ,
139
134
"correlation_id" : correlationID .String (),
@@ -145,7 +140,7 @@ func Test_Logf(t *testing.T) {
145
140
},
146
141
{
147
142
Data : logrus.Fields {
148
- "component " : componentName ,
143
+ "system " : systemName ,
149
144
"action" : action ,
150
145
"actor" : actorIdentity ,
151
146
"correlation_id" : correlationID .String (),
0 commit comments