michaaels opened a new pull request, #7616:
URL: https://github.com/apache/hop/pull/7616
## Description
Fixes the Mail Server Connection test for SMTP configurations, including TLS,
TLS 1.2, and SSL connections.
Previously, `MailServerConnection.getSession()` changed the configured
`protocol` field from `SMTP` to either `smtp` or `smtps`. The connection test
then attempted to obtain and connect a Jakarta Mail `Store`, even though SMTP
is a transport protocol.
Depending on the security configuration, this resulted in either:
- `NoSuchProviderException: invalid provider`, because a Store provider was
requested for SMTP/SMTPS.
- A `NullPointerException` when `getStore()` returned `null` and
`Store.connect()` was called.
This PR keeps the configured logical protocol unchanged and calculates the
effective Jakarta Mail protocol locally.
## Changes
- Route `SMTP` and `SMTPS` connection tests through `jakarta.mail.Transport`.
- Keep IMAP, POP3, and MBOX connection tests on the `jakarta.mail.Store`
path.
- Use `smtp` for regular SMTP, TLS, and TLS 1.2 connections.
- Use `smtps` for SSL connections or when SMTPS is explicitly configured.
- Stop mutating the configured `protocol` while building the mail session.
- Resolve variables and normalize protocol/security values using `trim()` and
case-insensitive comparisons.
- Reject SMTP and unsupported Store protocols with
`NoSuchProviderException` instead of returning `null`.
- Preserve the existing public API and the valid behavior of receiving
protocols.
## Tests
Added unit tests covering:
- SMTP without secure authentication.
- SMTP with TLS.
- SMTP with TLS 1.2.
- SMTP with SSL.
- Explicit SMTPS.
- SMTP values with whitespace and mixed case.
- IMAP connection-test routing through Store.
- POP3 connection-test routing through Store.
- Preservation of the logical SMTP protocol.
- SMTPS session properties for SSL.
- Rejection of SMTP and unsupported protocols by `getStore()`.
- Verification that SMTP connection tests never request a Store.
No real SMTP or mail server is required by the tests.
## Validation
Executed:
```text
mvn -pl :hop-misc-mail -Dtest=MailServerConnectionTest test
--
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]