Commit graph

1394 commits

Author SHA1 Message Date
410343496c
Refactor and expand TestLoginAuth
Rename and uncomment TestLoginAuth with more test cases, ensuring coverage for successful and failed authentication scenarios, including checks for unencrypted logins and server response errors. This improves test robustness and coverage.
2024-11-07 21:14:52 +01:00
2391010e3a
Rename parameter for consistency in auth functions
Updated the parameter name `allowUnEnc` to `allowUnenc` in both `LoginAuth` and `PlainAuth` functions to maintain consistent naming conventions. This change improves code readability and follows standard naming practices.
2024-11-07 20:58:20 +01:00
e42b022076
Merge branch 'main' into smtp-client-tests 2024-11-07 20:50:59 +01:00
b4aa414a4d
Update doc.go
Bump version to v0.5.2
2024-11-06 11:22:54 +01:00
0f46ce800e
Merge pull request #354 from wneessen/test_close_on_nil
Add test for closing a nil smtpclient
2024-11-06 10:55:59 +01:00
03e53cbabc
Merge branch 'main' into test_close_on_nil 2024-11-06 10:52:32 +01:00
632ac17845
Merge pull request #353 from sonalys/fix/close_panic
Fix(close): Access to nil variable causes panic
2024-11-06 10:51:53 +01:00
a5fcb3ae8b
Add test for closing a nil smtpclient
Introduce a unit test to ensure that invoking Close on a nil smtpclient instance returns nil without errors. This enhances the robustness of the client closure functionality. This test accommodates the fix provided with PR #353
2024-11-06 10:47:31 +01:00
Alysson Ribeiro
8c4eb62360
Fix(close): Access to nil variable causes panic 2024-11-06 10:20:59 +01:00
3cfd20576d
Rename and expand TestPlainAuth_noEnc with additional checks
Refactor the test function `TestPlainAuth_noEnc` to include subtests for better organization and add more comprehensive error handling. This improves clarity and robustness by verifying various authentication scenarios and expected outcomes.
2024-11-03 16:13:54 +01:00
99c4378107
Refactor and streamline authentication tests
Improved the structure and readability of the authentication tests by using subtests for each scenario, ensuring better isolation and clearer failure reporting. Removed unnecessary imports and redundant code, reducing complexity and enhancing maintainability.
2024-11-01 19:22:28 +01:00
a3fe2f88d5
Add test for MessageID on nil SendError
This test ensures that when MessageID is called on a nil SendError, it returns an empty string. This additional check helps verify the correct behavior of the MessageID method under nil conditions.
2024-11-01 18:47:21 +01:00
9ca7d24f6a
Merge pull request #352 from wneessen/more-test-improvements
More test improvements
2024-11-01 16:39:34 +01:00
ec10e0b132
Remove redundant upgrade command in CI workflow
The `sudo apt-get -y upgrade` command was removed from the CI workflow's "Install sendmail" step. This change simplifies the installation process by ensuring only the necessary updates and installations are performed, which can contribute to faster and more reliable CI runs.
2024-11-01 16:36:06 +01:00
0fcde10768
Remove output redirection from sendmail install
This change ensures that the output of the apt-get commands is no longer redirected to /dev/null. This aids in debugging by making command outputs visible in the CI logs.
2024-11-01 16:33:48 +01:00
e37dd39654
Refactor senderror_test.go for improved test clarity
Consolidated multiple duplicate test cases into grouped sub-tests with clear names. This enhances readability and maintainability, ensures proper test isolation, and removes redundant code.
2024-11-01 15:58:11 +01:00
25b7f81e3b
Refactor error handling logic and string formatting
Replaced constant with named error for readability and maintainability in the error handling condition. Adjusted error message formatting by removing an extra space for consistency.
2024-11-01 15:57:59 +01:00
27a3985240
Refactor and expand random string tests
Refactored the test for `randomStringSecure` to better organize test cases using subtests. Added new test cases to check failures with a broken rand.Reader, improving test coverage and robustness.
2024-11-01 15:24:47 +01:00
d7e0b48567
Merge pull request #350 from wneessen/dependabot/github_actions/actions/dependency-review-action-4.4.0
Bump actions/dependency-review-action from 4.3.5 to 4.4.0
2024-10-29 14:59:58 +01:00
f74e16c822
Merge pull request #351 from wneessen/dependabot/github_actions/sonarsource/sonarqube-quality-gate-action-8406f4f1edaffef38e9fb9c53eb292fc1d7684fa
Bump sonarsource/sonarqube-quality-gate-action from dc2f7b0dd95544cd550de3028f89193576e958b9 to 8406f4f1edaffef38e9fb9c53eb292fc1d7684fa
2024-10-29 14:21:21 +01:00
dependabot[bot]
9ea960b796
Bump sonarsource/sonarqube-quality-gate-action
Bumps [sonarsource/sonarqube-quality-gate-action](https://github.com/sonarsource/sonarqube-quality-gate-action) from dc2f7b0dd95544cd550de3028f89193576e958b9 to 8406f4f1edaffef38e9fb9c53eb292fc1d7684fa.
- [Release notes](https://github.com/sonarsource/sonarqube-quality-gate-action/releases)
- [Commits](dc2f7b0dd9...8406f4f1ed)

---
updated-dependencies:
- dependency-name: sonarsource/sonarqube-quality-gate-action
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-29 13:17:03 +00:00
dependabot[bot]
fc3d9749c0
Bump actions/dependency-review-action from 4.3.5 to 4.4.0
Bumps [actions/dependency-review-action](https://github.com/actions/dependency-review-action) from 4.3.5 to 4.4.0.
- [Release notes](https://github.com/actions/dependency-review-action/releases)
- [Commits](a6993e2c61...4081bf99e2)

---
updated-dependencies:
- dependency-name: actions/dependency-review-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-29 13:16:58 +00:00
edc5300b54
Merge pull request #349 from wneessen/fix-dependency-review-bug
Add base-ref and head-ref to Dependency Review action
2024-10-28 22:59:42 +01:00
8bc9b8b7fd
Add base-ref and head-ref to Dependency Review action
This update ensures that the Dependency Review action has the correct references for base and head in pull request events. It helps in accurately reviewing dependency changes between the branches. Reference: https://github.com/actions/dependency-review-action/issues/456#issuecomment-1537840047
2024-10-28 22:59:16 +01:00
c8478fb6c0
Merge pull request #348 from wneessen/feature/overhaul-tests
Overhaul test suite and GH CI workflow
2024-10-28 22:52:01 +01:00
c9f8a2acdd
Fix newline character in test attachment string for Windows
Updated the base64-encoded string for attachments in the tests to reflect the correct newline character for Windows. This ensures that the test cases correctly validate the presence of attachments in the mail messages.
2024-10-28 22:28:23 +01:00
b63a3dab9a
Adjust tests to handle platform-specific differences.
Added platform-specific checks for header and attachment content in `msgwriter_test.go`. This ensures compatibility and correct behavior on different operating systems, such as Windows and FreeBSD.
2024-10-28 22:20:09 +01:00
3a046d728e
Add test attachment and its license file
Introduced a new test attachment file for testing purposes. Also added a corresponding license file indicating copyright and licensing information for transparency and compliance.
2024-10-28 22:08:35 +01:00
a30215ebce
Add tests for writeHeader and writeBody functions
Introduce comprehensive test cases for the writeHeader and writeBody functions in msgWriter. These tests cover various scenarios including handling of multiple header values, edge cases, and error conditions in body writing operations. This concludes all tests for msgwriter.go.
2024-10-28 22:02:43 +01:00
b7a87fb15b
Add tests for MsgWriter_writeString function
Implemented tests to validate the MsgWriter writeString method for successful writes, failure scenarios, and handling pre-existing errors in the writer. This improves coverage and ensures robustness of the MsgWriter component.
2024-10-28 21:30:50 +01:00
dedb0e36c8
Add tests for MsgWriter writePart functionality
Introduce tests to validate MsgWriter's handling of message parts. This includes ensuring charset defaulting behavior and proper inclusion of part descriptions.
2024-10-28 21:25:22 +01:00
8e11fabbaf
Remove unused TestRcpt constant from client_test.go
The TestRcpt constant was defined but never used within the test file, leading to unnecessary clutter. Removing it enhances code readability and maintainability.
2024-10-28 21:14:05 +01:00
5c8d07407f
Add tests for file attachments in msgWriter
This commit introduces unit tests covering various scenarios for attaching files in email messages using msgWriter. These tests check for proper encoding, custom content types, different transfer encodings, custom descriptions, and handling attachments without body parts.
2024-10-28 21:13:36 +01:00
61244a541e
Refactor msgWriter tests and add new test cases
Reorganize existing tests for msgWriter and writeMsg, adding subtests for various encoding, charset, and failure scenarios. Enhanced tests to cover multipart/mixed, multipart/related, multipart/alternative, application/pgp-encrypted, application/pgp-signature messages, and handling of preformatted headers.
2024-10-28 20:52:38 +01:00
7bbcee7d48
Add tests for consecutive attachment and embedding
Added tests for `AttachReader`, `AttachReadSeeker`, `EmbedReader`, and `EmbedReadSeeker` methods with consecutive `WriteTo` calls to ensure attachments are not lost. This addresses issue #110 on GitHub. Also, added tests for `SetBodyWriter` with a nil option and improved existing tests for `hasAlt` and `hasMixed` methods. This commit concludes the tests for msg.go. We have achieved the highest possible coverage.
2024-10-28 19:47:00 +01:00
d0280ea9ad
Add test coverage for WriteToTempFile method
Implemented unit tests for WriteToTempFile, including successful writing to a temporary file and failure cases due to an invalid TMPDIR. These tests ensure the method behaves correctly under different conditions and enhances code robustness.
2024-10-28 18:52:02 +01:00
c28bd7e331
Prevent Test Execution Without Env Variable
Added a check for the "PERFORM_UNIX_OPEN_WRITE_TESTS" environment variable to conditionally skip tests. This ensures tests are only executed when the variable is set to "true". Additionally, commented out the TestMsg_WriteToTempFileFailed function.
2024-10-28 17:42:18 +01:00
1c6b9faf15
Add tests for Msg.HasSendError method.
Introduce several unit tests for the Msg.HasSendError function to ensure its correct behavior under different conditions like unsent messages, failed deliveries, and temporary errors. This enhances the validation of message error states within the system.
2024-10-28 17:34:35 +01:00
7d670a1f24
Add temporary failure condition in client test
Introduce a new `FailTemp` property to simulate a temporary failure during the DATA transmission phase in tests. This helps ensure better coverage and handling of specific error conditions.
2024-10-28 17:31:11 +01:00
2f3809f33e
Add tests for Msg.UpdateReader method
Implemented new tests to validate the Msg.UpdateReader method, ensuring its functionality for both success and failure scenarios. Removed obsolete tests for Msg.NewReader to maintain code clarity and relevance.
2024-10-28 17:20:40 +01:00
4ecc6f2b0c
Refactor Msg tests and remove unused code
Reorganized message writing tests to create more concise and specific scenarios, including new context tests and WriteToFile tests. Removed outdated and redundant test cases to streamline the test suite.
2024-10-28 17:14:06 +01:00
a59173fae0
Refactor buffer initialization in NewReader.
Replaced bytes.Buffer{} with bytes.NewBuffer(nil) for buffer initialization in NewReader method of Msg. This change enhances clarity and consistency in buffer handling.
2024-10-28 17:04:44 +01:00
d39953c837
Update environment variables in CI workflow
Standardize variables by using expressions for consistency. This change ensures that all environment variables for Unix and Sendmail tests are sourced from GitHub variables.
2024-10-28 16:32:24 +01:00
6cbb6745bb
Add new test cases for message attachments and long headers
Introduce tests for "AttachFile" with a normal file and "WriteTo" with long headers. Additionally, remove outdated and redundant test functions.
2024-10-28 15:58:14 +01:00
4506472319
Add missing newline after test function
A newline was added after an anonymous function block to improve code readability. This change adheres to proper formatting practices and enhances the maintainability of the code.
2024-10-28 15:43:32 +01:00
759452f346
Refactor tests to remove redundant unix-specific cases
Unified the test cases for AttachFile, AttachReader, AttachReadSeeker, EmbedFile, EmbedReader, and EmbedReadSeeker by incorporating the previously separate UNIX-specific tests into the general test files. This change enhances maintainability by reducing code duplication and ensuring more consistent test coverage across platforms.
2024-10-28 15:42:20 +01:00
4eb9d8a1fa
Add tests for Msg.Write and WriteTo error handling
Implemented tests for the Msg.Write method and enhanced WriteTo error handling. Also added a failReadWriteSeekCloser type to explicitly simulate IO failures in tests, ensuring comprehensive reliability of error handling mechanisms.
2024-10-28 15:14:43 +01:00
afa65585a0
Add test for WriteToSkipMiddleware function in Msg structure
Implement a new test for the WriteToSkipMiddleware function to validate its behavior with normal mail parts. Ensure that the function properly skips the specified middleware and writes the message to a buffer correctly.
2024-10-28 14:58:55 +01:00
4a519a3b1f
Add tests for middleware application on messages
Introduced comprehensive test cases for applying middlewares (uppercase and encode) to messages. Also added tests for writing messages to memory buffers and parsing them back. Corrected messages in helper functions for consistency.
2024-10-28 14:54:42 +01:00
ae44d37d03
Add test for Msg_Reset function
This test ensures that the Reset method correctly clears all fields in the Msg struct. It verifies that the From, To, Subject, Body, Attachments, and Embeds fields are empty after calling Reset.
2024-10-28 12:30:13 +01:00