Stirling-PDF/src/main/java/stirling/software/SPDF/config
Ludy 35304a1491
Enhance email error handling and expand test coverage (#3561)
# Description of Changes

Please provide a summary of the changes, including:

- **What was changed**  
- **EmailController**: Added a `catch (MailSendException)` block to
handle invalid-address errors, log the exception, and return a 500
response with the raw error message.
- **EmailServiceTest**: Added unit tests for attachment-related error
cases (missing filename, null filename, missing file, null file) and
invalid “to” address (null or empty), expecting `MessagingException` or
`MailSendException`.
- **MailConfigTest**: New test class verifying `MailConfig.java`
correctly initializes `JavaMailSenderImpl` with host, port, username,
password, default encoding, and SMTP properties.
- **EmailControllerTest**: Refactored into a parameterized test
(`shouldHandleEmailRequests`) covering four scenarios: success, generic
messaging error, missing `to` parameter, and invalid address formatting.

- **Why the change was made**  
- To ensure invalid email addresses and missing attachments are handled
gracefully at the controller layer, providing clearer feedback to API
clients.
- To improve overall test coverage and guard against regressions in
email functionality.
  - To enforce correct mail configuration via automated tests.

---

## Checklist

### General

- [x] I have read the [Contribution
Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md)
- [x] I have read the [Stirling-PDF Developer
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md)
(if applicable)
- [ ] I have read the [How to add new languages to
Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md)
(if applicable)
- [x] I have performed a self-review of my own code
- [x] My changes generate no new warnings

### Documentation

- [ ] I have updated relevant docs on [Stirling-PDF's doc
repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/)
(if functionality has heavily changed)
- [ ] I have read the section [Add New Translation
Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/HowToAddNewLanguage.md#add-new-translation-tags)
(for new translation tags only)

### UI Changes (if applicable)

- [ ] Screenshots or videos demonstrating the UI changes are attached
(e.g., as comments or direct attachments in the PR)

### Testing (if applicable)

- [ ] I have tested my changes locally. Refer to the [Testing
Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/DeveloperGuide.md#6-testing)
for more details.
2025-05-21 15:42:08 +01:00
..
fingerprint Frooodle/license (#1994) 2024-10-14 22:34:41 +01:00
interfaces SSO Refactoring (#2818) 2025-02-24 22:18:34 +00:00
security Enhance email error handling and expand test coverage (#3561) 2025-05-21 15:42:08 +01:00
AppConfig.java 🤖 format everything with pre-commit by <stirlingbot> (#3514) 2025-05-12 09:01:28 +01:00
AppUpdateService.java Enhance AppUpdateService: Add @Configuration Annotation for Improved Spring Boot Integration (#3036) 2025-02-23 20:02:46 +00:00
CleanUrlInterceptor.java SSO Refactoring (#2818) 2025-02-24 22:18:34 +00:00
ConfigInitializer.java Security fixes, enterprise stuff and more (#3241) 2025-03-25 17:57:17 +00:00
EndpointConfiguration.java Remove read only from forms (#3423) 2025-04-29 11:40:08 +01:00
EndpointInspector.java Refactor codebase to replace explicit constructors with Lombok annotations and remove boilerplat (#3415) 2025-04-25 14:35:12 +01:00
EndpointInterceptor.java Refactor codebase to replace explicit constructors with Lombok annotations and remove boilerplat (#3415) 2025-04-25 14:35:12 +01:00
EnterpriseEndpointFilter.java Cleanups and making distinction between pro and enterprise (#3250) 2025-03-27 12:42:45 +00:00
ExternalAppDepConfig.java Cleanups and making distinction between pro and enterprise (#3250) 2025-03-27 12:42:45 +00:00
FileFallbackTemplateResolver.java Fix TemplateResolver and LibreOfficeListener bugs (#3555) 2025-05-20 12:02:26 +01:00
InitialSetup.java Update legal URLs and improve OpenAPI metadata configuration (#3522) 2025-05-13 23:06:14 +01:00
InstallationPathConfig.java Refactor Path Handling (#3041) 2025-02-25 21:31:20 +00:00
LocaleConfiguration.java Refactor codebase to replace explicit constructors with Lombok annotations and remove boilerplat (#3415) 2025-04-25 14:35:12 +01:00
LogbackPropertyLoader.java File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00
MetricsConfig.java Update legal URLs and improve OpenAPI metadata configuration (#3522) 2025-05-13 23:06:14 +01:00
MetricsFilter.java Refactor codebase to replace explicit constructors with Lombok annotations and remove boilerplat (#3415) 2025-04-25 14:35:12 +01:00
OpenApiConfig.java Update legal URLs and improve OpenAPI metadata configuration (#3522) 2025-05-13 23:06:14 +01:00
PostHogConfig.java Dynamic paths for tools and removal of unused book endpoints (#3018) 2025-02-23 13:36:21 +00:00
PostHogLoggerImpl.java Posthog to log to log file (#2813) 2025-01-30 15:13:42 +00:00
RuntimePathConfig.java Refactor Path Handling (#3041) 2025-02-25 21:31:20 +00:00
StartupApplicationListener.java eol 2024-01-03 17:59:04 +00:00
WebMvcConfig.java Refactor codebase to replace explicit constructors with Lombok annotations and remove boilerplat (#3415) 2025-04-25 14:35:12 +01:00
YamlHelper.java Improved Configuration and YAML Management (#2966) 2025-02-25 21:52:59 +00:00
YamlPropertySourceFactory.java File paths dynamic (#2605) 2025-01-06 12:41:30 +00:00