You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "mengw15 (via GitHub)" <gi...@apache.org> on 2026/08/14 02:55:25 UTC
[I] cover GuestAuthFilter and UserResource [texera]
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: notifications-unsubscribe@texera.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] cover GuestAuthFilter and UserResource [texera]
Posted by "mengw15 (via GitHub)" <gi...@apache.org>.
mengw15 closed issue #7650: cover GuestAuthFilter and UserResource
URL: https://github.com/apache/texera/issues/7650
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org