Esempio n. 1
0
    def setUp(self):
        self.test_reactor = task.Clock()

        jobs.job.reactor = self.test_reactor
        tempdict.TempDict.reactor = self.test_reactor

        self.state = State

        init_state()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', 'glbackend-%d.db' % DATABASE_VERSION),
                os.path.join(Settings.db_file_path)
            )
        else:
            yield db.create_db()
            yield db.init_db()

        yield self.set_hostnames(1)

        yield db.refresh_memory_variables()

        self.state.reset_hourly()

        Settings.submission_minimum_delay = 0

        self.internationalized_text = load_appdata()['node']['whistleblowing_button']
Esempio n. 2
0
    def setUp(self):
        self.test_reactor = task.Clock()
        jobs.base.test_reactor = self.test_reactor
        token.TokenList.reactor = self.test_reactor
        runner.test_reactor = self.test_reactor
        tempdict.test_reactor = self.test_reactor
        GLSessions.reactor = self.test_reactor

        init_glsettings_for_unit_tests()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', GLSettings.db_file_name),
                os.path.join(GLSettings.working_path, 'db',
                             GLSettings.db_file_name))
        else:
            yield db.init_db(use_single_lang=True)

        allow_unencrypted = self.encryption_scenario in ['PLAINTEXT', 'MIXED']

        yield update_node_setting('allow_unencrypted', allow_unencrypted)

        yield db.refresh_memory_variables()

        Alarm.reset()
        event.EventTrackQueue.clear()
        jobs.statistics_sched.StatisticsSchedule.reset()

        self.internationalized_text = load_appdata(
        )['node']['whistleblowing_button']
Esempio n. 3
0
    def setUp(self):
        yield TestGL.setUp(self)

        self.api = api.APIResourceWrapper()

        yield tw(db_update_enabled_languages, 1, ['en', 'ar', 'it'], 'en')
        yield refresh_memory_variables()
Esempio n. 4
0
    def setUp(self):
        init_glsettings_for_unit_tests()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', GLSettings.db_file_name),
                os.path.join(GLSettings.working_path, 'db',
                             GLSettings.db_file_name))
        else:
            yield db.init_db()

        yield db.refresh_memory_variables()

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

        # 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']
Esempio n. 5
0
 def initialization_callback(ret):
     log.info('Initialization of hidden-service %s completed.',
              ephs.hostname)
     if not hostname and not key:
         yield set_onion_service_info(ephs.hostname,
                                      ephs.private_key)
         yield refresh_memory_variables()
Esempio n. 6
0
    def setUp(self):
        self.test_reactor = task.Clock()
        jobs.base.test_reactor = self.test_reactor
        token.TokenList.reactor = self.test_reactor
        runner.test_reactor = self.test_reactor
        tempdict.test_reactor = self.test_reactor
        GLSettings.sessions.reactor = self.test_reactor

        init_glsettings_for_unit_tests()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', GLSettings.db_file_name),
                os.path.join(GLSettings.working_path, 'db', GLSettings.db_file_name)
            )
        else:
            yield db.init_db()

        yield db.refresh_memory_variables()

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

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

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

        self.internationalized_text = load_appdata()['node']['whistleblowing_button']
Esempio n. 7
0
    def setUp(self):
        self.test_reactor = task.Clock()

        jobs.base.test_reactor = self.test_reactor
        tempdict.test_reactor = self.test_reactor
        token.TokenList.reactor = self.test_reactor
        runner.test_reactor = self.test_reactor
        GLSessions.reactor = self.test_reactor

        init_glsettings_for_unit_tests()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', GLSettings.db_file_name),
                os.path.join(GLSettings.working_path, 'db', GLSettings.db_file_name)
            )
        else:
            yield db.init_db(use_single_lang=True)

        allow_unencrypted = self.encryption_scenario in ['PLAINTEXT', 'MIXED']

        yield update_node_setting('allow_unencrypted', allow_unencrypted)
        yield update_node_setting('submission_minimum_delay', 0)

        yield db.refresh_memory_variables()

        Alarm.reset()
        event.EventTrackQueue.clear()
        jobs.statistics_sched.StatisticsSchedule.reset()

        self.internationalized_text = load_appdata()['node']['whistleblowing_button']
Esempio n. 8
0
    def setUp(self):
        yield TestGL.setUp(self)

        from globaleaks.rest import api
        self.api = api.APIResourceWrapper()

        yield update_enabled_languages(1, ['en', 'ar', 'it'], 'en')
        yield refresh_memory_variables()
Esempio n. 9
0
    def setUp(self):
        yield TestGL.setUp(self)

        from globaleaks.rest import api
        self.api = api.APIResourceWrapper()

        yield tw(db_update_enabled_languages, 1, ['en', 'ar', 'it'], 'en')
        yield refresh_memory_variables()
Esempio n. 10
0
    def start_globaleaks(self):
        try:
            GLSettings.fix_file_permissions()
            GLSettings.drop_privileges()
            GLSettings.check_directories()

            # Check presence of an existing database and eventually perform its migration
            check = check_db_files()
            if check == -1:
                self._reactor.stop()
            elif check == 0:
                yield init_db()
            else:
                yield update_version()
                yield init_appdata()

            yield clean_untracked_files()

            yield refresh_memory_variables()

            if GLSettings.cmdline_options:
                yield apply_cmdline_options()

            self.start_asynchronous_jobs()

            log.msg("GLBackend is now running")
            for ip in GLSettings.bind_addresses:
                log.msg("Visit http://%s:%d to interact with me" %
                        (ip, GLSettings.bind_port))

            for host in GLSettings.accepted_hosts:
                if host not in GLSettings.bind_addresses:
                    log.msg("Visit http://%s:%d to interact with me" %
                            (host, GLSettings.bind_port))

            for other in GLSettings.configured_hosts:
                if other:
                    log.msg("Visit %s to interact with me" % other)

            log.msg(
                "Remind: GlobaLeaks is not accessible from other URLs, this is strictly enforced"
            )
            log.msg(
                "Check documentation in https://github.com/globaleaks/GlobaLeaks/wiki/ for special enhancement"
            )

        except Exception as excep:
            log.err(
                "ERROR: Cannot start GlobaLeaks; please manual check the error."
            )
            log.err("EXCEPTION: %s" % excep)
            self._reactor.stop()
Esempio n. 11
0
        def init_callback(ret):
            log.err('Initialization of onion-service %s completed.', ephs.hostname, tid=tid)
            if not hostname and not key:
                if tid in State.tenant_cache:
                    self.hs_map[ephs.hostname] = ephs
                    yield set_onion_service_info(tid, ephs.hostname, ephs.private_key)
                else:
                    yield ephs.remove_from_tor(self.tor_conn.protocol)

                tid_list = list(set([1, tid]))

                for x in tid_list:
                    Cache().invalidate(x)

                yield refresh_memory_variables(tid_list)
Esempio n. 12
0
        def init_callback(ret):
            log.info('Initialization of hidden-service %s completed.', ephs.hostname, tid=tid)
            if not hostname and not key:
                if tid in State.tenant_cache:
                    self.hs_map[ephs.hostname] = ephs
                    yield set_onion_service_info(tid, ephs.hostname, ephs.private_key)
                else:
                    yield ephs.remove_from_tor(self.tor_conn.protocol)

                tid_list = list(set([1, tid]))

                for x in tid_list:
                    Cache().invalidate(x)

                yield refresh_memory_variables(tid_list)

                del self.startup_semaphore[tid]
Esempio n. 13
0
    def start_globaleaks(self):
        try:
            GLSettings.fix_file_permissions()
            GLSettings.drop_privileges()
            GLSettings.check_directories()

            # Check presence of an existing database and eventually perform its migration
            check = check_db_files()
            if check == -1:
                 self._reactor.stop()
            elif check == 0:
                yield init_db()
            else:
                yield update_version()
                yield init_appdata()

            yield clean_untracked_files()

            yield refresh_memory_variables()

            if GLSettings.cmdline_options:
                yield apply_cmdline_options()

            self.start_asynchronous_jobs()

            log.msg("GLBackend is now running")
            for ip in GLSettings.bind_addresses:
                log.msg("Visit http://%s:%d to interact with me" % (ip, GLSettings.bind_port))

            for host in GLSettings.accepted_hosts:
                if host not in GLSettings.bind_addresses:
                    log.msg("Visit http://%s:%d to interact with me" % (host, GLSettings.bind_port))

            for other in GLSettings.configured_hosts:
                if other:
                    log.msg("Visit %s to interact with me" % other)

            log.msg("Remind: GlobaLeaks is not accessible from other URLs, this is strictly enforced")
            log.msg("Check documentation in https://github.com/globaleaks/GlobaLeaks/wiki/ for special enhancement")

        except Exception as excep:
            log.err("ERROR: Cannot start GlobaLeaks; please manual check the error.")
            log.err("EXCEPTION: %s" % excep)
            self._reactor.stop()
Esempio n. 14
0
    def setUp(self):
        self.test_reactor = task.Clock()

        jobs.job.reactor = self.test_reactor
        tempdict.reactor = self.test_reactor
        token.TokenList.reactor = self.test_reactor
        Sessions.reactor = self.test_reactor

        self.state = State

        init_state()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty',
                             'glbackend-%d.db' % DATABASE_VERSION),
                os.path.join(Settings.db_file_path))
        else:
            yield db.create_db()
            yield db.init_db()

        allow_unencrypted = self.encryption_scenario in ['PLAINTEXT', 'MIXED']

        yield tw(db_set_config_variable, 1, u'allow_unencrypted',
                 allow_unencrypted)

        yield self.set_hostnames(1)

        yield db.refresh_memory_variables()

        sup = ProcessSupervisor([], '127.0.0.1', 8082)
        self.state.process_supervisor = sup

        self.state.reset_hourly()

        Settings.submission_minimum_delay = 0

        self.internationalized_text = load_appdata(
        )['node']['whistleblowing_button']
Esempio n. 15
0
    def start_globaleaks(self):
        try:
            GLSettings.fix_file_permissions()
            GLSettings.drop_privileges()
            GLSettings.check_directories()

            if GLSettings.initialize_db:
                yield init_db()

            yield clean_untracked_files()

            yield refresh_memory_variables()

            self.start_asynchronous_jobs()

        except Exception as excep:
            log.err(
                "ERROR: Cannot start GlobaLeaks; please manually check the error."
            )
            log.err("EXCEPTION: %s" % excep)
            self._reactor.stop()
Esempio n. 16
0
    def start_globaleaks(self):
        try:
            GLSettings.fix_file_permissions()
            GLSettings.drop_privileges()
            GLSettings.check_directories()

            if GLSettings.initialize_db:
                yield init_db()
            else:
                yield update_version()
                yield init_appdata()

            yield clean_untracked_files()

            yield refresh_memory_variables()

            self.start_asynchronous_jobs()

        except Exception as excep:
            log.err("ERROR: Cannot start GlobaLeaks; please manual check the error.")
            log.err("EXCEPTION: %s" % excep)
            self._reactor.stop()
Esempio n. 17
0
    def setUp(self):
        self.test_reactor = task.Clock()

        jobs.job.reactor = self.test_reactor
        tempdict.reactor = self.test_reactor
        token.TokenList.reactor = self.test_reactor
        Sessions.reactor = self.test_reactor

        self.state = State

        init_state()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', 'glbackend-%d.db' % DATABASE_VERSION),
                os.path.join(Settings.db_file_path)
            )
        else:
            yield db.create_db()
            yield db.init_db()

        allow_unencrypted = self.encryption_scenario in ['PLAINTEXT', 'MIXED']

        yield tw(db_set_config_variable, 1, u'allow_unencrypted', allow_unencrypted)

        yield self.set_hostnames(1)

        yield db.refresh_memory_variables()

        sup = ProcessSupervisor([], '127.0.0.1', 8082)
        self.state.process_supervisor = sup

        self.state.reset_hourly()

        Settings.submission_minimum_delay = 0

        self.internationalized_text = load_appdata()['node']['whistleblowing_button']
Esempio n. 18
0
    def start_globaleaks(self):
        try:
            GLSettings.fix_file_permissions()
            GLSettings.drop_privileges()
            GLSettings.check_directories()

            GLSettings.orm_tp.start()
            self._reactor.addSystemEventTrigger('after', 'shutdown', GLSettings.orm_tp.stop)

            if GLSettings.initialize_db:
                yield init_db()

            yield clean_untracked_files()

            yield refresh_memory_variables()

            self.start_asynchronous_jobs()

        except Exception as excep:
            log.err("ERROR: Cannot start GlobaLeaks; please manually check the error.")
            log.err("EXCEPTION: %s" % excep)
            self._reactor.stop()
Esempio n. 19
0
    def setUp(self):
        test_config.skipCase(self)
        self.test_reactor = task.Clock()

        jobs.base.test_reactor = self.test_reactor
        tempdict.test_reactor = self.test_reactor
        token.TokenList.reactor = self.test_reactor
        GLSessions.reactor = self.test_reactor

        init_glsettings_for_unit_tests()

        self.setUp_dummy()

        if self.initialize_test_database_using_archived_db:
            shutil.copy(
                os.path.join(TEST_DIR, 'db', 'empty', GLSettings.db_file_name),
                os.path.join(GLSettings.working_path, 'db',
                             GLSettings.db_file_name))
        else:
            yield db.init_db(use_single_lang=True)

        allow_unencrypted = self.encryption_scenario in ['PLAINTEXT', 'MIXED']

        yield update_node_setting('allow_unencrypted', allow_unencrypted)

        yield db.refresh_memory_variables()

        sup = ProcessSupervisor([], '127.0.0.1', 8082)
        GLSettings.state.process_supervisor = sup

        Alarm.reset()
        event.EventTrackQueue.clear()
        GLSettings.reset_hourly()

        GLSettings.submission_minimum_delay = 0

        self.internationalized_text = load_appdata(
        )['node']['whistleblowing_button']
Esempio n. 20
0
 def setUp(self):
     yield TestGL.setUp(self)
     yield self.fill_data()
     yield db.refresh_memory_variables()
Esempio n. 21
0
 def setUp(self):
     self.api_tok, digest = generate_api_token()
     yield helpers.TestHandlerWithPopulatedDB.setUp(self)
     yield set_api_digest(digest)
     yield db.refresh_memory_variables()
Esempio n. 22
0
 def setUp(self):
     yield TestGL.setUp(self)
     yield self.fill_data()
     yield db.refresh_memory_variables()
Esempio n. 23
0
 def setUp(self):
     yield TenantTestEnv.setUp(self)
     t = yield tenant.create(get_dummy_tenant_desc())
     self.handler = self.request(t, role='admin')
     yield refresh_memory_variables([4])
Esempio n. 24
0
 def setUp(self):
     yield helpers.TestHandlerWithPopulatedDB.setUp(self)
     t = yield tenant.create(get_dummy_tenant_desc())
     self.handler = self.request(t, role='admin')
     yield refresh_memory_variables([4])
Esempio n. 25
0
 def setUp(self):
     yield helpers.TestHandlerWithPopulatedDB.setUp(self)
     t = yield tenant.create(get_dummy_tenant_desc())
     self.handler = self.request(t, role='admin')
     yield refresh_memory_variables([4])
Esempio n. 26
0
 def setUp(self):
     self.api_tok, digest = generateApiToken()
     yield helpers.TestHandlerWithPopulatedDB.setUp(self)
     yield tw(db_set_config_variable, 1, 'admin_api_token_digest', digest)
     yield db.refresh_memory_variables()
Esempio n. 27
0
 def setUp(self):
     self.api_tok, digest = generateApiToken()
     yield helpers.TestHandlerWithPopulatedDB.setUp(self)
     yield tw(db_set_config_variable, 1, 'admin_api_token_digest', digest)
     yield db.refresh_memory_variables()