Skip to content
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

Use authentication enabled docker for integration test #4160

Merged
merged 46 commits into from Mar 14, 2024

Conversation

chilagrow
Copy link
Contributor

@chilagrow chilagrow commented Mar 8, 2024

Description

For task test-integration-mongodb, the image mongodb_secured is used which has authentication and authorization enable. It already has an user created in docker.
Calling setup.SetupWithOpts(t, &setup.SetupOpts{SetupUser: true}) creates an user with root authorization permission at the beginning of the test, use that authenticated user for the test and drops the user at the end. Since all test share the users in admin.system.users database, the unique username is used for each test.

For task test-integration-postgresql and task test-integration-sqlite the listener is created within setup, and each test creates its own independent postgresql database or sqlite directory, so no other test accesses it.
Calling setup.SetupWithOpts(t, &setup.SetupOpts{SetupUser: true}) creates an user using local exception at the beginning of the test, and entire postgresql database is dropped at the end of the test.

  • postgresql example postgres://username@127.0.0.1:5432/testcommandsauthenticationlogoutauthenticateduser
  • sqlite example file:../tmp/sqlite-tests/testcommandsauthenticationlogoutauthenticateduser/

Closes #4100.

Readiness checklist

  • I added/updated unit tests (and they pass).
  • I added/updated integration/compatibility tests (and they pass).
  • I added/updated comments and checked rendering.
  • I made spot refactorings.
  • I updated user documentation.
  • I ran task all, and it passed.
  • I ensured that PR title is good enough for the changelog.
  • (for maintainers only) I set Reviewers (@FerretDB/core), Milestone (Next), Labels, Project and project's Sprint fields.
  • I marked all done items in this checklist.

@chilagrow chilagrow self-assigned this Mar 8, 2024
Copy link

codecov bot commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 92.98246% with 4 lines in your changes are missing coverage. Please review.

Project coverage is 73.81%. Comparing base (58ff7b0) to head (b063d16).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4160      +/-   ##
==========================================
- Coverage   73.85%   73.81%   -0.04%     
==========================================
  Files         339      339              
  Lines       22786    22827      +41     
==========================================
+ Hits        16828    16850      +22     
- Misses       4676     4691      +15     
- Partials     1282     1286       +4     
Files Coverage Δ
internal/handler/common/find.go 100.00% <100.00%> (ø)
integration/setup/setup.go 83.62% <97.22%> (+2.24%) ⬆️
integration/setup/client.go 80.48% <85.00%> (+4.29%) ⬆️

... and 7 files with indirect coverage changes

Flag Coverage Δ
filter-true 67.15% <92.98%> (-0.16%) ⬇️
integration 67.15% <92.98%> (-0.16%) ⬇️
mongodb-1 5.12% <87.71%> (+0.22%) ⬆️
postgresql-1 46.52% <61.40%> (-0.10%) ⬇️
postgresql-2 49.51% <61.40%> (+0.12%) ⬆️
postgresql-3 49.88% <61.40%> (+0.58%) ⬆️
sqlite-1 45.69% <61.40%> (-0.07%) ⬇️
sqlite-2 48.73% <61.40%> (+0.19%) ⬆️
sqlite-3 ?
unit 32.55% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@chilagrow chilagrow added the code/chore Code maintenance improvements label Mar 11, 2024
@chilagrow chilagrow added this to the Next milestone Mar 11, 2024
@chilagrow chilagrow marked this pull request as ready for review March 11, 2024 01:54
@chilagrow chilagrow requested review from AlekSi, ptrfarkas and a team as code owners March 11, 2024 01:54
@mergify mergify bot removed the conflict PRs that have merge conflicts label Mar 12, 2024
@chilagrow chilagrow marked this pull request as ready for review March 13, 2024 03:40
@chilagrow chilagrow enabled auto-merge (squash) March 13, 2024 03:46
@chilagrow chilagrow changed the title Cleanup integration test for setting up user Use authentication enabled image for integration test Mar 13, 2024
@chilagrow chilagrow changed the title Use authentication enabled image for integration test Use authentication enabled docker for integration test Mar 13, 2024
Copy link
Member

@rumyantseva rumyantseva left a comment

Choose a reason for hiding this comment

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

Cool! This will also help with sessions testing too :)

@AlekSi
Copy link
Member

AlekSi commented Mar 14, 2024

I will check the security workflow failure

@chilagrow chilagrow merged commit 1bfc549 into FerretDB:main Mar 14, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/chore Code maintenance improvements
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Implement localhost exception
4 participants