aglinxinyuan opened a new issue, #7630:
URL: https://github.com/apache/texera/issues/7630
### Task Summary
`amber/src/main/scala/org/apache/texera/web/resource/GmailResource.scala`
sits at **31.2% of 77 lines** measured in isolation (39.0% on live Codecov,
where other suites incidentally touch its case class). A spec exists with 4
tests — extend it rather than adding a second.
**The file's name is misleading, and it changes the whole assessment.** This
is a **javax.mail / SMTP** resource, not a Google-OAuth one: there is no
`GoogleCredential`, no token exchange, no `clientId`. The only credential is an
SMTP app password read from config and consumed inside an `Authenticator`
callback that never fires unless a socket opens. So the parts worth testing are
not credential-gated at all.
What is reachable offline:
- **The recipient-format guard**, clause by clause — the null short-circuit,
the missing `@`, the empty local part, an embedded space, a dotless domain, and
the two-character TLD floor.
- **The admin fan-out** in `notifyUnauthorizedUser`, driven through
`MockTexeraDB` with two ADMIN rows and a REGULAR decoy, so narrowing the role
filter or notifying only the first admin are both visible.
- **The `ForbiddenException` guard** on a malformed applicant address.
Three things to get right:
1. **Never let a test reach `Transport.send`.** It dials
`smtp.gmail.com:465` with no connect or read timeout configured. The existing
`requireNoRealGmailSender()` guard fails loudly instead; keep calling it.
2. **A six-case malformed-address list is vacuous on its own.** A regex that
rejects *everything* keeps it green. It needs a companion test asserting a
well-formed address gets past the guard and fails later in delivery, so the two
together pin the regex from both sides.
3. **The fan-out fixture's admin addresses must be malformed in a way
unrelated to the regex clause under test.** Seeding them as `…@localhost`
couples the fan-out test to the domain rules — loosening the domain regex then
makes them deliverable and the fan-out test false-reddens. Use addresses with
no `@` at all.
Left unpinnable, and worth recording so nobody contorts a test around them:
both `catch { case ex: Exception => logger.warn(...) }` arms in
`notifyUnauthorizedUser` are unreachable (`sendEmail` wraps everything in a
`Try` and returns a `Left`; it never throws) and should be deleted rather than
reached. The applicant acknowledgement has no observable effect offline. And
only the admin notification's *recipient* is observable, not its payload —
`sendEmail` is on the companion object, so nothing can intercept what it was
handed; the builder's own contract is already pinned by `EmailTemplateSpec`.
### 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]