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

refactor(apiv1): accounts api #825

Open
wants to merge 116 commits into
base: master
Choose a base branch
from
Open

refactor(apiv1): accounts api #825

wants to merge 116 commits into from

Conversation

fmartingr
Copy link
Member

@fmartingr fmartingr commented Jan 27, 2024

  • Refactor Accounts API to API v1
  • Renamed current AccountsDomain to AuthDomain to handle authentication logic in a separate layer.
  • Adds AccountsDomain which contains logic related to managing Accounts and is the layer that communicates with teh database.
  • New AccountDTO object. Account is the exact database representation of the row, AccountDTO is the object we can transfer around in the rest of the code with more fields, helper methods, etc. Is also the object used in creates/updates for the Accounts with included validation.
    • Changed the Account usages around the code to be AccountDTO.
  • Database interface changes:
    • Added new Database.ListAccounts (formerly Database.GetAccounts). Using List* to better differentiate between the method that return one account and the one that return many.
      • Accepts new ListAccountOptions to filter by keyword, username and owner. Also allows retrieving the password field which is disabled by default.
    • DeleteAccount replaces DeleteAccounts. Now only deletes one account, iteration logic moved to the AccountsDomain.
    • SaveAccount is not called CreateAccount
  • New middleware: AdminRequired
  • Changed /api/v1/auth/account to allow updating the entire user data, not only the settings. This should be backwards compatible.
  • Added model.Ptr helper that return an object as a pointer of itself
  • Added ValidationError error type to return directly from domains and have details available to expose to the API.
  • Testutil additions: NewAdminUser and options.WithAuthToken to avoid boilerplate in tests.
  • e2e tests: Added plywright to perform real e2e testing on a browser, added tests to check that the current account workflows work (login, logout, add user, remove user, change password, change password for self)

Closes #657

@fmartingr fmartingr self-assigned this Jan 27, 2024
@fmartingr fmartingr changed the title refactor: migrate accounts API refactor(apiv1): accounts api to v1 Jun 3, 2024
@go-shiori go-shiori deleted a comment from codecov bot Jun 3, 2024
@go-shiori go-shiori deleted a comment from codecov bot Jun 3, 2024
Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 77.01674% with 151 lines in your changes missing coverage. Please review.

Project coverage is 39.15%. Comparing base (a9a45cc) to head (dbb8ad7).

Files with missing lines Patch % Lines
internal/database/mysql.go 67.64% 22 Missing and 11 partials ⚠️
internal/database/pg.go 67.32% 22 Missing and 11 partials ⚠️
internal/database/sqlite.go 66.66% 21 Missing and 8 partials ⚠️
internal/domains/accounts.go 72.36% 15 Missing and 6 partials ⚠️
internal/domains/auth.go 84.90% 6 Missing and 2 partials ⚠️
internal/http/routes/api/v1/auth.go 84.31% 6 Missing and 2 partials ⚠️
internal/cmd/root.go 0.00% 6 Missing ⚠️
internal/testutil/accounts.go 57.14% 4 Missing and 2 partials ⚠️
internal/http/routes/api/v1/tags.go 0.00% 2 Missing ⚠️
internal/database/migrations.go 0.00% 0 Missing and 1 partial ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #825      +/-   ##
==========================================
+ Coverage   34.64%   39.15%   +4.51%     
==========================================
  Files          61       65       +4     
  Lines        5499     5782     +283     
==========================================
+ Hits         1905     2264     +359     
+ Misses       3359     3243     -116     
- Partials      235      275      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fmartingr fmartingr force-pushed the fmartingr/issue657 branch from cfe1345 to 0835804 Compare June 3, 2024 17:18
@fmartingr fmartingr marked this pull request as ready for review June 3, 2024 17:53
@fmartingr fmartingr changed the title refactor(apiv1): accounts api to v1 refactor(apiv1): accounts api to v1 (WIP) Jun 3, 2024
@fmartingr fmartingr marked this pull request as draft June 3, 2024 21:43
@fmartingr fmartingr changed the title refactor(apiv1): accounts api to v1 (WIP) refactor(apiv1): accounts api to v1 Jun 3, 2024
@fmartingr fmartingr changed the title refactor(apiv1): accounts api to v1 refactor(apiv1): accounts api Jun 3, 2024
@Monirzadeh
Copy link
Collaborator

Hi after a long time :)
as i see E2E test not pass yet

@fmartingr
Copy link
Member Author

Hi after a long time :) as i see E2E test not pass yet

Yeah still working on the PR and the E2E tests :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

APIv1: Accounts
2 participants