Skip to content

Stop accessing/altering request.account directly#3599

Merged
hmpf merged 6 commits intomasterfrom
refactor-get-set-account
Oct 22, 2025
Merged

Stop accessing/altering request.account directly#3599
hmpf merged 6 commits intomasterfrom
refactor-get-set-account

Conversation

@hmpf
Copy link
Copy Markdown
Contributor

@hmpf hmpf commented Oct 17, 2025

Scope and purpose

Fixes #3598. Nobody should notice this change, tests should be green, sudo should work.

Contributor Checklist

Every pull request should have this checklist filled out, no matter how small it is.
More information about contributing to NAV can be found in the
Hacker's guide to NAV.

  • [ ] Added a changelog fragment for towncrier
  • [ ] Added/amended tests for new/changed code
  • [ ] Added/changed documentation
  • Linted/formatted the code with ruff, easiest by using pre-commit
  • Wrote the commit message so that the first line continues the sentence "If applied, this commit will ...", starts with a capital letter, does not end with punctuation and is 50 characters or less long. See https://cbea.ms/git-commit/
  • Based this pull request on the correct upstream branch: For a patch/bugfix affecting the latest stable version, it should be based on that version's branch (<major>.<minor>.x). For a new feature or other additions, it should be based on master.
  • [ ] If applicable: Created new issues if this PR does not fix the issue completely/there is further work to be done
  • [ ] If it's not obvious from a linked issue, described how to interact with NAV in order for a reviewer to observe the effects of this change first-hand (commands, URLs, UI interactions)
  • [ ] If this results in changes in the UI: Added screenshots of the before and after
  • [ ] If this adds a new Python source code file: Added the boilerplate header to that file

@hmpf hmpf requested review from a team, johannaengland, lunkwill42 and stveit October 17, 2025 06:41
@hmpf hmpf self-assigned this Oct 17, 2025
@hmpf hmpf added the nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes) label Oct 17, 2025
@hmpf hmpf force-pushed the refactor-get-set-account branch from a36edd7 to b4c9715 Compare October 17, 2025 06:47
@hmpf hmpf changed the title Refactor get set account Stop accessing/altering request.account directly Oct 17, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 17, 2025

Test results

    27 files      27 suites   45m 23s ⏱️
 2 622 tests  2 622 ✅ 0 💤 0 ❌
19 366 runs  19 366 ✅ 0 💤 0 ❌

Results for commit bfbb994.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 17, 2025

Codecov Report

❌ Patch coverage is 64.92147% with 67 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.50%. Comparing base (e53f9fa) to head (8bc85fd).
⚠️ Report is 270 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/web/useradmin/views.py 25.00% 15 Missing ⚠️
python/nav/web/webfront/views.py 66.66% 11 Missing ⚠️
python/nav/web/navlets/__init__.py 25.00% 9 Missing ⚠️
python/nav/web/netmap/api.py 12.50% 7 Missing ⚠️
python/nav/web/status2/views.py 69.23% 4 Missing ⚠️
python/nav/web/alertprofiles/views.py 76.92% 3 Missing ⚠️
python/nav/web/business/views.py 25.00% 3 Missing ⚠️
python/nav/web/portadmin/views.py 40.00% 3 Missing ⚠️
python/nav/web/api/v1/views.py 33.33% 2 Missing ⚠️
python/nav/web/navlets/report.py 33.33% 2 Missing ⚠️
... and 5 more
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3599      +/-   ##
==========================================
- Coverage   62.51%   62.50%   -0.01%     
==========================================
  Files         611      611              
  Lines       45020    45093      +73     
  Branches       43       43              
==========================================
+ Hits        28142    28186      +44     
- Misses      16868    16897      +29     
  Partials       10       10              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

LGTM. Some warts, but some of them will be fixed in subsequent PRs working with the auth system going forward...

@lunkwill42 lunkwill42 self-requested a review October 17, 2025 13:17
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

I see now that tests are failing?

@hmpf hmpf force-pushed the refactor-get-set-account branch from c2b89b9 to 6517661 Compare October 20, 2025 06:44
@hmpf hmpf force-pushed the refactor-get-set-account branch 2 times, most recently from 3e0d584 to 8de6484 Compare October 21, 2025 05:54
Copy link
Copy Markdown
Member

@lunkwill42 lunkwill42 left a comment

Choose a reason for hiding this comment

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

Provisional approval 😆

@hmpf hmpf force-pushed the refactor-get-set-account branch from bfbb994 to 8bc85fd Compare October 22, 2025 07:16
@sonarqubecloud
Copy link
Copy Markdown

@hmpf hmpf merged commit f35cca2 into master Oct 22, 2025
16 checks passed
@hmpf hmpf deleted the refactor-get-set-account branch October 22, 2025 07:23
johannaengland added a commit that referenced this pull request Nov 12, 2025
This was moved in #3599, but this instance was forgotten to be changed
Which lead an error when accessing the API when unauthenticated
johannaengland added a commit that referenced this pull request Nov 12, 2025
This was moved in #3599, but this instance was forgotten to be changed
Which lead an error when accessing the API when unauthenticated
johannaengland added a commit that referenced this pull request Nov 13, 2025
This was moved in #3599, but this instance was forgotten to be changed
Which lead an error when accessing the API when unauthenticated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nonews No news fragment is necessary for this PR (e.g. refactoring, cleanups, workflow/development changes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clean up get_account/set_account and usage of request.account in preparation for switching to request.user in Python

2 participants