Rspamd: update GTube patters in tests (#4191)

This commit is contained in:
Georg Lauterbach 2024-09-28 13:27:34 +02:00 committed by GitHub
parent 3bf32a6552
commit 1a938dfb15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 7 deletions

View File

@ -39,6 +39,7 @@ All notable changes to this project will be documented in this file. The format
- **Postfix:** - **Postfix:**
- Disable Microsoft reactions to outgoing mail ([#4120](https://github.com/docker-mailserver/docker-mailserver/pull/4120)) - Disable Microsoft reactions to outgoing mail ([#4120](https://github.com/docker-mailserver/docker-mailserver/pull/4120))
- bumped `jaq` version from 1.3.0 to 1.6.0 ([#4190](https://github.com/docker-mailserver/docker-mailserver/pull/4190)) - bumped `jaq` version from 1.3.0 to 1.6.0 ([#4190](https://github.com/docker-mailserver/docker-mailserver/pull/4190))
- updated Rspamd GTube settings and tests ([#4191](https://github.com/docker-mailserver/docker-mailserver/pull/4191))
### Fixes ### Fixes

View File

@ -5,7 +5,7 @@
# #
# We do not use `custom-commands.conf` because this a feature # We do not use `custom-commands.conf` because this a feature
# we are testing too. # we are testing too.
echo "enable_test_patterns = true;" >>/etc/rspamd/local.d/options.inc echo 'gtube_patterns = "all"' >>/etc/rspamd/local.d/options.inc
# We want Dovecot to be very detailed about what it is doing, # We want Dovecot to be very detailed about what it is doing,
# specifically for Sieve because we need to check whether the # specifically for Sieve because we need to check whether the

View File

@ -45,8 +45,10 @@ function setup_file() {
_wait_for_smtp_port_in_container _wait_for_smtp_port_in_container
# We will send 5 emails: # We will send 5 emails:
# 1. The first one should pass just fine # 1. The first ones should pass just fine
_send_email_with_msgid 'rspamd-test-email-pass' _send_email_with_msgid 'rspamd-test-email-pass'
_send_email_with_msgid 'rspamd-test-email-pass-gtube' \
--body 'AJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X'
# 2. The second one should be rejected (Rspamd-specific GTUBE pattern for rejection) # 2. The second one should be rejected (Rspamd-specific GTUBE pattern for rejection)
_send_spam --expect-rejection _send_spam --expect-rejection
# 3. The third one should be rejected due to a virus (ClamAV EICAR pattern) # 3. The third one should be rejected due to a virus (ClamAV EICAR pattern)
@ -54,7 +56,7 @@ function setup_file() {
_send_email_with_msgid 'rspamd-test-email-virus' --expect-rejection \ _send_email_with_msgid 'rspamd-test-email-virus' --expect-rejection \
--body 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' --body 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*'
# 4. The fourth one will receive an added header (Rspamd-specific GTUBE pattern for adding a spam header) # 4. The fourth one will receive an added header (Rspamd-specific GTUBE pattern for adding a spam header)
# ref: https://rspamd.com/doc/gtube_patterns.html # ref: https://rspamd.com/doc/other/gtube_patterns.html
_send_email_with_msgid 'rspamd-test-email-header' \ _send_email_with_msgid 'rspamd-test-email-header' \
--body "YJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X" --body "YJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
# 5. The fifth one will have its subject rewritten, but now spam header is applied. # 5. The fifth one will have its subject rewritten, but now spam header is applied.
@ -134,11 +136,12 @@ function teardown_file() { _default_teardown ; }
@test 'normal mail passes fine' { @test 'normal mail passes fine' {
_service_log_should_contain_string 'rspamd' 'F (no action)' _service_log_should_contain_string 'rspamd' 'F (no action)'
_service_log_should_contain_string 'rspamd' 'S (no action)'
_print_mail_log_for_msgid 'rspamd-test-email-pass' _print_mail_log_for_msgid 'rspamd-test-email-pass'
assert_output --partial "stored mail into mailbox 'INBOX'" assert_output --partial "stored mail into mailbox 'INBOX'"
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 2 _count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 3
} }
@test 'detects and rejects spam' { @test 'detects and rejects spam' {
@ -153,7 +156,7 @@ function teardown_file() { _default_teardown ; }
refute_output --partial "stored mail into mailbox 'INBOX'" refute_output --partial "stored mail into mailbox 'INBOX'"
assert_failure assert_failure
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 2 _count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 3
} }
@test 'detects and rejects virus' { @test 'detects and rejects virus' {
@ -168,7 +171,7 @@ function teardown_file() { _default_teardown ; }
refute_output --partial "stored mail into mailbox 'INBOX'" refute_output --partial "stored mail into mailbox 'INBOX'"
assert_failure assert_failure
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 2 _count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 3
} }
@test 'custom commands work correctly' { @test 'custom commands work correctly' {
@ -246,7 +249,7 @@ function teardown_file() { _default_teardown ; }
_print_mail_log_for_msgid 'rspamd-test-email-header' _print_mail_log_for_msgid 'rspamd-test-email-header'
assert_output --partial "fileinto action: stored mail into mailbox [SPECIAL-USE \\Junk]" assert_output --partial "fileinto action: stored mail into mailbox [SPECIAL-USE \\Junk]"
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 2 _count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/new/ 3
_count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/.Junk/new/ 1 _count_files_in_directory_in_container /var/mail/localhost.localdomain/user1/.Junk/new/ 1
} }