aglinxinyuan opened a new issue, #5779:
URL: https://github.com/apache/texera/issues/5779

   ### Task Summary
   
   Add a `SessionUserSpec.scala` that pins how `SessionUser` wraps a jOOQ 
`User` and exposes it as a `java.security.Principal`, including the `isRoleOf` 
role check.
   
   ## Background
   
   `SessionUser` (`common/auth`, `SessionUser.scala`) wraps a generated `User` 
POJO and implements `java.security.Principal`. It delegates identity accessors 
to the wrapped user and adds a role predicate. It has no dedicated unit-spec 
(its `common/auth` sibling `HeaderField` is already a starter task, #5662).
   
   ```scala
   class SessionUser(val user: User) extends Principal {
     def getUser: User = user
     override def getName: String = user.getName
     def getUid: Integer = user.getUid
     def getEmail: String = user.getEmail
     def getGoogleId: String = user.getGoogleId
     def isRoleOf(role: UserRoleEnum): Boolean = user.getRole == role
   }
   ```
   
   ## Behavior to pin
   
   Construct a `User` POJO (set `uid`, `name`, `email`, `googleId`, `role` via 
setters), wrap it in `SessionUser`, and assert:
   
   | Surface | Contract |
   | --- | --- |
   | `getName` (Principal contract) | returns `user.getName` |
   | `getUid` / `getEmail` / `getGoogleId` | delegate to the wrapped user |
   | `getUser` | returns the same `User` instance |
   | `isRoleOf(role)` | `true` iff `user.getRole == role` — verify a match 
(e.g. `ADMIN` vs `ADMIN`) and a mismatch (`REGULAR` vs `ADMIN`) using 
`UserRoleEnum` |
   
   ## Scope
   
   - New spec: `SessionUserSpec.scala` under 
`common/auth/src/test/scala/org/apache/texera/auth/` (alongside the existing 
auth specs).
   - No production-code changes.
   
   ### Task Type
   - [ ] Refactor / Cleanup
   - [ ] DevOps / Deployment / CI
   - [x] Testing / QA
   - [ ] Documentation
   - [ ] Performance
   - [ ] Other
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to