Commit graph

1375 commits

Author SHA1 Message Date
6fbb88239f
Enable gosec linter and add exclusion rules
Added gosec to the list of enabled linters in `.golangci.toml`. Defined specific exclusion rules to ignore certain false positives and context-specific issues flagged by gosec, ensuring the linter does not impose on intentional code practices.
2024-11-15 12:35:15 +01:00
441d163e38
Merge pull request #369 from wneessen/dependabot/github_actions/fsfe/reuse-action-5.0.0
Bump fsfe/reuse-action from 4.0.0 to 5.0.0
2024-11-14 14:55:16 +01:00
dependabot[bot]
1a811f3bcf
Bump fsfe/reuse-action from 4.0.0 to 5.0.0
Bumps [fsfe/reuse-action](https://github.com/fsfe/reuse-action) from 4.0.0 to 5.0.0.
- [Release notes](https://github.com/fsfe/reuse-action/releases)
- [Commits](3ae3c6bdf1...bb774aa972)

---
updated-dependencies:
- dependency-name: fsfe/reuse-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-14 13:50:11 +00:00
da6bf26405
Merge pull request #368 from wneessen/feature/365_expose-error-code-in-senderror
Expose error code in SendError
2024-11-14 10:49:59 +01:00
2bde340428
Update SMTP test port variable and CI configuration
Changed the SMTP test server base port and updated the corresponding environment variable name to `TEST_BASEPORT_SMTP`. This ensures consistency across the test setup and CI workflow configuration.
2024-11-14 10:45:35 +01:00
a70dde5a4d
Add TEST_BASEPORT environment variable to CI workflow
In the CI configuration file, the TEST_BASEPORT environment variable was added to various job scopes. This ensures consistency and allows the test base port to be set properly across different OS versions and Go versions.
2024-11-14 10:41:10 +01:00
ca3f50552e
Allow configuration of test server port via environment variable
Moved TestServerPortBase initialization to use an environment variable `TEST_BASEPORT` if provided. This adjustment helps in specifying custom base ports for running tests, ensuring better flexibility in different testing environments.
2024-11-14 10:36:24 +01:00
bd655b768b
Refactor SendError initialization for better readability
Structured the initialization of SendError on connection errors to improve code readability and maintainability. This change affects the error handling in both client_120.go and client_119.go by spreading the error details across multiple lines.
2024-11-14 10:20:52 +01:00
c8d7cf86e1
Enhance error handling in Client's Send method
Added support for Enhanced Status Codes (ESC) when checking the SMTP client's extensions. The SendError struct now includes the error code and enhanced status code for improved diagnostics.
2024-11-14 10:17:18 +01:00
a5ac7c3370
Update error handling to include error code and status
Previously, only the isTemp flag was considered when aggregating errors. Now, the error code and enhanced status code from the last error are also included. This ensures more comprehensive error reporting and handling.
2024-11-13 23:04:39 +01:00
719e5b217c
Enhance error handling with ENHANCEDSTATUSCODES check
Added a check for the ENHANCEDSTATUSCODES extension and included error code and enhanced status code information in SendError. This helps in providing more detailed error reporting and troubleshooting.
2024-11-13 23:02:30 +01:00
f367db0278
Refactor error code functions and add enhanced status code tests
Renamed `getErrorCode` function to `errorCode` for consistency. Added new tests for the `enhancedStatusCode` function to validate its behavior with various error scenarios.
2024-11-13 22:53:18 +01:00
6268acac44
Refactor error handling by renaming functions.
Renamed `getErrorCode` to `errorCode` and `getEnhancedStatusCode` to `enhancedStatusCode` for consistency. Updated all references in `client.go` and `senderror.go` accordingly, improving readability and maintaining uniformity across the codebase.
2024-11-13 22:47:53 +01:00
e8fb977afe
Add tests for getErrorCode function
Introduce a suite of unit tests for the getErrorCode function to validate its behavior with various error types, including go-mail errors, permanent and temporary errors, wrapper errors, non-4xx/5xx errors, and non-3-digit codes.
2024-11-13 21:48:24 +01:00
615155bfc2
Add tests for SendError's enhanced status and error codes
Implemented new unit tests for SendError to validate the enhanced status code and error codes in various scenarios, including nil SendError cases, errors with no enhanced status code, and errors with both permanent and temporary error codes. This ensures the correctness of the error handling behavior across different conditions.
2024-11-13 21:27:27 +01:00
ad265cac57
Add ErrorCode method to SendError
Implemented ErrorCode method to retrieve the error code from the server response in SendError. This method distinguishes between server-generated errors and client-generated errors, returning 0 for errors generated by the client.
2024-11-13 21:26:11 +01:00
b9d9449252
Change test server port base for SMTP client tests
Updated the TestServerPortBase from 12025 to 30025 to avoid port conflicts with other services running on the common 12025 port. This adjustment aims to ensure that the tests run reliably in diverse environments.
2024-11-13 21:25:39 +01:00
6809084e80
Add enhanced status code and error code to SendError
Enhance error handling by adding error code and enhanced status code to the SendError struct. This allows for better troubleshooting and debugging by providing more detailed SMTP server responses.
2024-11-13 16:11:28 +01:00
29ad32e6d0
Merge pull request #366 from wneessen/dependabot/github_actions/sonarsource/sonarqube-scan-action-4.0.0
Bump sonarsource/sonarqube-scan-action from 3.1.0 to 4.0.0
2024-11-13 14:40:23 +01:00
d03c476fb7
Merge pull request #367 from wneessen/dependabot/github_actions/github/codeql-action-3.27.3
Bump github/codeql-action from 3.27.2 to 3.27.3
2024-11-13 14:40:04 +01:00
dependabot[bot]
2f97ebabd3
Bump github/codeql-action from 3.27.2 to 3.27.3
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.2 to 3.27.3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](9278e42166...396bb3e453)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-13 13:31:52 +00:00
dependabot[bot]
ea70b21c90
Bump sonarsource/sonarqube-scan-action from 3.1.0 to 4.0.0
Bumps [sonarsource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 3.1.0 to 4.0.0.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](13990a6956...94d4f8ac4a)

---
updated-dependencies:
- dependency-name: sonarsource/sonarqube-scan-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-13 13:31:45 +00:00
37ac2de2af
Merge pull request #364 from wneessen/dependabot/github_actions/github/codeql-action-3.27.2
Bump github/codeql-action from 3.27.1 to 3.27.2
2024-11-12 14:15:58 +01:00
dependabot[bot]
cff789883f
Bump github/codeql-action from 3.27.1 to 3.27.2
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.1 to 3.27.2.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](4f3212b617...9278e42166)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-12 13:13:53 +00:00
6c06c459da
Update README.md SMTP features and TLS support details
Revised the documentation for greater clarity: swapped the listed items for explicit and implicit SSL/TLS support, and detailed the supported SMTP authentication mechanisms in an itemized format. This ensures users understand all available options and configurations more clearly.
2024-11-11 20:23:42 +01:00
ccc104973e
Merge pull request #363 from wneessen/simplify-license
Remove CC0-1.0 license
2024-11-11 20:19:34 +01:00
935a523fa7
Change license to MIT
Updated SPDX identifiers from CC0-1.0 to MIT across multiple files, including `.github`, `CONTRIBUTING.md`, `README.md`, and more. Deleted the `LICENSES/CC0-1.0.txt` file as it is no longer relevant.
2024-11-11 20:16:09 +01:00
26f1ed3102
Merge pull request #362 from wneessen/fix-spelling
Fix spelling in some tests
2024-11-11 20:12:46 +01:00
29794fd6ad
Fix typo in Content-Disposition header in tests
Corrected multiple instances of the misspelled "Content-Dispositon" to "Content-Disposition" in the msgwriter_test.go file. This ensures that the error messages in the tests are accurate and improve code readability.
2024-11-11 20:08:58 +01:00
c7438a974c
Fix typos: change "non-existant" to "non-existent"
Corrected multiple instances of the word "non-existant" to "non-existent" in test descriptions to improve code clarity and accuracy. This change affects both smtp_test.go and msg_test.go files.
2024-11-11 20:07:55 +01:00
79d4c6fd07
Correct spelling errors in email validation comments
Fixed the spelling of "dot-separated" in comment explanations to ensure clarity. This makes the comments more accurate and easier to understand.
2024-11-11 20:06:47 +01:00
ad86c7ac4f
Correct typo in test name
The test name had a typo in the word "recipient." This commit corrects "recepient" to "recipient" to improve code readability and maintain consistency in naming conventions. This change does not modify any functional behavior of the tests.
2024-11-11 20:06:07 +01:00
580ef5ed48
Merge pull request #361 from wneessen/smtp-client-tests
SMTP client tests overhaul
2024-11-11 19:57:31 +01:00
800c266ccb
Refactor test server code for thread safety
Moved serverProps outside goroutines to improve code readability and maintainability. Added a RWMutex to serverProps to ensure thread-safe access to EchoBuffer, preventing race conditions during concurrent writes.
2024-11-11 19:53:14 +01:00
f7bdd8fffc
Refactor error variable in smtp test
Renamed 'err' to 'berr' to avoid shadowing outer variable. This change ensures clearer error handling and avoids potential issues with variable scope and readability in the smtp_test.go file.
2024-11-11 19:21:50 +01:00
77175a2952
Refactor and relocate JSON logger tests for Go 1.21 compliance
Removed JSON logger tests from smtp_test.go and relocated them to a new file smtp_121_test.go, ensuring compliance with Go 1.21. This change maintains test integrity while organizing tests by Go version compatibility.
2024-11-11 19:15:13 +01:00
08034e6ff8
Refactor echoBuffer parameter handling in tests
Removed redundant mutex and streamlined anonymous goroutine syntax for test server setup by passing echoBuffer directly as a parameter. This change reduces unnecessary use of shared resources and simplifies the test code structure and fixes potential race conditions
2024-11-11 18:58:31 +01:00
2156fbc01e
Add mutex lock to handle concurrent SMTP test server connections
Introduced a mutex to the SMTP test server properties to ensure thread-safe access when handling connections. This prevents race conditions and improves the reliability of the test server under concurrent load.
2024-11-11 18:51:14 +01:00
61353d51e5
Fix variable declarations in test cases
Changed variable declarations from '=' to ':=' to properly handle errors within the SMTP test cases. This ensures that errors are correctly captured and reported when writing to the EchoBuffer.
2024-11-11 18:43:48 +01:00
1d19290e1c
Merge branch 'main' into smtp-client-tests 2024-11-11 18:36:00 +01:00
7da30e09e1
Refactor smtp tests to improve clarity and error handling
Removed unused variables and improved error handling in smtp_test.go. Adjusted to capture only error in auth.Next() calls, ensuring accurate validation. Added necessary error checks after creating new client connections to prevent test failures.
2024-11-11 18:35:10 +01:00
c58aa35454
Add tests for Client debug logging behavior
Introduce unit tests to verify the behavior of the debug logging in the Client. Confirm that logs are correctly produced when debug mode is enabled and appropriately suppressed when it is disabled.
2024-11-11 18:25:39 +01:00
3b9085e19d
Add tests for GetTLSConnectionState method in SMTP client
This commit introduces four test cases for the GetTLSConnectionState method. These tests cover scenarios with a valid TLS connection, no connection, a non-TLS connection, and a non-TLS connection with the TLS flag set on the client. This ensures comprehensive validation of the method's behavior across different states.
2024-11-11 18:17:36 +01:00
007d214c68
Add comprehensive tests for SMTP client functionality
Introduce new tests to verify behaviors of client methods including SetLogAuthData, SetDSNRcptNotifyOption, SetDSNMailReturnOption, HasConnection, and UpdateDeadline. Ensure these tests cover various scenarios such as successful operations, edge cases, and failure conditions.
2024-11-11 18:08:56 +01:00
8fbd94a675
Add nil check in UpdateDeadline method
Ensure that the connection is not nil before setting the deadline in the UpdateDeadline method. This prevents a potential runtime panic when attempting to set a deadline on a nil connection.
2024-11-11 18:07:31 +01:00
5e3d14f842
Add tests for Client's SetLogger method
This commit introduces unit tests for the Client's SetLogger method. It verifies the correct logger type is set and ensures setting a nil logger does not override an existing logger.
2024-11-11 17:49:07 +01:00
9412f31874
Lock mutex when setting the logger
Add mutex locking to ensure thread-safety when setting the logger in the `smtp` package. This prevents potential race conditions and ensures that the logger is updated consistently in concurrent operations.
2024-11-11 17:47:59 +01:00
59f2778a38
Add tests for Client's SetDebugLog method
These tests verify the behavior of the SetDebugLog method in various scenarios such as enabling and disabling debug logging and ensuring the logger type is as expected. This improves the robustness and reliability of the debug logging functionality in the Client class.
2024-11-11 17:44:31 +01:00
2cc670659e
Remove obsolete SMTP client tests
Deleted multiple outdated and redundant tests from the SMTP client test suite to streamline and improve the maintainability of the test codebase. This change focuses on removing tests that are no longer relevant or have been superseded by other methods.
2024-11-11 17:36:24 +01:00
2d384a7d37
Add unit tests for SMTP client extensions, reset, and noop
Introduced new unit tests to verify the SMTP client's behavior with extensions, reset, and noop commands under various server conditions. Updated server response handling to correctly manage feature sets when they are empty.
2024-11-11 17:29:43 +01:00