chapps.tests.test_policy.test_spf_policy module

Tests for CHAPPS SPF Enforcement policy module

class chapps.tests.test_policy.test_spf_policy.Test_PostfixSPFActions[source]

Bases: object

Tests for Postfix action strings corresponding to particular SPF results

The possible results are:

  • pass*

  • fail*

  • softfail

  • temperror*

  • permerror*

  • none/neutral (two which must be treated the same)

Starred items are ones for which RFC 7208 provides recommended SMTP result codes. For now, configuration will be able to override how the non-starred results are mapped onto actions taken for other classes of message. Eventually a response which implements greylisting (say, for softfails) will be provided, which could be applied also to none/neutral situations as well.

test_pass_produces_prepend(spf_actions, spf_reason)[source]
test_fail_produces_reject(spf_actions, spf_reason)[source]
test_temperror_produces_enhanced_code(spf_actions, spf_reason)[source]
test_permerror_produces_enhanced_code(spf_actions, spf_reason)[source]
test_none_produces_greylist(monkeypatch, spf_actions)[source]
test_neutral_produces_greylist(monkeypatch, spf_actions)[source]
test_softfail_produces_greylist(monkeypatch, spf_actions)[source]
class chapps.tests.test_policy.test_spf_policy.Test_SPFEnforcementPolicy[source]

Bases: object

Tests of the SPF module

test_passing_emails_get_prepend(caplog, monkeypatch, passing_spf_query, testing_policy_spf, allowable_inbound_ppr, populated_database_fixture)[source]
test_whitelisted_clients_get_dunno(caplog, monkeypatch, helo_ppr_factory, testing_policy_spf, populated_database_fixture)[source]
GIVEN

a HELO whitelist

WHEN

email arrives from a whitelisted server

THEN

forward the email with DUNNO (no prepends)

test_domain_spf_flag_false(caplog, monkeypatch, passing_spf_query, testing_policy_spf, allowable_inbound_ppr, populated_database_fixture_with_extras)[source]
GIVEN

the domain has the SPF-checking flag set to false

WHEN

policy approval is requested

THEN

PREPEND the SPF result header and forward the email

test_failing_emails_get_reject(caplog, monkeypatch, failing_spf_query, testing_policy_spf, allowable_inbound_ppr, populated_database_fixture)[source]
test_no_helo_passing_mf_gets_prepend(caplog, monkeypatch, no_helo_passing_mf, testing_policy_spf, allowable_inbound_ppr, populated_database_fixture)[source]
test_passing_helo_failing_mf_gets_reject(caplog, monkeypatch, passing_helo_failing_mf, testing_policy_spf, allowable_inbound_ppr, populated_database_fixture)[source]
test_all_spf_query_result_permutations(caplog, monkeypatch, clear_redis_grl, auto_spf_query, expected_result, testing_policy_spf, allowable_inbound_ppr, populated_database_fixture)[source]