51Degrees Pipeline for Python

tests.test_usage.UsageTests Class Reference

Detailed Description

The Tests.

Inheritance diagram for tests.test_usage.UsageTests:

[legend]

Collaboration diagram for tests.test_usage.UsageTests:

[legend]

Public Member Functions

 setUpClass (cls)
 setUp (self)
 tearDownClass (cls)
 startReceiver (cls)
 stopReceiver (cls)
 waitForUsageThreads (self)
 wait_for (self, condition, message)
 Wait for a condition, failing the test with the message if it is not met within 30 seconds.
 back_off_pipeline (self, **settings)
 A pipeline whose usage sharing element sends each entry on its own.
 process_unique (self, pipeline)
 Process a request whose evidence no other request has, and return its client IP.
 fail_sends (self, pipeline, count)
 Process requests one at a time, waiting for each to be sent, so each is a separate failed send.
 test_back_off_pauses_then_drains_queue (self)
 Ten failed sends pause sending for two seconds, the defaults.
 test_back_off_close_while_paused (self)
 Closing while paused returns at once rather than waiting for the pause to end, and sends nothing.
 test_back_off_delay_grows_to_maximum (self)
 Each failed send after a pause multiplies the delay, and the delay stops growing at the maximum.
 test_back_off_full_queue_drops_new_evidence (self)
 When the queue fills during a pause, new evidence is dropped and what was queued first is sent once sending resumes.
 test_full_queue_logs_without_a_message_per_entry (self)
 Entries discarded because the queue is full are logged, but not with a message for each entry discarded.
 test_failed_answer_logs_status_and_content (self)
 A send answered with anything other than 200 logs the status code and the content of the answer.
 test_failed_send_prints_nothing (self)
 A send that cannot be made is logged and does not print.
 test_message_holds_up_to_twice_the_package_size (self)
 A message holds the requested package size or more entries, up to twice the package size, so a queue that filled during a pause drains in fewer messages.
 test_close_sends_fewer_entries_than_the_package_size (self)
 Closing sends the entries still queued, even when there are fewer than the requested package size.
 test_close_stops_sending_after_the_cleanup_bound (self)
 Closing stops after the five seconds the specification allows, rather than waiting for a service that does not answer, and logs a warning counting the entries it discarded.
 test_minimum_entries_per_message_default (self)
 The default minimum entries per message is the 50 the specification gives, so no message is started before 50 entries are queued.
 test_back_off_invalid_settings (self)
 Settings the pause cannot work with are rejected.
 test_data_received (self)
 Check that data is received from the share usage element.
 test_data_correct (self)
 Check that the data received from the share usage element is correct.
 test_includes_header (self)
 Check that the data received from the share usage element contains the headers which were in the evidence.
 test_client_ip (self)
 Check that the data received from the share usage element includes the client IP from the evidence.
 test_two_events_first (self)
 Check that a single event is not sent when the requested package size is 2.
 test_two_events_second (self)
 Check that a single event is not sent when the requested package size is 2.
 test_ignore_headers (self)
 Check that the share usage element respects the headerBlacklist.
 test_queue_cleared (self)
 test_session_and_sequence (self)
 Check that session and sequence values are included.
 test_invalid_char (self)
 Check that invalid characters are escaped correctly.
 test_truncated_value (self)
 Check that long values are truncated correctly.
 test_send_more_than_once (self)
 Check that the queue of data is correctly reset, and used for the next set of requests.
 test_low_percentage (self)
 Check that small portion sharing is done correctly.
 test_includes_header (self)
 Check that XML characters are escaped correctly.
 test_default_shares_only_accepted_evidence (self)
 Check that with no options the element shares headers and the 51Degrees cookies and parameters, and leaves out other cookies, the Cookie header, and other query string and form parameters.
 test_never_shared_evidence (self)
 Check that the email address, the salt for hashed email identifiers, the query string and the path are not shared, though the rules for their prefixes would share them.
 test_share_all (self)
 Check that sharing all evidence shares what the other rules leave out, but not the evidence that is never shared.
 test_parameter_names_with_dots (self)
 Check that a query string parameter whose name contains a dot is matched by its whole name against the parameters to share.
 test_empty_query_whitelist (self)
 Check that an empty list of parameters to share shares only those starting 51D_, and that None shares every parameter.
 test_session_cookie (self)
 Check that with session tracking on the tracker reads the session cookie, which the element does not accept as evidence, and that neither it nor any other ordinary cookie is shared.
 test_session_cookie_without_session_tracking (self)
 Check that session tracking is off by default, and that naming the session cookie then has no effect.
 test_session_tracking (self)
 Check that with session tracking on, evidence already shared is shared again for a new session but not for a repeat in the same session, and that the session cookie is not shared.
 test_ordinary_cookie_with_header_blacklist (self)
 Check that an ordinary cookie is left out without an error when some headers are not to be shared.
 test_repeat_with_new_sequence_not_shared (self)
 Check that a request differing from one already shared only in its session id and sequence number is not shared again.
 test_evidence_without_a_prefix (self)
 Check that evidence whose key has no prefix is shared without an error.
 test_zzz_timeout (self)

Public Attributes

int requests = 0
list logs = []
 receiver = ReceiverThread(app)

Member Function Documentation

◆ back_off_pipeline()

tests.test_usage.UsageTests.back_off_pipeline ( self,
** settings )

A pipeline whose usage sharing element sends each entry on its own.

The element is closed when the test ends.

◆ fail_sends()

tests.test_usage.UsageTests.fail_sends ( self,
pipeline,
count )

Process requests one at a time, waiting for each to be sent, so each is a separate failed send.

◆ process_unique()

tests.test_usage.UsageTests.process_unique ( self,
pipeline )

Process a request whose evidence no other request has, and return its client IP.

◆ setUp()

tests.test_usage.UsageTests.setUp ( self)

◆ setUpClass()

tests.test_usage.UsageTests.setUpClass ( cls)

◆ startReceiver()

tests.test_usage.UsageTests.startReceiver ( cls)

◆ stopReceiver()

tests.test_usage.UsageTests.stopReceiver ( cls)

◆ tearDownClass()

tests.test_usage.UsageTests.tearDownClass ( cls)

◆ test_back_off_close_while_paused()

tests.test_usage.UsageTests.test_back_off_close_while_paused ( self)

Closing while paused returns at once rather than waiting for the pause to end, and sends nothing.

◆ test_back_off_delay_grows_to_maximum()

tests.test_usage.UsageTests.test_back_off_delay_grows_to_maximum ( self)

Each failed send after a pause multiplies the delay, and the delay stops growing at the maximum.

◆ test_back_off_full_queue_drops_new_evidence()

tests.test_usage.UsageTests.test_back_off_full_queue_drops_new_evidence ( self)

When the queue fills during a pause, new evidence is dropped and what was queued first is sent once sending resumes.

◆ test_back_off_invalid_settings()

tests.test_usage.UsageTests.test_back_off_invalid_settings ( self)

Settings the pause cannot work with are rejected.

◆ test_back_off_pauses_then_drains_queue()

tests.test_usage.UsageTests.test_back_off_pauses_then_drains_queue ( self)

Ten failed sends pause sending for two seconds, the defaults.

Nothing is sent during the pause, the evidence processed during it is queued, and all of it is sent once the pause ends and the service answers, with no more requests processed.

◆ test_client_ip()

tests.test_usage.UsageTests.test_client_ip ( self)

Check that the data received from the share usage element includes the client IP from the evidence.

◆ test_close_sends_fewer_entries_than_the_package_size()

tests.test_usage.UsageTests.test_close_sends_fewer_entries_than_the_package_size ( self)

Closing sends the entries still queued, even when there are fewer than the requested package size.

◆ test_close_stops_sending_after_the_cleanup_bound()

tests.test_usage.UsageTests.test_close_stops_sending_after_the_cleanup_bound ( self)

Closing stops after the five seconds the specification allows, rather than waiting for a service that does not answer, and logs a warning counting the entries it discarded.

◆ test_data_correct()

tests.test_usage.UsageTests.test_data_correct ( self)

Check that the data received from the share usage element is correct.

◆ test_data_received()

tests.test_usage.UsageTests.test_data_received ( self)

Check that data is received from the share usage element.

◆ test_default_shares_only_accepted_evidence()

tests.test_usage.UsageTests.test_default_shares_only_accepted_evidence ( self)

Check that with no options the element shares headers and the 51Degrees cookies and parameters, and leaves out other cookies, the Cookie header, and other query string and form parameters.

◆ test_empty_query_whitelist()

tests.test_usage.UsageTests.test_empty_query_whitelist ( self)

Check that an empty list of parameters to share shares only those starting 51D_, and that None shares every parameter.

◆ test_evidence_without_a_prefix()

tests.test_usage.UsageTests.test_evidence_without_a_prefix ( self)

Check that evidence whose key has no prefix is shared without an error.

◆ test_failed_answer_logs_status_and_content()

tests.test_usage.UsageTests.test_failed_answer_logs_status_and_content ( self)

A send answered with anything other than 200 logs the status code and the content of the answer.

◆ test_failed_send_prints_nothing()

tests.test_usage.UsageTests.test_failed_send_prints_nothing ( self)

A send that cannot be made is logged and does not print.

◆ test_full_queue_logs_without_a_message_per_entry()

tests.test_usage.UsageTests.test_full_queue_logs_without_a_message_per_entry ( self)

Entries discarded because the queue is full are logged, but not with a message for each entry discarded.

◆ test_ignore_headers()

tests.test_usage.UsageTests.test_ignore_headers ( self)

Check that the share usage element respects the headerBlacklist.

When header names are added to the list, values for them should not be included in the data shared.

◆ test_includes_header() [1/2]

tests.test_usage.UsageTests.test_includes_header ( self)

Check that XML characters are escaped correctly.

◆ test_includes_header() [2/2]

tests.test_usage.UsageTests.test_includes_header ( self)

Check that the data received from the share usage element contains the headers which were in the evidence.

◆ test_invalid_char()

tests.test_usage.UsageTests.test_invalid_char ( self)

Check that invalid characters are escaped correctly.

◆ test_low_percentage()

tests.test_usage.UsageTests.test_low_percentage ( self)

Check that small portion sharing is done correctly.

◆ test_message_holds_up_to_twice_the_package_size()

tests.test_usage.UsageTests.test_message_holds_up_to_twice_the_package_size ( self)

A message holds the requested package size or more entries, up to twice the package size, so a queue that filled during a pause drains in fewer messages.

◆ test_minimum_entries_per_message_default()

tests.test_usage.UsageTests.test_minimum_entries_per_message_default ( self)

The default minimum entries per message is the 50 the specification gives, so no message is started before 50 entries are queued.

◆ test_never_shared_evidence()

tests.test_usage.UsageTests.test_never_shared_evidence ( self)

Check that the email address, the salt for hashed email identifiers, the query string and the path are not shared, though the rules for their prefixes would share them.

◆ test_ordinary_cookie_with_header_blacklist()

tests.test_usage.UsageTests.test_ordinary_cookie_with_header_blacklist ( self)

Check that an ordinary cookie is left out without an error when some headers are not to be shared.

◆ test_parameter_names_with_dots()

tests.test_usage.UsageTests.test_parameter_names_with_dots ( self)

Check that a query string parameter whose name contains a dot is matched by its whole name against the parameters to share.

◆ test_queue_cleared()

tests.test_usage.UsageTests.test_queue_cleared ( self)

◆ test_repeat_with_new_sequence_not_shared()

tests.test_usage.UsageTests.test_repeat_with_new_sequence_not_shared ( self)

Check that a request differing from one already shared only in its session id and sequence number is not shared again.

◆ test_send_more_than_once()

tests.test_usage.UsageTests.test_send_more_than_once ( self)

Check that the queue of data is correctly reset, and used for the next set of requests.

◆ test_session_and_sequence()

tests.test_usage.UsageTests.test_session_and_sequence ( self)

Check that session and sequence values are included.

◆ test_session_cookie()

tests.test_usage.UsageTests.test_session_cookie ( self)

Check that with session tracking on the tracker reads the session cookie, which the element does not accept as evidence, and that neither it nor any other ordinary cookie is shared.

◆ test_session_cookie_without_session_tracking()

tests.test_usage.UsageTests.test_session_cookie_without_session_tracking ( self)

Check that session tracking is off by default, and that naming the session cookie then has no effect.

The cookie is not kept, and evidence already shared is not shared again for a new session.

◆ test_session_tracking()

tests.test_usage.UsageTests.test_session_tracking ( self)

Check that with session tracking on, evidence already shared is shared again for a new session but not for a repeat in the same session, and that the session cookie is not shared.

◆ test_share_all()

tests.test_usage.UsageTests.test_share_all ( self)

Check that sharing all evidence shares what the other rules leave out, but not the evidence that is never shared.

◆ test_truncated_value()

tests.test_usage.UsageTests.test_truncated_value ( self)

Check that long values are truncated correctly.

◆ test_two_events_first()

tests.test_usage.UsageTests.test_two_events_first ( self)

Check that a single event is not sent when the requested package size is 2.

◆ test_two_events_second()

tests.test_usage.UsageTests.test_two_events_second ( self)

Check that a single event is not sent when the requested package size is 2.

◆ test_zzz_timeout()

tests.test_usage.UsageTests.test_zzz_timeout ( self)

◆ wait_for()

tests.test_usage.UsageTests.wait_for ( self,
condition,
message )

Wait for a condition, failing the test with the message if it is not met within 30 seconds.

◆ waitForUsageThreads()

tests.test_usage.UsageTests.waitForUsageThreads ( self)

Member Data Documentation

◆ logs

tests.test_usage.UsageTests.logs = []

◆ receiver

tests.test_usage.UsageTests.receiver = ReceiverThread(app)

◆ requests

int tests.test_usage.UsageTests.requests = 0