mengw15 opened a new issue, #7650:
URL: https://github.com/apache/texera/issues/7650
### Task Summary
Two small amber classes have **no spec at all** (~33 uncovered lines total):
the guest authentication filter and the user joining-reason endpoints. **Goal:
bring both files to full coverage** — add the specs below and check the
coverage report for anything left. `AnyFlatSpec` + `Matchers`.
### Behavior to add
**GuestAuthFilter**
(`amber/src/main/scala/org/apache/texera/web/auth/GuestAuthFilter.scala`, ~13%,
14 lines) — pure, no DB needed
- The filter swaps in a guest identity. Mock a `ContainerRequestContext` and
call `filter(requestContext)`, then capture the `SecurityContext` it installs
via `verify(requestContext).setSecurityContext(captor.capture())` and assert
the anonymous implementation it builds:
- `getUserPrincipal` returns a `SessionUser` wrapping the `GUEST` user;
- `isUserInRole(role)` delegates to the authorizer — assert both an
allowed and a denied role;
- `isSecure` inherits from the incoming security context — cover an
incoming context that is secure, one that is not, and the **null** incoming
context (the code guards with `securityContext != null`);
- `getAuthenticationScheme` returns the filter's scheme.
- `GuestAuthFilter.GUEST` — assert the preset user's fields (it is built
once with `.tap`, no DB access).
- `Builder.newInstance` returns a fresh `GuestAuthFilter`.
**UserResource**
(`amber/src/main/scala/org/apache/texera/web/resource/dashboard/user/UserResource.scala`,
**0%**, 19 lines) — jOOQ; use embedded Postgres via `MockTexeraDB`
- Spec shape: `class UserResourceSpec extends AnyFlatSpec with
BeforeAndAfterAll with BeforeAndAfterEach with MockTexeraDB`; `beforeAll {
initializeDBAndReplaceDSLContext() }`; `beforeEach` builds a `UserDao` and
seeds a user.
- `isJoiningReasonRequired(uid)` — it reads the user via
`userDao.fetchOneByUid`: assert `true` for a seeded user whose joining reason
is absent, `false` once it is set, and the behaviour for an unknown uid.
- `updateJoiningReason(...)` — assert the value is persisted (re-read
through the DAO) and that a subsequent `isJoiningReasonRequired` flips to
`false`.
### 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]