<commit_before>load 'test_helper/common'

function setup() {
    run_setup_file_if_necessary
}

function teardown() {
    run_teardown_file_if_necessary
}

function setup_file() {
    docker run -d --name mail_privacy \
		-v "`pwd`/test/config":/tmp/docker-mailserver \
		-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
		-e ENABLE_CLAMAV=1 \
		-e ENABLE_SPAMASSASSIN=1 \
		-e SA_TAG=-5.0 \
		-e SA_TAG2=2.0 \
		-e SA_KILL=3.0 \
		-e SA_SPAM_SUBJECT="SPAM: " \
		-e VIRUSMAILS_DELETE_DELAY=7 \
		-e SASL_PASSWD="<PASSWORD> username:password" \
		-e ENABLE_MANAGESIEVE=1 \
		--cap-add=SYS_PTRACE \
		-e PERMIT_DOCKER=host \
		-e DMS_DEBUG=0 \
		-h mail.my-domain.com -t ${NAME}

    wait_for_amavis_port_in_container mail_privacy
}

function teardown_file() {
    docker rm -f mail_privacy
}

@test "first" {
  skip 'this test must come first to reliably identify when to run setup_file'
}

#
# LDAP
#

# postfix

@test "checking postfix: remove privacy details of the sender" {
  docker exec mail_privacy /bin/sh -c "openssl s_client -quiet -starttls smtp -connect 0.0.0.0:587 < /tmp/docker-mailserver-test/email-templates/send-privacy-email.txt"
  repeat_until_success_or_timeout 120 docker exec mail_privacy /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/new | wc -l) -eq 1 ]'
  docker logs mail_privacy<commit_msg>Tests fx: Also wait for smtp port<commit_after>load 'test_helper/common'

function setup() {
    run_setup_file_if_necessary
}

function teardown() {
    run_teardown_file_if_necessary
}

function setup_file() {
    docker run -d --name mail_privacy \
		-v "`pwd`/test/config":/tmp/docker-mailserver \
		-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \
		-e ENABLE_CLAMAV=1 \
		-e ENABLE_SPAMASSASSIN=1 \
		-e SA_TAG=-5.0 \
		-e SA_TAG2=2.0 \
		-e SA_KILL=3.0 \
		-e SA_SPAM_SUBJECT="SPAM: " \
		-e VIRUSMAILS_DELETE_DELAY=7 \
		-e SASL_PASSWD="<PASSWORD> username:password" \
		-e ENABLE_MANAGESIEVE=1 \
		--cap-add=SYS_PTRACE \
		-e PERMIT_DOCKER=host \
		-e DMS_DEBUG=0 \
		-h mail.my-domain.com -t ${NAME}

    wait_for_amavis_port_in_container mail_privacy
    wait_for_smtp_port_in_container mail_privacy
}

function teardown_file() {
    docker rm -f mail_privacy
}

@test "first" {
  skip 'this test must come first to reliably identify when to run setup_file'
}

#
# LDAP
#

# postfix

@test "checking postfix: remove privacy details of the sender" {
  docker exec mail_privacy /bin/sh -c "openssl s_client -quiet -starttls smtp -connect 0.0.0.0:587 < /tmp/docker-mailserver-test/email-templates/send-privacy-email.txt"
  repeat_until_success_or_timeout 120 docker exec mail_privacy /bin/sh -c '[ $(ls /var/mail/localhost.localdomain/user1/new | wc -l) -eq 1 ]'
  docker logs mail_privacy
{'fraction_non_alphanumeric': 0.1241354204586822, 'fraction_numerical': 0.017473607571896616, 'mean_word_length': 3.5123152709359604, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4190423', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1111, 'n_words': 227}