Commit graph

1169 commits

Author SHA1 Message Date
4b8bf0507d
Update CI workflow and sendmail test condition
Add the TEST_SENDMAIL environment variable for better control over sendmail tests. Optimize sendmail installation in CI by updating and installing ssmtp. Modify tests to check if TEST_SENDMAIL is set to "true" before running.
2024-10-26 16:25:42 +02:00
9072aef355
Remove support for Go 1.19 and 1.20 in CI workflow
This commit updates the CI configuration to no longer test against Go versions 1.19 and 1.20. The supported Go versions are now 1.21, 1.22, and 1.23, ensuring the CI pipeline aligns with our current support policy.
2024-10-26 15:58:13 +02:00
3aef85e324
Add SPDX license headers to CI workflow file
This change adds SPDX license headers to the .github/workflows/ci.yml file to ensure proper attribution and compliance with the MIT license. The added headers include copyright information and the applicable license type.
2024-10-26 15:57:27 +02:00
f82ac0c5ae
Update concurrency group names in GitHub Actions
This change modifies the concurrency group names to include OS and Go version for better differentiation. This prevents conflicts and ensures that concurrent jobs are properly managed based on their specific matrices.
2024-10-26 15:52:27 +02:00
eeccee0d94
Add checkout step to CI workflow
Ensure CI workflow has access to the latest code by adding a checkout step. This change is necessary for the golangci-lint action to function correctly with the most recent codebase.
2024-10-26 15:50:14 +02:00
9c57ba56cf
Add 'runs-on' directive to lint and govulncheck steps
This ensures the lint and vulnerability check steps run on the 'ubuntu-latest' environment. Establishing a clear execution environment helps maintain consistency across CI runs.
2024-10-26 15:48:10 +02:00
4d4aa1e1df
Add runs-on parameter to dependency review job
This change specifies that the dependency review job should run on the latest version of Ubuntu. It ensures consistency and clarity in the workflow configuration. This modification helps avoid potential issues related to unspecified runner environments.
2024-10-26 15:47:04 +02:00
960c015a93
Remove IPv6 and IPv4 test cases from msg_test.go
Removed test cases for IPv6 and IPv4 addresses from `msg_test.go` as they are no longer required. Also made a minor formatting adjustment to the `checkAddrHeader` function signature for better readability.
2024-10-26 15:45:01 +02:00
12e9a0cb5d
Simplify CI workflow branch checks
Removed file path filters on branch triggers in the CI workflow configuration. This allows the CI to run for any changes made in the main branch, ensuring broader test coverage and catching issues early.
2024-10-26 15:37:07 +02:00
9e6c1f0417
Consolidate CI workflows into a single file
Merged separate workflows for Codecov, dependency-review, golangci-lint, govulncheck, offline-tests, reuse compliance, and SonarQube into a unified CI workflow file in `.github/workflows/ci.yml`. This restructuring simplifies our CI setup and ensures more consistent and efficient pipeline management.
2024-10-26 15:33:05 +02:00
0e9646e0e4
Merge branch 'main' into feature/overhaul-tests 2024-10-26 14:58:41 +02:00
3a3eaed348
Refactor address header tests to use checkAddrHeader
Consolidate repeated header validation logic into the `checkAddrHeader` helper function. This refactoring improves code readability and maintainability by reducing redundancy and potential for errors.
2024-10-26 02:07:44 +02:00
e08d36d0b8
Refactor address header validation in tests
Replace repeated address header validation code with a helper function `checkAddrHeader` to reduce redundancy and improve readability. Also, add new test cases for `ToFromString` to handle valid addresses with and without empty fields.
2024-10-25 20:21:17 +02:00
c99b6c3f14
Fix ToFromString to handle and trim empty addresses
Previously, the ToFromString function split email addresses by commas but did not handle empty addresses or trim whitespace. Now, it trims each address and ignores any empty entries to ensure only valid addresses are processed. This prevents potential errors stemming from malformed input.
2024-10-25 19:54:41 +02:00
03da20fc39
Add unit tests for Msg_ToIgnoreInvalid behavior
Introduces new test cases to verify the Msg_ToIgnoreInvalid function handles various scenarios correctly. These tests check for behavior with valid addresses, invalid addresses, and a mix of both.
2024-10-25 19:43:05 +02:00
8b6a7927ef
Add dummy test function in msg_test.go
Introduce a new, empty test function `TestMsg_ToIgnoreInvalid` in `msg_test.go` to accommodate future test cases. This commit also aligns a comment for better readability.
2024-10-25 17:43:59 +02:00
1ea7b173c6
Add tests for Msg.AddToFormat
Introduced new test cases to validate Msg.AddToFormat functionality with both valid and invalid email addresses. Ensured proper error handling and address formatting in the message headers.
2024-10-25 17:16:46 +02:00
a7f81baa4b
Fix address references in tests and add AddTo functionality
Corrected incorrect address references in the `msg_test.go` file. Added new tests to validate the AddTo functionality, ensuring multiple addresses can be added and validated properly.
2024-10-25 17:13:22 +02:00
cb85a136c3
Add Goland noinspection comments to suppress deprecation warnings
This change adds `//goland:noinspection GoDeprecation` comments in the `msg_test.go` file. These comments suppress deprecation warnings for the `SetHeader` and `SetHeaderPreformatted` methods during test execution.
2024-10-25 17:05:22 +02:00
aa46b408ad
Add additional tests for From and To address handling
Refactor "From" related tests to improve error messages and add tests for the new "FromFormat" function. Introduce new tests to validate the "To" address handling, covering various valid and invalid address scenarios.
2024-10-25 17:03:57 +02:00
5d85be068d
Add comprehensive tests for email "From" field validation
Implemented extensive test cases for the "From" field in email messages, covering various valid and invalid email formats according to RFC5322. Verified correct handling for each scenario to ensure robustness of email address validation.
2024-10-25 16:36:34 +02:00
c47f08dc7f
Merge pull request #346 from wneessen/dependabot/github_actions/actions/setup-go-5.1.0
Bump actions/setup-go from 5.0.2 to 5.1.0
2024-10-25 16:32:48 +02:00
dependabot[bot]
87c0575dd4
Bump actions/setup-go from 5.0.2 to 5.1.0
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.0.2 to 5.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](0a12ed9d6a...41dfa10bad)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-25 13:39:33 +00:00
1caa2cfb92
Add tests for EnvelopeFrom and EnvelopeFromFormat methods
Implemented comprehensive tests for the EnvelopeFrom and EnvelopeFromFormat methods to ensure proper handling of valid and invalid email addresses. This includes validation of both address and format for the "EnvelopeFrom" header.
2024-10-25 15:14:06 +02:00
c8dbc9a735
Update tests for SetAddrHeader and add new test cases
Renamed existing test cases for clarity and added new test cases for SetAddrHeaderIgnoreInvalid function. The new tests cover multiple scenarios including valid/invalid addresses, and edge cases such as nil addrHeader map.
2024-10-25 15:00:53 +02:00
08fe44c051
Initialize address header map and enforce single 'From' address.
This commit ensures that the address header map is properly initialized before assigning addresses to it. Additionally, it enforces the rule that only a single 'From' address is allowed, preventing multiple addresses from being set for the 'From' header. These misses were found while working on the enhanced testing suite
2024-10-25 14:57:36 +02:00
7d352bc58e
Add comprehensive tests for header and address methods
Implemented extensive unit tests for setting various headers and address fields in the `Msg` struct, including setting general headers, preformatted headers, and address headers with various scenarios to ensure correctness and robustness.
2024-10-25 12:18:26 +02:00
9505f94e3d
Refactor header test structure and improve readability
Simplify test structure by renaming fields for clarity and brevity. AddressHeader tests and importance tests now use more concise and consistent naming conventions. This enhances readability and maintainability of the test code.
2024-10-25 12:18:12 +02:00
143e3b5b4f
Fix context in tests and improve error handling
Updated test cases to use a predefined context instead of creating new backgrounds. Additionally, improved error handling by checking for client creation failures and adding appropriate fatal log messages. These changes enhance test reliability and debugging clarity.
2024-10-25 11:46:48 +02:00
a2e9dbae11
Add unit tests for charset and header setting in messages
This commit introduces two new unit tests: `TestMsg_Charset` and `TestMsg_SetHeader`. These tests cover the functionality of setting and retrieving the character set and headers for messages, ensuring correctness and robustness.
2024-10-25 11:36:26 +02:00
69c5f43cbf
Refactor test cases in header_test.go
Consolidate repetitive test case definitions into separate slices for readability and maintainability. This change simplifies the addition of new test cases and reduces redundancy.
2024-10-25 11:36:17 +02:00
425a190eb1
fumpt'ed formatting 2024-10-25 11:36:05 +02:00
64aeb683ba
Format test cases for consistency
Reformat test cases in `client_test.go` for better readability and consistency by converting single-line struct definitions into multi-line blocks. This change improves code maintainability and aligns the formatting across similar tests.
2024-10-25 11:35:25 +02:00
1dba76948f
Simplify test descriptions in msg_test.go
Shortened the test case descriptions for better clarity and readability. Added a new test function 'TestMsg_Encoding' to verify encoding outputs.
2024-10-25 11:24:35 +02:00
120c2efd08
Refactor test cases with shared test data
Consolidated repetitive test data into shared variables to improve code maintainability and readability. This modification also helps in reducing redundancy and streamlining future updates to test data.
2024-10-25 11:18:09 +02:00
c4946af3ab
Refactor msg_test.go to streamline tests and reduce redundancy
Reorganized and condensed test cases for the NewMsg method by merging individual tests and removing obsolete functions. This improves maintainability and reduces duplication in the test suite.
2024-10-25 11:08:11 +02:00
64cfbf9e46
Rename test functions and add new header cases.
Renamed test functions from `TestHeader_String` to `TestHeader_Stringer` and `TestAddrHeader_String` to `TestAddrHeader_Stringer` for consistency. Additionally, added new header cases such as "Content-Description" and "X-Auto-Response-Suppress" to improve test coverage.
2024-10-25 09:53:49 +02:00
c58d52e49a
Refactor TestImportance_StringFuncs in header_test.go
Separated test cases for String, NumString, and XPrioString methods of the Importance object into distinct sub-tests. Improved readability and maintainability by grouping similar assertions together.
2024-10-25 09:48:00 +02:00
eebbaa2513
Refactor and reintegrate content type tests in file_test.go
Reintegrates previously commented out tests for file content types, ensuring they are part of a structured t.Run block. Enhances readability and maintains functionality by checking the presence and correctness of attachments in a more concise manner.
2024-10-25 09:40:15 +02:00
8353b4b255
Follow upstream for HELO during Quit bug
I reported the bug I fixed in 74fa3f6f62 to Go upstream. They fixed simpler by just ignoring the error (See: https://go.dev/cl/622476). We follow this patch accordingly. The upstream test has been adopted as well.
2024-10-25 09:33:45 +02:00
9834c6508d
Refactor file_test.go to use subtests
Consolidate multiple test functions into a single TestFile function using subtests. This improves test organization and enhances readability. Added a new test case for testing file name attachment.
2024-10-24 17:09:55 +02:00
75e035c783
Add test cases for various EML parsing scenarios
Introduced a series of test cases for validating EML parsing against different edge cases, including invalid headers, content types, and transfer encodings. Ensured both valid and invalid EML strings are covered to thoroughly test the robustness of the parser.
2024-10-24 16:42:11 +02:00
769783f037
Refactor error handling in eml parser
Removed redundant error checking in address parsing as netmail.ParseAddressList already performs necessary checks. Added a default error return for unsupported content disposition types to improve robustness.
2024-10-24 16:42:00 +02:00
9f1e1976fe
Fix assignment in error handling for EML parsing function
Correct the variable assignment in the `if err` statement to ensure proper error handling. This change eliminates a potential bug where the wrong variable might be used.
2024-10-24 14:49:24 +02:00
887e3cd768
Add EML parsing with new tests and examples
Introduce new EML files with valid and invalid examples. Implement tests for EML parsing from readers and files, checking for both successful parsing and expected failures on invalid inputs.
2024-10-24 13:36:03 +02:00
127cfdf2bc
Fix error variable declaration in eml.go
The error variable declaration has been corrected from "if err := parseEML(...)" to "if err = parseEML(...)". This change ensures consistency with the rest of the error handling code in the file.
2024-10-24 13:20:09 +02:00
7ed23bf01b
Remove outdated client test cases
Removed obsolete and redundant client test cases that were no longer relevant. This cleanup improves code maintainability and readability by eliminating excessive, unused test methods.
2024-10-24 12:53:37 +02:00
0310527eb5
Completed client.go tests
We've now covered 96% of all code. Everything else is not testable for us at this point.
2024-10-24 12:25:13 +02:00
1399a3331a
Refactor and extend client email tests
Refactor existing email sending tests by organizing multiple edge cases and adding robust test coverage. This includes adding checks for invalid sender/recipient addresses, handling DSN support, and ensuring proper client server interactions during failures like DATA init, DATA close, and MAIL FROM.
2024-10-24 12:03:56 +02:00
45ebcb95b3
Remove redundant connection check in send function.
The connection check is performed in the c.Reset call just before the c.checkconn call, making this redundant. Removing it simplifies the code and eliminates unnecessary error handling for connection status. This change helps improve code maintainability.
2024-10-24 12:02:57 +02:00