Skip to content

Improve __str__ on APIToken#3686

Merged
hmpf merged 1 commit intomasterfrom
fix-str-on-apitoken
Dec 15, 2025
Merged

Improve __str__ on APIToken#3686
hmpf merged 1 commit intomasterfrom
fix-str-on-apitoken

Conversation

@hmpf
Copy link
Copy Markdown
Contributor

@hmpf hmpf commented Dec 12, 2025

Scope and purpose

Partial fix for #3683. New tokens will not be logged as the actual token string.

Create a token then visit the auditlog and find its creation log.

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

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 12, 2025

Test results

    27 files      27 suites   45m 55s ⏱️
 2 733 tests  2 733 ✅ 0 💤 0 ❌
20 254 runs  20 254 ✅ 0 💤 0 ❌

Results for commit 6b54924.

♻️ This comment has been updated with latest results.

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.05%. Comparing base (636a4e6) to head (6b54924).
⚠️ Report is 411 commits behind head on master.

Files with missing lines Patch % Lines
python/nav/web/api/v1/auth.py 0.00% 1 Missing ⚠️
python/nav/web/api/v1/views.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3686      +/-   ##
==========================================
+ Coverage   63.02%   63.05%   +0.02%     
==========================================
  Files         612      612              
  Lines       45228    45239      +11     
  Branches       43       43              
==========================================
+ Hits        28507    28526      +19     
+ Misses      16711    16703       -8     
  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
Contributor

@johannaengland johannaengland left a comment

Choose a reason for hiding this comment

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

Just a tiny suggestion, just if we decide to change the string representation again in the future

@hmpf hmpf requested a review from johannaengland December 12, 2025 09: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.

I guess this is fine as is: It achieves the goal.

Non-blocking suggestion in comments.

@hmpf hmpf force-pushed the fix-str-on-apitoken branch from 13ebdd7 to 6b54924 Compare December 15, 2025 11:41
@hmpf hmpf merged commit d3bc0bf into master Dec 15, 2025
17 of 18 checks passed
@hmpf hmpf deleted the fix-str-on-apitoken branch December 15, 2025 12:07
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants