Skip to content

test(common/auth): add spec for SessionUser#5788

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
EmilySun621:test/session-user
Jun 19, 2026
Merged

test(common/auth): add spec for SessionUser#5788
aglinxinyuan merged 1 commit into
apache:mainfrom
EmilySun621:test/session-user

Conversation

@EmilySun621

@EmilySun621 EmilySun621 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Adds a unit test spec for SessionUser. Tests cover:

  • getName returns the wrapped user.getName (Principal contract)
  • getUid, getEmail, getGoogleId delegate to the wrapped User
  • getUser returns the same User instance
  • isRoleOf(ADMIN) returns true when role is ADMIN
  • isRoleOf(ADMIN) returns false when role is REGULAR
    Mirrors the existing JwtParserSpec.scala style (AnyFlatSpec with Matchers).

Any related issues, documentation, discussions?

Closes: #5779

How was this PR tested?

Spec verified with sbt "common-auth/testOnly *SessionUserSpec". 7 tests passing.

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

Coauthored-by: Claude Code (Anthropic)

@codecov-commenter

codecov-commenter commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.27%. Comparing base (731d671) to head (61bae94).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5788      +/-   ##
============================================
- Coverage     53.30%   53.27%   -0.04%     
+ Complexity     2668     2665       -3     
============================================
  Files          1098     1098              
  Lines         42532    42532              
  Branches       4575     4575              
============================================
- Hits          22673    22660      -13     
- Misses        18530    18540      +10     
- Partials       1329     1332       +3     
Flag Coverage Δ *Carryforward flag
access-control-service 70.44% <ø> (ø)
agent-service 34.36% <ø> (ø) Carriedforward from 731d671
amber 53.73% <ø> (-0.08%) ⬇️
computing-unit-managing-service 1.65% <ø> (ø)
config-service 56.71% <ø> (ø)
file-service 57.06% <ø> (ø)
frontend 48.00% <ø> (ø) Carriedforward from 731d671
pyamber 90.13% <ø> (ø) Carriedforward from 731d671
python 90.80% <ø> (ø) Carriedforward from 731d671
workflow-compiling-service 58.69% <ø> (ø)

*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

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

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

Compared against main 731d671 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 399 0.243 24,639/31,625/31,625 us 🔴 +16.1% / 🟢 -9.6%
🟢 bs=100 sw=10 sl=64 798 0.487 124,785/136,631/136,631 us 🟢 -7.0% / 🔴 +11.1%
bs=1000 sw=10 sl=64 919 0.561 1,093,236/1,146,102/1,146,102 us ⚪ within ±5% / 🔴 +12.4%
Baseline details

Latest main 731d671 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 399 tuples/sec 428 tuples/sec 410.82 tuples/sec -6.8% -2.9%
bs=10 sw=10 sl=64 MB/s 0.243 MB/s 0.261 MB/s 0.251 MB/s -6.9% -3.1%
bs=10 sw=10 sl=64 p50 24,639 us 21,228 us 23,785 us +16.1% +3.6%
bs=10 sw=10 sl=64 p95 31,625 us 33,137 us 34,980 us -4.6% -9.6%
bs=10 sw=10 sl=64 p99 31,625 us 33,137 us 34,980 us -4.6% -9.6%
bs=100 sw=10 sl=64 throughput 798 tuples/sec 830 tuples/sec 891.94 tuples/sec -3.9% -10.5%
bs=100 sw=10 sl=64 MB/s 0.487 MB/s 0.507 MB/s 0.544 MB/s -3.9% -10.5%
bs=100 sw=10 sl=64 p50 124,785 us 120,027 us 112,277 us +4.0% +11.1%
bs=100 sw=10 sl=64 p95 136,631 us 146,910 us 139,802 us -7.0% -2.3%
bs=100 sw=10 sl=64 p99 136,631 us 146,910 us 139,802 us -7.0% -2.3%
bs=1000 sw=10 sl=64 throughput 919 tuples/sec 917 tuples/sec 1,041 tuples/sec +0.2% -11.7%
bs=1000 sw=10 sl=64 MB/s 0.561 MB/s 0.56 MB/s 0.635 MB/s +0.2% -11.7%
bs=1000 sw=10 sl=64 p50 1,093,236 us 1,087,415 us 972,714 us +0.5% +12.4%
bs=1000 sw=10 sl=64 p95 1,146,102 us 1,156,618 us 1,023,057 us -0.9% +12.0%
bs=1000 sw=10 sl=64 p99 1,146,102 us 1,156,618 us 1,023,057 us -0.9% +12.0%
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,501.88,200,128000,399,0.243,24639.38,31624.51,31624.51
1,100,10,64,20,2504.73,2000,1280000,798,0.487,124785.49,136631.35,136631.35
2,1000,10,64,20,21771.56,20000,12800000,919,0.561,1093236.48,1146101.92,1146101.92

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 ScalaTest unit coverage in common-auth for SessionUser, ensuring its java.security.Principal contract and delegation behavior to the underlying jOOQ User POJO are pinned by tests.

Changes:

  • Introduces SessionUserSpec covering delegation for getName, getUid, getEmail, getGoogleId, and getUser.
  • Adds role-check coverage for isRoleOf for both matching (ADMIN) and non-matching (REGULAR vs ADMIN) cases.

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

@aglinxinyuan

Copy link
Copy Markdown
Contributor

For PR description, use Closes instead of related to link to the issue. related doesn't work.

@aglinxinyuan aglinxinyuan 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.

LGTM!

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jun 19, 2026
Merged via the queue into apache:main with commit d513324 Jun 19, 2026
25 checks passed
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 24, 2026
<!--
Thanks for sending a pull request (PR)! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
[Contributing to
Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
  2. Ensure you have added or run the appropriate tests for your PR
  3. If the PR is work in progress, mark it a draft on GitHub.
  4. Please write your PR title to summarize what this PR proposes, we 
    are following Conventional Commits style for PR titles as well.
  5. Be sure to keep the PR description updated to reflect all changes.
-->

### What changes were proposed in this PR?
<!--
Please clarify what changes you are proposing. The purpose of this
section
is to outline the changes. Here are some tips for you:
  1. If you propose a new API, clarify the use case for a new API.
  2. If you fix a bug, you can clarify why it is a bug.
  3. If it is a refactoring, clarify what has been changed.
  3. It would be helpful to include a before-and-after comparison using 
     screenshots or GIFs.
  4. Please consider writing useful notes for better and faster reviews.
-->


Adds a unit test spec for `SessionUser`. Tests cover:
- `getName` returns the wrapped `user.getName` (Principal contract)
- `getUid`, `getEmail`, `getGoogleId` delegate to the wrapped User
- `getUser` returns the same User instance
- `isRoleOf(ADMIN)` returns `true` when role is ADMIN
- `isRoleOf(ADMIN)` returns `false` when role is REGULAR
Mirrors the existing `JwtParserSpec.scala` style (AnyFlatSpec with
Matchers).

### Any related issues, documentation, discussions?
<!--
Please use this section to link other resources if not mentioned
already.
1. If this PR fixes an issue, please include `Fixes apache#1234`, `Resolves
apache#1234`
or `Closes apache#1234`. If it is only related, simply mention the issue
number.
  2. If there is design documentation, please add the link.
  3. If there is a discussion in the mailing list, please add the link.
-->

Closes: apache#5779

### How was this PR tested?
<!--
If tests were added, say they were added here. Or simply mention that if
the PR
is tested with existing test cases. Make sure to include/update test
cases that
check the changes thoroughly including negative and positive cases if
possible.
If it was tested in a way different from regular unit tests, please
clarify how
you tested step by step, ideally copy and paste-able, so that other
reviewers can
test and check, and descendants can verify in the future. If tests were
not added,
please describe why they were not added and/or why it was difficult to
add.
-->

Spec verified with `sbt "common-auth/testOnly *SessionUserSpec"`. 7
tests passing.

### Was this PR authored or co-authored using generative AI tooling?
<!--
If generative AI tooling has been used in the process of authoring this
PR,
please include the phrase: 'Generated-by: ' followed by the name of the
tool
and its version. If no, write 'No'. 
Please refer to the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) for
details.
-->
Coauthored-by: Claude Code (Anthropic)
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.

add unit test coverage for SessionUser

4 participants