示例#1
0
 def setUp(self):
     TestCase.setUp(self)
     TestHelper.setUp(self)
     self.threadpool = FakeThreadPool()
     self.transaction = self.mocker.mock()
     self.transactor = Transactor(self.threadpool, self.transaction)
     self.function = self.mocker.mock()
示例#2
0
    def setUp(self):
        GLSetting.set_devel_mode()
        GLSetting.logging = None
        GLSetting.scheduler_threadpool = FakeThreadPool()
        GLSetting.memory_copy.allow_unencrypted = True
        GLSetting.sessions = {}
        GLSetting.failed_login_attempts = 0
        GLSetting.working_path = './working_path'
        GLSetting.ramdisk_path = './working_path/ramdisk'

        GLSetting.eval_paths()
        GLSetting.remove_directories()
        GLSetting.create_directories()

        self.setUp_dummy()

        # This mocks out the MailNotification plugin so it does not actually
        # require to perform a connection to send an email.
        # XXX we probably want to create a proper mock of the ESMTPSenderFactory
        def mail_flush_mock(self, from_address, to_address, message_file,
                            event):
            return defer.succeed(None)

        notification.MailNotification.mail_flush = mail_flush_mock

        return db.create_tables(create_node=True)
示例#3
0
    def setUp(self):
        GLSettings.set_devel_mode()
        GLSettings.logging = None
        GLSettings.scheduler_threadpool = FakeThreadPool()
        GLSettings.sessions = {}
        GLSettings.failed_login_attempts = 0

        if os.path.isdir('/dev/shm'):
            GLSettings.working_path = '/dev/shm/globaleaks'
            GLSettings.ramdisk_path = '/dev/shm/globaleaks/ramdisk'
        else:
            GLSettings.working_path = './working_path'
            GLSettings.ramdisk_path = './working_path/ramdisk'

        GLSettings.eval_paths()
        GLSettings.remove_directories()
        GLSettings.create_directories()

        self.setUp_dummy()

        yield db.create_tables(self.create_node)

        for fixture in getattr(self, 'fixtures', []):
            yield import_fixture(fixture)

        yield import_memory_variables()

        # override of imported memory variables
        GLSettings.memory_copy.allow_unencrypted = True

        anomaly.Alarm.reset()
        event.EventTrackQueue.reset()
        statistics_sched.StatisticsSchedule.reset()

        self.internationalized_text = load_appdata()['node']['whistleblowing_button']
示例#4
0
def init_glsettings_for_unit_tests():
    GLSettings.testing = True
    GLSettings.set_devel_mode()
    GLSettings.logging = None
    GLSettings.scheduler_threadpool = FakeThreadPool()
    GLSettings.sessions.clear()
    GLSettings.failed_login_attempts = 0
    GLSettings.working_path = './working_path'
    GLSettings.ramdisk_path = os.path.join(GLSettings.working_path, 'ramdisk')

    GLSettings.eval_paths()
    GLSettings.remove_directories()
    GLSettings.create_directories()
示例#5
0
def init_glsettings_for_unit_tests():
    GLSettings.testing = True
    GLSettings.set_devel_mode()
    GLSettings.logging = None
    GLSettings.failed_login_attempts = 0
    GLSettings.working_path = './working_path'

    GLSettings.eval_paths()

    GLSettings.set_ramdisk_path()

    GLSettings.remove_directories()
    GLSettings.create_directories()

    GLSettings.orm_tp = FakeThreadPool()

    GLSessions.clear()
示例#6
0
def init_glsettings_for_unit_tests():
    Settings.testing = True
    Settings.set_devel_mode()
    Settings.logging = None
    Settings.failed_login_attempts = 0
    Settings.working_path = './working_path'

    Settings.eval_paths()

    Settings.set_ramdisk_path()

    Settings.remove_directories()
    Settings.create_directories()

    State.orm_tp = FakeThreadPool()

    State.tenant_cache[1].hostname = 'localhost'

    Sessions.clear()
示例#7
0
def init_glsettings_for_unit_tests():
    GLSettings.testing = True
    GLSettings.set_devel_mode()
    GLSettings.logging = None
    GLSettings.failed_login_attempts = 0
    GLSettings.working_path = './working_path'
    GLSettings.onionservice = 'kpvz7ki2v5agwt35.onion'

    GLSettings.eval_paths()

    GLSettings.set_ramdisk_path()

    GLSettings.remove_directories()
    GLSettings.create_directories()

    GLSettings.orm_tp = FakeThreadPool()

    GLSettings.memory_copy.hostname = 'localhost'

    GLSessions.clear()
示例#8
0
VALID_HASH1 = security.hash_password(VALID_PASSWORD1, VALID_SALT1)
VALID_HASH2 = security.hash_password(VALID_PASSWORD2, VALID_SALT2)
INVALID_PASSWORD = u'antani'

FIXTURES_PATH = os.path.join(TEST_DIR, 'fixtures')

with open(os.path.join(TEST_DIR, 'keys/valid_pgp_key1.txt')) as pgp_file:
    VALID_PGP_KEY1 = unicode(pgp_file.read())

with open(os.path.join(TEST_DIR, 'keys/valid_pgp_key2.txt')) as pgp_file:
    VALID_PGP_KEY2 = unicode(pgp_file.read())

with open(os.path.join(TEST_DIR, 'keys/expired_pgp_key.txt')) as pgp_file:
    EXPIRED_PGP_KEY = unicode(pgp_file.read())

transact.tp = FakeThreadPool()
authentication.reactor_override = task.Clock()
event.reactor_override = task.Clock()
token.reactor_override = task.Clock()
mailflush_sched.reactor_override = task.Clock()


class UTlog:
    @staticmethod
    def err(stuff):
        pass

    @staticmethod
    def debug(stuff):
        pass