Skip to content

chore(coderd/database/dbauthz): migrate File, Group, APIKey, AuditLogs, and ConnectionLogs tests to mocked db #19299

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 7 commits into from
Aug 13, 2025

Conversation

hugodutka
Copy link
Contributor

Related to coder/internal#869

…with dbmock and gofakeit\n- Add expectations for GetFileByHashAndCreator, GetFileByID, GetFileIDByTemplateVersionID, InsertFile\n- Seed data with testutil.Fake\n\nRefs: coder/internal#869\nCo-authored-by: hugodutka <28019628+hugodutka@users.noreply.github.com>
@hugodutka hugodutka changed the title chore(coderd/database/dbauthz): migrate File, Group, APIKey, AuditLogs, and ConnectionLogs to mocked db chore(coderd/database/dbauthz): migrate File, Group, APIKey, AuditLogs, and ConnectionLogs tests to mocked db Aug 11, 2025
@hugodutka hugodutka requested a review from Emyrk August 11, 2025 17:53
blink-so bot added 4 commits August 11, 2025 17:55
…ubtests to s.Mocked\n- Seed data with testutil.Fake and gofakeit\n- Add gomock expectations for Group methods\n\nCo-authored-by: hugodutka <28019628+hugodutka@users.noreply.github.com>
… API key subtests to s.Mocked\n- Add gomock expectations for API key and external auth link methods\n\nCo-authored-by: hugodutka <28019628+hugodutka@users.noreply.github.com>
…logs tests to s.Mocked\n- Add gomock expectations for authorized and non-authorized code paths\n\nCo-authored-by: hugodutka <28019628+hugodutka@users.noreply.github.com>
…onnection log tests to s.Mocked\n- Add gomock expectations (authorized and non-authorized paths)\n\nCo-authored-by: hugodutka <28019628+hugodutka@users.noreply.github.com>
@hugodutka hugodutka force-pushed the hugodutka/dbauthz-mock-1 branch from 48918d5 to 1ff8f54 Compare August 11, 2025 17:56
params := database.GetGroupsParams{OrganizationID: g.OrganizationID, HasMemberID: gm.UserID}
row := database.GetGroupsRow{Group: g, OrganizationName: o.Name, OrganizationDisplayName: o.DisplayName}
dbm.EXPECT().GetGroups(gomock.Any(), params).Return([]database.GetGroupsRow{row}, nil).AnyTimes()
check.Args(params).Asserts(rbac.ResourceSystem, policy.ActionRead, g, policy.ActionRead).FailSystemObjectChecks()
Copy link
Member

Choose a reason for hiding this comment

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

FailSystemObjectChecks TIL!

@Emyrk Emyrk merged commit e10f29c into main Aug 13, 2025
31 checks passed
@Emyrk Emyrk deleted the hugodutka/dbauthz-mock-1 branch August 13, 2025 14:30
@github-actions github-actions bot locked and limited conversation to collaborators Aug 13, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants