10000 chore: add sql filter to fetching audit logs by Emyrk · Pull Request #14070 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: add sql filter to fetching audit logs #14070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
linting
  • Loading branch information
Emyrk committed Jul 31, 2024
commit 38280892a4852521302e280046375121a672cf1b
9 changes: 8 additions & 1 deletion coderd/database/dbauthz/dbauthz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,14 @@ func (s *MethodTestSuite) TestAuditLogs() {
_ = dbgen.AuditLog(s.T(), db, database.AuditLog{})
check.Args(database.GetAuditLogsOffsetParams{
LimitOpt: 10,
}).Asserts(rbac.ResourceAuditLog, policy.ActionRead)
}).Asserts()
}))
s.Run("GetAuthorizedAuditLogsOffset", s.Subtest(func(db database.Store, check *expects) {
_ = dbgen.AuditLog(s.T(), db, database.AuditLog{})
_ = dbgen.AuditLog(s.T(), db, database.AuditLog{})
check.Args(database.GetAuditLogsOffsetParams{
LimitOpt: 10,
}, emptyPreparedAuthorized{}).Asserts()
}))
}

Expand Down
11 changes: 10 additions & 1 deletion coderd/database/querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,6 @@ func TestAuthorizedAuditLogs(t *testing.T) {
ID: id,
OrganizationID: uuid.Nil,
}))

}

orgAuditLogs := map[uuid.UUID][]uuid.UUID{
Expand Down Expand Up @@ -827,6 +826,8 @@ func TestAuthorizedAuditLogs(t *testing.T) {
}

t.Run("NoAccess", func(t *testing.T) {
t.Parallel()

siteAuditorCtx := dbauthz.As(ctx, rbac.Subject{
FriendlyName: "member",
ID: uuid.NewString(),
Expand All @@ -840,6 +841,8 @@ func TestAuthorizedAuditLogs(t *testing.T) {
})

t.Run("SiteWideAuditor", func(t *testing.T) {
t.Parallel()

siteAuditorCtx := dbauthz.As(ctx, rbac.Subject{
FriendlyName: "owner",
ID: uuid.NewString(),
Expand All @@ -853,6 +856,8 @@ func TestAuthorizedAuditLogs(t *testing.T) {
})

t.Run("SingleOrgAuditor", func(t *testing.T) {
t.Parallel()

orgID := orgIDs[0]
siteAuditorCtx := dbauthz.As(ctx, rbac.Subject{
FriendlyName: "org-auditor",
Expand All @@ -867,6 +872,8 @@ func TestAuthorizedAuditLogs(t *testing.T) {
})

t.Run("TwoOrgAuditors", func(t *testing.T) {
t.Parallel()

first := orgIDs[0]
second := orgIDs[1]
siteAuditorCtx := dbauthz.As(ctx, rbac.Subject{
Expand All @@ -882,6 +889,8 @@ func TestAuthorizedAuditLogs(t *testing.T) {
})

t.Run("ErroneousOrg", func(t *testing.T) {
t.Parallel()

siteAuditorCtx := dbauthz.As(ctx, rbac.Subject{
FriendlyName: "org-auditor",
ID: uuid.NewString(),
Expand Down
2 changes: 1 addition & 1 deletion enterprise/audit/backends/postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ func TestPostgresBackend(t *testing.T) {
})
require.NoError(t, err)
require.Len(t, got, 1)
require.Equal(t, alog.ID, got[0].ID)
require.Equal(t, alog.ID, got[0].AuditLog.ID)
})
}
Loading
0