@@ -95,92 +95,6 @@ func TestAuditLogs(t *testing.T) {
9595 require .Equal (t , foundUser , * alogs .AuditLogs [0 ].User )
9696 })
9797
98- t .Run ("IncludeOrganization" , func (t * testing.T ) {
99- t .Parallel ()
100-
101- ctx := context .Background ()
102- client := coderdtest .New (t , nil )
103- user := coderdtest .CreateFirstUser (t , client )
104-
105- o , err := client .CreateOrganization (ctx , codersdk.CreateOrganizationRequest {
106- Name : "new-org" ,
107- DisplayName : "New organization" ,
108- Description : "A new organization to love and cherish until the test is over." ,
109- Icon : "/emojis/1f48f-1f3ff.png" ,
110- })
111- require .NoError (t , err )
112-
113- err = client .CreateTestAuditLog (ctx , codersdk.CreateTestAuditLogRequest {
114- OrganizationID : o .ID ,
115- ResourceID : user .UserID ,
116- })
117- require .NoError (t , err )
118-
119- alogs , err := client .AuditLogs (ctx , codersdk.AuditLogsRequest {
120- Pagination : codersdk.Pagination {
121- Limit : 1 ,
122- },
123- })
124- require .NoError (t , err )
125- require .Equal (t , int64 (1 ), alogs .Count )
126- require .Len (t , alogs .AuditLogs , 1 )
127-
128- // Make sure the organization is fully populated.
129- require .Equal (t , & codersdk.MinimalOrganization {
130- ID : o .ID ,
131- Name : o .Name ,
132- DisplayName : o .DisplayName ,
133- Icon : o .Icon ,
134- }, alogs .AuditLogs [0 ].Organization )
135-
136- // OrganizationID is deprecated, but make sure it is set.
137- require .Equal (t , o .ID , alogs .AuditLogs [0 ].OrganizationID )
138-
139- // Delete the org and try again, should be mostly empty.
140- err = client .DeleteOrganization (ctx , o .ID .String ())
141- require .NoError (t , err )
142-
143- alogs , err = client .AuditLogs (ctx , codersdk.AuditLogsRequest {
144- Pagination : codersdk.Pagination {
145- Limit : 1 ,
146- },
147- })
148- require .NoError (t , err )
149- require .Equal (t , int64 (1 ), alogs .Count )
150- require .Len (t , alogs .AuditLogs , 1 )
151-
152- require .Equal (t , & codersdk.MinimalOrganization {
153- ID : o .ID ,
154- }, alogs .AuditLogs [0 ].Organization )
155-
156- // OrganizationID is deprecated, but make sure it is set.
157- require .Equal (t , o .ID , alogs .AuditLogs [0 ].OrganizationID )
158-
159- // Some audit entries do not have an organization at all, in which case the
160- // response omits the organization.
161- err = client .CreateTestAuditLog (ctx , codersdk.CreateTestAuditLogRequest {
162- ResourceType : codersdk .ResourceTypeAPIKey ,
163- ResourceID : user .UserID ,
164- })
165- require .NoError (t , err )
166-
167- alogs , err = client .AuditLogs (ctx , codersdk.AuditLogsRequest {
168- SearchQuery : "resource_type:api_key" ,
169- Pagination : codersdk.Pagination {
170- Limit : 1 ,
171- },
172- })
173- require .NoError (t , err )
174- require .Equal (t , int64 (1 ), alogs .Count )
175- require .Len (t , alogs .AuditLogs , 1 )
176-
177- // The other will have no organization.
178- require .Equal (t , (* codersdk .MinimalOrganization )(nil ), alogs .AuditLogs [0 ].Organization )
179-
180- // OrganizationID is deprecated, but make sure it is empty.
181- require .Equal (t , uuid .Nil , alogs .AuditLogs [0 ].OrganizationID )
182- })
183-
18498 t .Run ("WorkspaceBuildAuditLink" , func (t * testing.T ) {
18599 t .Parallel ()
186100
0 commit comments