The GitHub Actions job "Release Auditing" on 
texera.git/gh-readonly-queue/main/pr-7180-0f7a42610e124e3860e74780ed62bc59ec5afe67
 has succeeded.
Run started by GitHub user mengw15 (triggered by mengw15).

Head commit for run:
348fa884442990307b842fd7c0dd6ca005dd320c / Meng Wang <[email protected]>
test(amber): add unit test coverage for AuthResource (#7180)

### What changes were proposed in this PR?

Adds a spec for `AuthResource`

(`amber/src/main/scala/org/apache/texera/web/resource/auth/AuthResource.scala`),
which had no test coverage. Authentication is against the user table
(jOOQ) and
JWTs are issued via `JwtAuth`, so the spec runs on embedded Postgres via
`MockTexeraDB` (the established unit pattern, mirroring
`AdminExecutionResourceSpec` / `WorkflowExecutionsResourceSpec`). No
production
code was changed.

15 tests:

- `retrieveUserByUsernameAndPassword` — returns the user for correct
credentials;
`None` for a wrong password, an unknown user, and a null
username/password.
- `login` — issues a JWT whose subject (decoded through
`JwtAuth.jwtConsumer`) is
  the username for valid credentials, and rejects bad credentials with
  `NotAuthorizedException`.
- `register` — persists a `RESTRICTED` user with a hashed password
(verified with
the same `StrongPasswordEncryptor`) and issues a token, and rejects each
guard
branch (`empty username` / `empty email` / `malformed email` / `empty
password`
/ `duplicate username` / `duplicate email`) with
`NotAcceptableException`.
- `createAdminUser` — inserts the configured admin with the `ADMIN` role
and a
  hashed password, and is idempotent when an admin already exists.

Tokens are verified by decoding through `JwtAuth.jwtConsumer`
(subject/claims)
rather than asserting raw strings, so there are no time-sensitive
assertions.

### Any related issues, documentation, discussions?

Closes #7164

### How was this PR tested?

Unit tests, run locally against embedded Postgres (`MockTexeraDB`). All
pass, and
the failure path was verified by breaking an assertion to confirm the
suite goes
red:

```
sbt "WorkflowExecutionService/testOnly *AuthResourceSpec"
# Tests: succeeded 15, failed 0
sbt "WorkflowExecutionService/scalafmtCheck"           # clean
sbt "WorkflowExecutionService/Test/scalafix --check"   # clean
```

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

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

Report URL: https://github.com/apache/texera/actions/runs/30669827679

With regards,
GitHub Actions via GitBox

Reply via email to