backend.globaleaks.tests.helpers

Utilities and basic TestCases.

Module Contents

Classes

UTlog
FakeThreadPool A fake L{twisted.python.threadpool.ThreadPool}, running functions inside
TestGL
TestGLWithPopulatedDB
TestHandler
attr _handler:handler class to be tested
TestCollectionHandler
attr _handler:handler class to be tested
TestInstanceHandler
attr _handler:handler class to be tested
TestHandlerWithPopulatedDB
attr _handler:handler class to be tested
MockDict This class just create all the shit we need for emulate a Node
SimpleServerPP

Functions

GCE_mock_generate_key()
GCE_mock_generate_keypair()
init_state()
mock_users_keys(session)
get_dummy_step()
get_dummy_field()
get_dummy_fieldoption_list()
get_dummy_file(filename=None, content=None)
get_file_upload(self)
forge_request(uri=b’https://www.globaleaks.org/’, headers=None, body=’‘, client_addr=None, method=b’GET’) Creates a twisted.web.Request compliant request that is from an external
backend.globaleaks.tests.helpers.VALID_PASSWORD1 = ACollectionOfDiplomaticHistorySince_1966_ToThe_Pr esentDay#[source]
backend.globaleaks.tests.helpers.VALID_PASSWORD2[source]
backend.globaleaks.tests.helpers.VALID_SALT1[source]
backend.globaleaks.tests.helpers.VALID_SALT2[source]
backend.globaleaks.tests.helpers.VALID_HASH1[source]
backend.globaleaks.tests.helpers.VALID_HASH2[source]
backend.globaleaks.tests.helpers.VALID_BASE64_IMG = iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVQYV2NgYAAAAAMAAWgmWQ0AAAAASUVORK5CYII=[source]
backend.globaleaks.tests.helpers.INVALID_PASSWORD = antani[source]
backend.globaleaks.tests.helpers.KEY[source]
backend.globaleaks.tests.helpers.USER_KEY[source]
backend.globaleaks.tests.helpers.USER_PRV_KEY_ENC[source]
backend.globaleaks.tests.helpers.USER_REC_KEY_PLAIN[source]
backend.globaleaks.tests.helpers.USER_REC_KEY_PLAIN[source]
backend.globaleaks.tests.helpers.GCE_orig_generate_key[source]
backend.globaleaks.tests.helpers.GCE_orig_generate_keypair[source]
backend.globaleaks.tests.helpers.GCE_mock_generate_key()[source]
backend.globaleaks.tests.helpers.GCE_mock_generate_keypair()[source]
backend.globaleaks.tests.helpers.PGPKEYS[source]
backend.globaleaks.tests.helpers.DATA_DIR[source]
backend.globaleaks.tests.helpers.kp[source]
class backend.globaleaks.tests.helpers.UTlog[source]
static mlog(flag)[source]
backend.globaleaks.tests.helpers.err[source]
backend.globaleaks.tests.helpers.debug[source]
backend.globaleaks.tests.helpers.info[source]
backend.globaleaks.tests.helpers.min_ttl = 0[source]
class backend.globaleaks.tests.helpers.FakeThreadPool[source]

Bases: object

A fake L{twisted.python.threadpool.ThreadPool}, running functions inside the main thread instead for easing tests.

callInThreadWithCallback(self, onResult, func, *args, **kw)[source]
backend.globaleaks.tests.helpers.init_state()[source]
backend.globaleaks.tests.helpers.mock_users_keys(session)[source]
backend.globaleaks.tests.helpers.get_dummy_step()[source]
backend.globaleaks.tests.helpers.get_dummy_field()[source]
backend.globaleaks.tests.helpers.get_dummy_fieldoption_list()[source]
backend.globaleaks.tests.helpers.files_count = 0[source]
backend.globaleaks.tests.helpers.get_dummy_file(filename=None, content=None)[source]
backend.globaleaks.tests.helpers.get_file_upload(self)[source]
backend.globaleaks.tests.helpers.get_file_upload[source]
backend.globaleaks.tests.helpers.forge_request(uri=b'https://www.globaleaks.org/', headers=None, body='', client_addr=None, method=b'GET')[source]

Creates a twisted.web.Request compliant request that is from an external IP address.

class backend.globaleaks.tests.helpers.TestGL[source]

Bases: twisted.trial.unittest.TestCase

initialize_test_database_using_archived_db = True[source]
encryption_scenario = ENCRYPTED[source]
setUp(self)[source]
set_hostnames(self, session, i)[source]
setUp_dummy(self)[source]
get_dummy_user(self, role, username)[source]
get_dummy_receiver(self, username)[source]
fill_random_field_recursively(self, answers, field)[source]
fill_random_answers(self, session, questionnaire_id)[source]

return randomly populated questionnaire

getToken(self)[source]
getSolvedToken(self)[source]
get_dummy_submission(self, context_id)[source]

this may works until the content of the fields do not start to be validated. like numbers shall contain only number, and not URL. This validation would not be implemented in validate_jmessage but in structures.Fields

need to be enhanced generating appropriate data based on the fields.type

get_dummy_file(self, filename='', content=None)[source]
get_dummy_redirect(self, x='')[source]
emulate_file_upload(self, token, n)[source]

This emulates the file upload of an incomplete submission

pollute_events(self, number_of_times=10)[source]
get_rtips(self, session)[source]
get_rfiles(self, session, rtip_id)[source]
get_wbtips(self, session)[source]
get_wbfiles(self, session, wbtip_id)[source]
get_internalfiles_by_receipt(self, session, receipt)[source]
get_receiverfiles_by_receipt(self, session, receipt)[source]
db_test_model_count(self, session, model, n)[source]
test_model_count(self, session, model, n)[source]
get_model_count(self, session, model)[source]
class backend.globaleaks.tests.helpers.TestGLWithPopulatedDB[source]

Bases: backend.globaleaks.tests.helpers.TestGL

complex_field_population = False[source]
population_of_recipients = 2[source]
population_of_submissions = 2[source]
population_of_attachments = 2[source]
population_of_tenants = 3[source]
setUp(self)[source]
fill_data(self)[source]
add_whistleblower_identity_field_to_step(self, session, step_id)[source]
perform_submission_start(self)[source]
perform_submission_uploads(self, token)[source]
perform_submission_actions(self, token)[source]
perform_post_submission_actions(self)[source]
perform_full_submission_actions(self)[source]

Populates the DB with tips, comments, messages and files

perform_minimal_submission(self)[source]
force_wbtip_expiration(self, session)[source]
force_itip_expiration(self, session)[source]
set_itips_near_to_expire(self, session)[source]
set_contexts_timetolive(self, session, ttl)[source]
class backend.globaleaks.tests.helpers.TestHandler[source]

Bases: backend.globaleaks.tests.helpers.TestGLWithPopulatedDB

Attr _handler:handler class to be tested
_handler[source]
_test_desc[source]
setUp(self)[source]
request(self, body='', uri=b'https://www.globaleaks.org/', user_id=None, role=None, multilang=False, headers=None, client_addr=None, handler_cls=None, attached_file=None, kwargs={})[source]

Constructs a handler for preforming mock requests using the bag of params described below.

ss_serial_desc(self, safe_set, request_desc)[source]

Constructs a request_dec parser of a handler that uses a safe_set in its serialization

get_dummy_request(self)[source]
class backend.globaleaks.tests.helpers.TestCollectionHandler[source]

Bases: backend.globaleaks.tests.helpers.TestHandler

Attr _handler:handler class to be tested
test_get(self)[source]
test_post(self)[source]
class backend.globaleaks.tests.helpers.TestInstanceHandler[source]

Bases: backend.globaleaks.tests.helpers.TestHandler

Attr _handler:handler class to be tested
test_get(self)[source]
test_put(self)[source]
test_delete(self)[source]
class backend.globaleaks.tests.helpers.TestHandlerWithPopulatedDB[source]

Bases: backend.globaleaks.tests.helpers.TestHandler

Attr _handler:handler class to be tested
setUp(self)[source]
class backend.globaleaks.tests.helpers.MockDict[source]

This class just create all the shit we need for emulate a Node

class backend.globaleaks.tests.helpers.SimpleServerPP[source]

Bases: twisted.internet.protocol.ProcessProtocol

outReceived(self, data)[source]