Skip to content

test(auth): add unit test coverage for JwtAuth, RequestLoggingFilter, and UserActivityTracker#6093

Open
aglinxinyuan wants to merge 2 commits into
apache:mainfrom
aglinxinyuan:test-auth-jwt-logging
Open

test(auth): add unit test coverage for JwtAuth, RequestLoggingFilter, and UserActivityTracker#6093
aglinxinyuan wants to merge 2 commits into
apache:mainfrom
aglinxinyuan:test-auth-jwt-logging

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Add unit test coverage for three common/auth classes, selected from the Codecov report. No production-code changes.

File Codecov before What the tests pin
JwtAuth.scala 55% jwtClaims maps every User field onto its claim; expiry is derived from AuthConfig (the expireInDays arg is ignored — a real quirk); token round-trips back through JwtParser; null optional fields don't error
RequestLoggingFilter.scala 0% doFilter delegates to the chain and logs the request line; register wires the filter onto the servlet context for all dispatch types (mockito for the servlet/jetty types)
UserActivityTracker.scala 28.6% extends the existing spec to cover the markActive and evictStale catch blocks (via a throwing clock)

Any related issues, documentation, discussions?

Follow-up to the review feedback on #6043: prioritize tests that fill uncovered code paths.

How was this PR tested?

  • sbt "Auth/testOnly *JwtAuthSpec *RequestLoggingFilterSpec *UserActivityTrackerSpec" — 15 tests, all green
  • sbt "Auth/Test/scalafmtCheck" and sbt "Auth/scalafixAll --check" — clean

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 4.8 [1M context])

… and UserActivityTracker

- JwtAuth.jwtClaims: field mapping, config-derived expiry (ignoring expireInDays),
  JwtParser round-trip, null-optional-field tolerance
- RequestLoggingFilter: chain delegation + request logging, and register() wiring
  (mockito for the servlet/jetty types)
- UserActivityTracker: extend the existing spec to cover the markActive and evictStale
  catch blocks via a throwing clock
Copilot AI review requested due to automatic review settings July 4, 2026 06:42
@github-actions github-actions Bot added the common label Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Yicong-Huang
    You can notify them by mentioning @Yicong-Huang in a comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Scala unit-test coverage for previously under-tested common/auth behavior (JWT claim issuance/parsing, request logging filter wiring, and user-activity tracking exception paths) without changing production code.

Changes:

  • Add JwtAuthSpec to pin claim mapping, config-derived expiry, token round-trip via JwtParser, and null-optional handling.
  • Add RequestLoggingFilterSpec to cover doFilter and register wiring.
  • Extend UserActivityTrackerSpec to exercise markActive/evictStale exception-swallowing paths.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
common/auth/src/test/scala/org/apache/texera/auth/JwtAuthSpec.scala New unit tests for JWT claim contents, expiry derivation, and parser round-trip.
common/auth/src/test/scala/org/apache/texera/auth/RequestLoggingFilterSpec.scala New unit tests for request logging filter delegation and servlet-context registration.
common/auth/src/test/scala/org/apache/texera/auth/UserActivityTrackerSpec.scala Additional tests to cover exception-handling branches in activity tracking.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread common/auth/src/test/scala/org/apache/texera/auth/RequestLoggingFilterSpec.scala Outdated
Comment thread common/auth/src/test/scala/org/apache/texera/auth/JwtAuthSpec.scala
@codecov-commenter

codecov-commenter commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.54%. Comparing base (186115d) to head (e90b63a).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6093      +/-   ##
============================================
+ Coverage     58.17%   58.54%   +0.37%     
- Complexity     3144     3179      +35     
============================================
  Files          1132     1132              
  Lines         43674    43674              
  Branches       4734     4734              
============================================
+ Hits          25407    25569     +162     
+ Misses        16831    16675     -156     
+ Partials       1436     1430       -6     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø)
agent-service 44.59% <ø> (ø) Carriedforward from aab81e9
amber 61.67% <ø> (+0.96%) ⬆️
computing-unit-managing-service 0.00% <ø> (ø)
config-service 52.30% <ø> (ø)
file-service 62.81% <ø> (ø)
frontend 51.31% <ø> (ø) Carriedforward from aab81e9
notebook-migration-service 78.57% <ø> (ø)
pyamber 91.15% <ø> (ø) Carriedforward from aab81e9
workflow-compiling-service 55.14% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 3 worse · ⚪ 12 noise (<±5%) · 0 without baseline

Compared against main a3f22bb benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 378 0.231 25,428/33,686/33,686 us 🔴 -9.1% / 🔴 +119.7%
bs=100 sw=10 sl=64 777 0.474 126,668/155,558/155,558 us ⚪ within ±5% / 🔴 +43.6%
bs=1000 sw=10 sl=64 924 0.564 1,075,537/1,160,058/1,160,058 us ⚪ within ±5% / 🔴 +12.4%
Baseline details

Latest main a3f22bb from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 378 tuples/sec 416 tuples/sec 772.08 tuples/sec -9.1% -51.0%
bs=10 sw=10 sl=64 MB/s 0.231 MB/s 0.254 MB/s 0.471 MB/s -9.1% -51.0%
bs=10 sw=10 sl=64 p50 25,428 us 23,488 us 12,745 us +8.3% +99.5%
bs=10 sw=10 sl=64 p95 33,686 us 34,127 us 15,330 us -1.3% +119.7%
bs=10 sw=10 sl=64 p99 33,686 us 34,127 us 19,054 us -1.3% +76.8%
bs=100 sw=10 sl=64 throughput 777 tuples/sec 815 tuples/sec 982.64 tuples/sec -4.7% -20.9%
bs=100 sw=10 sl=64 MB/s 0.474 MB/s 0.497 MB/s 0.6 MB/s -4.6% -21.0%
bs=100 sw=10 sl=64 p50 126,668 us 121,213 us 101,961 us +4.5% +24.2%
bs=100 sw=10 sl=64 p95 155,558 us 150,823 us 108,335 us +3.1% +43.6%
bs=100 sw=10 sl=64 p99 155,558 us 150,823 us 114,379 us +3.1% +36.0%
bs=1000 sw=10 sl=64 throughput 924 tuples/sec 920 tuples/sec 1,013 tuples/sec +0.4% -8.8%
bs=1000 sw=10 sl=64 MB/s 0.564 MB/s 0.562 MB/s 0.618 MB/s +0.4% -8.8%
bs=1000 sw=10 sl=64 p50 1,075,537 us 1,087,133 us 993,573 us -1.1% +8.2%
bs=1000 sw=10 sl=64 p95 1,160,058 us 1,147,506 us 1,032,489 us +1.1% +12.4%
bs=1000 sw=10 sl=64 p99 1,160,058 us 1,147,506 us 1,065,526 us +1.1% +8.9%
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,528.71,200,128000,378,0.231,25427.62,33686.07,33686.07
1,100,10,64,20,2573.55,2000,1280000,777,0.474,126668.02,155557.81,155557.81
2,1000,10,64,20,21638.61,20000,12800000,924,0.564,1075537.23,1160057.84,1160057.84

- JwtAuth: assert the expiry window tracks AuthConfig for two very different expireInDays
  values, proving the argument is ignored rather than coincidentally matching
- RequestLoggingFilter: force the request-log logger to INFO and use Mockito inOrder to
  assert the chain is invoked before the request fields are read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants