Skip to content

add unit test coverage for SessionUser #5779

Description

@aglinxinyuan

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).

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
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions