Commit graph

1377 commits

Author SHA1 Message Date
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
1bfec504ed
Add new SMTP test cases for various failure scenarios
This commit introduces multiple test cases to handle SMTP failure scenarios such as invalid host, newline in addresses, EHLO/HELO failures, and malformed data injections. Additionally, it includes improvements in error handling for these specific conditions.
2024-11-11 17:12:15 +01:00
87accd289e
Fix formatting in smtp_test.go and add new test cases
Corrected indentation inconsistencies in the smtp_test.go file. Added multiple test cases to verify the failure scenarios for `SendMail` under various conditions including invalid hostnames, newlines in the address fields, and server failures during EHLO/HELO, STARTTLS, and authentication stages.
2024-11-11 16:41:44 +01:00
de3493ee9c
Merge pull request #360 from wneessen/dependabot/github_actions/github/codeql-action-3.27.1
Bump github/codeql-action from 3.27.0 to 3.27.1
2024-11-11 16:09:11 +01:00
dependabot[bot]
5d977e7206
Bump github/codeql-action from 3.27.0 to 3.27.1
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.0 to 3.27.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](662472033e...4f3212b617)

---
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-11 13:21:05 +00:00
c6da393676
Add echo buffer to SMTP server tests
Refactored SMTP server tests to use an echo buffer for capturing responses. This allows for better validation of command responses without relying on error messages. Additionally, added a new test case to validate a full SendMail transaction with TLS and authentication.
2024-11-11 13:31:25 +01:00
c3252626e3
Reverted change made in 3fffcd15f6 2024-11-11 13:31:02 +01:00
3fffcd15f6
Remove deprecated test hook for STARTTLS
The testHookStartTLS variable and its related conditional code have been removed from the smtp.go file. This cleanup streamlines the TLS initiation process and removes unnecessary test-specific hooks no longer in use.
2024-11-11 12:54:39 +01:00
e9c7bdbb4e
Refactor TLS config initialization in tests
Replace repetitive TLS configuration code with a reusable `getTLSConfig` helper function for consistency and maintainability. Additionally, update port configuration and add new tests for mail data transmission.
2024-11-11 12:54:10 +01:00
75bfdd2855
Update smtp tests to use t.Fatalf for critical failures
Changed `t.Errorf` to `t.Fatalf` in multiple instances within the test cases. This ensures that the tests halt immediately upon a critical failure, improving test reliability and debugging clarity.
2024-11-11 12:28:52 +01:00
d446b491e2
Add client cleanup to SMTP tests and new TestClient_Rcpt
Update SMTP tests to use t.Cleanup for client cleanup to ensure proper resource release. Introduce a new test, TestClient_Rcpt, to verify recipient address handling under various conditions.
2024-11-10 14:31:18 +01:00
0d8d097ae1
Add tests for DSN, 8BITMIME, and SMTPUTF8 support in SMTP
Introduce new test cases to verify the SMTP server's ability to handle DSN, 8BITMIME, and SMTPUTF8 features. These tests ensure correct response behavior when these features are supported by the server.
2024-11-10 14:10:50 +01:00
0df228178a
Add extensive client tests for Mail, Verify, and Auth commands
Introduce new tests for the SMTP client covering scenarios for Mail, Verify, and Auth commands to ensure correct behavior under various conditions. Updated `simpleSMTPServer` implementation to handle more cases including VRFY and SMTPUTF8.
2024-11-10 14:06:05 +01:00
b7ffce62aa
Add TLS connection state tests for SMTP client
Introduce tests to verify TLS connection state handling in the SMTP client. Ensure that normal TLS connections return a valid state, and non-TLS connections do not wrongly indicate a TLS state.
2024-11-09 15:22:23 +01:00
8f28babc47
Add tests for Client StartTLS functionality
Introduce new tests to cover the Client's behavior when initiating a STARTTLS session under different conditions: normal operation, failure on EHLO/HELO, and a server not supporting STARTTLS. This ensures robustness in handling STARTTLS interactions.
2024-11-09 14:58:23 +01:00
50505e1339
Add test for Client cmd failure on textproto command
This commit introduces a new test case for the `Client`'s `cmd` method to ensure it fails correctly when the `textproto` command encounters a broken writer. It also adds a `failWriter` struct that simulates a write failure to facilitate this testing scenario.
2024-11-09 14:26:44 +01:00
af7964450a
Add test cases for invalid HELO/EHLO commands
Add tests to ensure HELO/EHLO commands fail with empty name, newline in name, and double execution. This improves validation and robustness of the SMTP client implementation.
2024-11-09 14:01:02 +01:00
cefaa0d4ee
Refactor SMTP test cases for improved clarity and coverage
Consolidate and organize SMTP test cases by removing obsolete tests and adding focused, detailed tests for CRAM-MD5 and new client behaviors. This ensures clearer test structure and better coverage of edge cases.
2024-11-09 13:44:14 +01:00
92ab51b13d
Add comprehensive tests for scramAuth error handling
Introduce new test cases to validate the error handling of the scramAuth methods. These tests cover scenarios such as invalid characters in usernames, empty inputs, and edge cases like broken rand.Reader.
2024-11-09 00:06:33 +01:00
c6d416f142
Fix typo in the tls-unique channel binding comment
Corrected "crypto/tl" to "crypto/tls" in the comment for better clarity and accuracy. This typo fix ensures that the code comments correctly reference the relevant Go package.
2024-11-08 23:05:31 +01:00
a1efa1a1ca
Remove redundant empty string check in SCRAM normalization
The existing check for an empty normalized string is unnecessary because the OpaqueString profile in precis already throws an error if an empty string is returned: https://cs.opensource.google/go/x/text/+/master:secure/precis/profiles.go;l=66
2024-11-08 22:44:10 +01:00
d6f256c29e
Fix typo in error message in normalizeString function
Corrected the spelling of "failed" in the error handling branch of the normalizeString function within smtp/auth_scram.go. This change addresses a minor typographical error to ensure the error message is clear and accurate.
2024-11-08 22:30:46 +01:00
d4c6cb506c
Add SCRAM authentication tests to smtp package
Added comprehensive unit tests for SCRAM-SHA-1, SCRAM-SHA-256, and their PLUS variants. Implemented a test server to simulate various SCRAM authentication scenarios and validate both success and failure cases.
2024-11-08 16:53:09 +01:00
c656226fd3
Add XOAuth2 authentication tests to SMTP package
Introduces two tests for XOAuth2 authentication in the SMTP package. The first test ensures successful authentication with valid credentials, while the second test verifies that authentication fails with incorrect settings.
2024-11-08 15:51:17 +01:00
0d906e21ac
Merge pull request #359 from wneessen/dependabot/github_actions/sonarsource/sonarqube-scan-action-3.1.0
Bump sonarsource/sonarqube-scan-action from 3.0.0 to 3.1.0
2024-11-08 15:16:19 +01:00
1af17f14e1
Add cleanup to close client connections in tests
This commit enhances the cleanup process in the SMTP tests by adding t.Cleanup to close client connections. Additionally, it rewrites the TestXOAuth2 function to include more detailed sub-tests, enhancing test granularity and readability.
2024-11-08 15:11:47 +01:00
dependabot[bot]
a3ef47ac93
Bump sonarsource/sonarqube-scan-action from 3.0.0 to 3.1.0
Bumps [sonarsource/sonarqube-scan-action](https://github.com/sonarsource/sonarqube-scan-action) from 3.0.0 to 3.1.0.
- [Release notes](https://github.com/sonarsource/sonarqube-scan-action/releases)
- [Commits](884b79409b...13990a6956)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-08 14:05:00 +00:00
7b8a24f34a
Merge branch 'main' into smtp-client-tests 2024-11-08 14:42:58 +01:00
edc3de5484
Merge pull request #358 from wneessen/dependabot/go_modules/golang.org/x/crypto-0.29.0
Bump golang.org/x/crypto from 0.28.0 to 0.29.0
2024-11-08 14:34:57 +01:00
dependabot[bot]
62ea3f56af
Bump golang.org/x/crypto from 0.28.0 to 0.29.0
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.28.0 to 0.29.0.
- [Commits](https://github.com/golang/crypto/compare/v0.28.0...v0.29.0)

---
updated-dependencies:
- dependency-name: golang.org/x/crypto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-08 13:31:55 +00:00
b03fbb4ae8
Add test server for SMTP authentication
Added a simple SMTP test server with basic features like PLAIN, LOGIN, and NOENC authentication. It can start, handle connections, and simulate authentication success or failure. Included support for TLS with a generated localhost certificate.
2024-11-07 22:42:23 +01:00
4221d48644
Update login authentication test cases in smtp_test.go
Renamed the test functions and improved the test structure for login authentication checks. Added subtests to provide clear descriptions and enhance error checking.
2024-11-07 21:31:24 +01:00
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