chapps.tests.test_switchboard.test_spf_handler module
tests for chapps.switchboard
- class chapps.tests.test_switchboard.test_spf_handler.Test_SPFEnforcementHandler[source]
Bases:
object
This class contains tests of the SPF Enforcement Handler
- async test_handle_policy_request(caplog, monkeypatch, testing_policy_spf, auto_spf_query, expected_result, mock_reader_factory, mock_writer, populated_database_fixture, clear_redis_grl)[source]
- GIVEN
a particular result from the SPF checker
- WHEN
communicating with Postfix
- THEN
send the appropriate result
This test is parameterized to go through all possible responses
- async test_handle_request_on_unrecognized_domain(caplog, monkeypatch, testing_policy_spf, populated_database_fixture, mock_reader_factory, mock_writer)[source]
- GIVEN
a recipient within an unrecognized domain
- WHEN
policy evaluation takes place
- THEN
return DUNNO rather than enforcing the policy
- async test_handle_request_on_nonenforcing_domain(caplog, monkeypatch, testing_policy_spf, mock_reader_factory, mock_writer, populated_database_fixture_with_extras)[source]
- GIVEN
a recipient within an unrecognized domain
- WHEN
policy evaluation takes place
- THEN
return DUNNO rather than enforcing the policy
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]
- class chapps.tests.test_switchboard.test_spf_handler.Test_InboundMultipolicyHandler[source]
Bases:
object
This class contains tests of the inbound multipolicy handler
- async test_handle_policy_request_spf_only(caplog, monkeypatch, testing_policy_spf, testing_policy_grl, auto_spf_query, expected_result, mock_reader_factory, mock_writer, populated_database_fixture_with_extras, clear_redis_grl)[source]
GIVEN a particular result from the SPF checker WHEN communicating with Postfix THEN send the appropriate result This test is parameterized to go through all possible responses
- async test_handle_policy_request_spf_plus_greylist(caplog, monkeypatch, testing_policy_spf, testing_policy_grl, auto_spf_query, expected_result, mock_reader_factory, mock_writer, populated_database_fixture_with_extras, clear_redis_grl)[source]
GIVEN a particular result from the SPF checker WHEN communicating with Postfix THEN send the appropriate result based on SPF plus Greylisting This test is parameterized to go through all possible responses
- async test_pass_after_greylist(caplog, monkeypatch, testing_policy_spf, testing_policy_grl, grl_reader_recognized_factory, passing_spf_query, mock_writer, populated_database_fixture_with_extras, clear_redis_grl)[source]
- GIVEN
an email delivery attempt has occured and been greylisted
- WHEN
the tuple is seen again
- THEN
PREPEND the SPF header
- async test_softfail_after_greylist(caplog, monkeypatch, testing_policy_spf, testing_policy_grl, grl_reader_recognized_factory, softfail_spf_query, mock_writer, populated_database_fixture_with_extras, clear_redis_grl)[source]
- GIVEN
an email delivery attempt has occured and been greylisted
- WHEN
the tuple is seen again
- THEN
the policy handler should pass the email and prepend an SPF header
- async test_handle_request_on_unrecognized_domain(caplog, monkeypatch, testing_policy_spf, testing_policy_grl, populated_database_fixture_with_extras, mock_reader_factory, mock_writer)[source]
- GIVEN
a recipient within an unrecognized domain
- WHEN
policy evaluation takes place
- THEN
PREPEND the SPF header rather than enforcing the policy
Incoming mail destined for domains which are not configured within CHAPPS could either be rejected or forwarded. We choose the less-disruptive approach, forwarding emails which match no policy. But we do attach the SPF header.
- async test_handle_request_on_nonenforcing_domain(caplog, monkeypatch, testing_policy_spf, testing_policy_grl, mock_reader_factory, mock_writer, populated_database_fixture_with_extras)[source]
- GIVEN
a recipient within an unrecognized domain
- WHEN
policy evaluation takes place
- THEN
return the PREPEND rather than enforcing the policy
Whatever email flows in should have SPF headers attached to it, so that DMARC or other email utilities in the pipeline might be able to use them.
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]
- class chapps.tests.test_switchboard.test_spf_handler.Test_InboundMultipolicyHandler_GreylistingOnly[source]
Bases:
object
- async test_handle_new_tuple(clear_redis_grl, testing_policy_spf, testing_policy_grl, grl_reader_recognized_factory, populated_database_fixture_with_extras, mock_writer)[source]
- GIVEN
an email attempt from a new tuple
- WHEN
the client isn’t auto-allowed
- THEN
reject the email
- async test_handle_retry_too_fast(clear_redis_grl, testing_policy_spf, testing_policy_grl, grl_reader_too_fast_factory, mock_writer)[source]
- GIVEN
two back-to-back attempts with the same tuple
- WHEN
the two attempts are two close together
- THEN
reject the email
- async test_handle_recognized_tuple(clear_redis_grl, testing_policy_spf, testing_policy_grl, grl_reader_recognized_factory, mock_writer)[source]
- GIVEN
an email delivery attempt
- WHEN
the tuple is recognized
- THEN
PREPEND the SPF header to allow other filters to block it; it will be accepted by default
- async test_handle_allowed_client(clear_redis_grl, testing_policy_spf, testing_policy_grl, grl_reader_with_tally_factory, mock_writer)[source]
- GIVEN
an email delivery attempt
- WHEN
the client is recognized as a reliable sender
- THEN
PREPEND the SPF header to allow other filters to block it; it will be accepted by default
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]