chapps.tests.test_switchboard.test_switchboard module
tests for chapps.switchboard
- class chapps.tests.test_switchboard.test_switchboard.Test_OutboundQuotaHandler[source]
Bases:
object
Tests for the OQP switchboard
- async test_exception_handling(caplog, clear_redis, testing_policy, mock_reader_ok, mock_exc_raising_writer, populated_database_fixture)[source]
Verify that if an exception is raised, it will be handled by logging
- async test_handle_policy_request(clear_redis, testing_policy, mock_reader_ok, mock_writer, populated_database_fixture)[source]
Verify that when a permissible request is received, it gets an OK.
- async test_handle_policy_rejection(caplog, testing_policy, mock_reader_rej, mock_writer)[source]
Verify that over-quota senders’ requests are denied
- async test_default_policy(mock_reader_ok, mock_writer)[source]
Verify that when no policy is supplied, a default policy is instantiated
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]
- class chapps.tests.test_switchboard.test_switchboard.Test_GreylistingHandler[source]
Bases:
object
Tests of the Greylisting switchboard
- async test_handle_new_tuple(clear_redis_grl, testing_policy_grl, grl_reader_recognized, populated_database_fixture, 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_grl, grl_reader_too_fast, 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_grl, grl_reader_recognized, mock_writer)[source]
GIVEN an email delivery attempt WHEN the tuple is recognized THEN return DUNNO to allow other filters to block it; it will be accepted by default
- async test_handle_allowed_client(clear_redis_grl, testing_policy_grl, grl_reader_with_tally, mock_writer)[source]
GIVEN an email delivery attempt WHEN the client is recognized as a reliable sender THEN return DUNNO to allow other filters to block it; it will be accepted by default
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]
- class chapps.tests.test_switchboard.test_switchboard.Test_SenderDomainAuthHandler[source]
Bases:
object
Tests of the SenderDomainAuth handler
- async test_handle_authorized_user(clear_redis_sda, testing_policy_sda, mock_reader_sda_auth, mock_writer)[source]
GIVEN an email attempt from an authorized user WHEN asked for a response THEN return the acceptance message
- async test_handle_unauth_user(clear_redis_sda, testing_policy_sda, mock_reader_sda_unauth, mock_writer)[source]
GIVEN an email attempt from an UNauthorized user WHEN asked for a response THEN return the rejection message
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]
- class chapps.tests.test_switchboard.test_switchboard.Test_OutboundMultipolicyHandler[source]
Bases:
object
- async test_authed_user_gets_quota_check(monkeypatch, clear_redis, clear_redis_sda, testing_policy, testing_policy_sda, mock_reader_sda_auth, mock_writer, populated_database_fixture, database_fixture, finalizing_pcadapter, base_adapter_fixture)[source]
Verify that a successful SDA test cascades to a quota test
- async test_missing_user_key(clear_redis, clear_redis_sda, null_user_oq_policy, null_user_sda_policy, mock_reader_factory, mock_writer, populated_database_fixture)[source]
- GIVEN
that we require a user-key
- WHEN
a PPR is evaluated which has no value for the user-key
- THEN
the email is rejected and the
no_user_key_response
is returned
- async test_handle_null_sender(null_sender_policy_sda, testing_policy, mock_reader_sda_auth, mock_writer)[source]
- async test_reject_null_sender(null_sender_policy_sda, testing_policy, mock_reader_sda_auth, mock_writer)[source]
- async test_unauthed_user_gets_rejected(monkeypatch, clear_redis, clear_redis_sda, testing_policy, testing_policy_sda, mock_reader_sda_unauth, mock_writer, populated_database_fixture, database_fixture, finalizing_pcadapter, base_adapter_fixture)[source]
Verify that unsuccessful SDA tests prevent quota testing, and immediately reject the email
- pytestmark = [Mark(name='asyncio', args=(), kwargs={})]