|
4 | 4 | "context"
|
5 | 5 | "encoding/json"
|
6 | 6 | "fmt"
|
7 |
| - "net/http" |
8 | 7 | "strconv"
|
9 | 8 | "testing"
|
10 | 9 | "time"
|
@@ -163,19 +162,18 @@ func TestAuditLogs(t *testing.T) {
|
163 | 162 | })
|
164 | 163 | require.NoError(t, err)
|
165 | 164 |
|
166 |
| - // Fetching audit logs without an organization selector should fail |
167 |
| - _, err = orgAdmin.AuditLogs(ctx, codersdk.AuditLogsRequest{ |
| 165 | + // Fetching audit logs without an organization selector should only |
| 166 | + // return organization audit logs. |
| 167 | + alogs, err := orgAdmin.AuditLogs(ctx, codersdk.AuditLogsRequest{ |
168 | 168 | Pagination: codersdk.Pagination{
|
169 | 169 | Limit: 5,
|
170 | 170 | },
|
171 | 171 | })
|
172 |
| - var sdkError *codersdk.Error |
173 |
| - require.Error(t, err) |
174 |
| - require.ErrorAsf(t, err, &sdkError, "error should be of type *codersdk.Error") |
175 |
| - require.Equal(t, http.StatusForbidden, sdkError.StatusCode()) |
| 172 | + require.NoError(t, err) |
| 173 | + require.Len(t, alogs.AuditLogs, 1) |
176 | 174 |
|
177 | 175 | // Using the organization selector allows the org admin to fetch audit logs
|
178 |
| - alogs, err := orgAdmin.AuditLogs(ctx, codersdk.AuditLogsRequest{ |
| 176 | + alogs, err = orgAdmin.AuditLogs(ctx, codersdk.AuditLogsRequest{ |
179 | 177 | SearchQuery: fmt.Sprintf("organization:%s", owner.OrganizationID.String()),
|
180 | 178 | Pagination: codersdk.Pagination{
|
181 | 179 | Limit: 5,
|
|
0 commit comments