Exemplo n.º 1
0
    def setUp(self):
        helpers.patch(self, [
            'clusterfuzz._internal.base.utils.is_chromium',
            'clusterfuzz._internal.bot.tasks.impact_task.get_impacts_from_url',
            'clusterfuzz._internal.bot.tasks.impact_task.get_impacts_on_prod_builds',
            'clusterfuzz._internal.bot.tasks.setup.setup_testcase',
            'clusterfuzz._internal.build_management.build_manager.is_custom_binary',
            'clusterfuzz._internal.build_management.build_manager.has_production_builds',
            'clusterfuzz._internal.bot.testcase_manager.get_command_line_for_application',
            'clusterfuzz._internal.base.tasks.add_task',
        ])
        impacts = impact_task.Impacts(
            stable=impact_task.Impact('stable', False, 'trace-stable'),
            beta=impact_task.Impact('beta', True, 'trace-beta'),
            extended_stable=impact_task.Impact('extended stable', False,
                                               'trace-extended-stable'),
            head=impact_task.Impact('head', False, 'trace-head'))
        self.mock.is_chromium.return_value = True
        self.mock.is_custom_binary.return_value = False
        self.mock.has_production_builds.return_value = True
        self.mock.get_impacts_from_url.return_value = impacts
        self.mock.setup_testcase.return_value = (['a'], None, 'path')
        self.mock.get_impacts_on_prod_builds.return_value = impacts

        self.testcase = data_types.Testcase()
        self.testcase.is_impact_set_flag = False
        self.testcase.status = 'Processed'
        self.testcase.crash_stacktrace = 'trace'
        self.testcase.regression = '123:456'
        self.testcase.job_type = 'job2'
        self.testcase.project_name = 'chromium'
        self.testcase.put()
Exemplo n.º 2
0
 def setUp(self):
   test_helpers.patch(self, ['libs.handler.get_email_and_access_token'])
   flaskapp = flask.Flask('testflask')
   flaskapp.add_url_rule('/', view_func=OAuthHandler.as_view('/'))
   self.app = webtest.TestApp(flaskapp)
   test_helpers.patch_environ(self)
   os.environ['AUTH_DOMAIN'] = 'localhost'
Exemplo n.º 3
0
    def setUp(self):
        test_helpers.patch(self, [
            'libs.access._is_domain_allowed',
            'libs.auth.get_current_user',
            'clusterfuzz._internal.config.db_config.get',
            'libs.issue_management.issue_tracker.IssueTracker.get_original_issue',
            'libs.issue_management.issue_tracker_utils.'
            'get_issue_tracker_for_testcase',
            'libs.issue_management.monorail.issue_tracker_manager.'
            'IssueTrackerManager',
        ])
        self.itm = issue_tracker_manager.IssueTrackerManager('test')
        self.itm.project_name = 'test-project'
        self.mock.get_issue_tracker_for_testcase.return_value = (
            monorail.IssueTracker(self.itm))
        self.get_issue = self.itm.get_issue

        self.email = '*****@*****.**'
        self.mock.get_current_user.return_value = auth.User(self.email)

        self.bug = issue.Issue()
        self.bug.id = 1234
        self.bug.itm = self.itm
        self.original_bug = issue.Issue()
        self.original_bug.id = 5678
        self.original_bug.itm = self.itm

        self.testcase = data_types.Testcase()

        self.mock.get.return_value = (data_types.Config(
            relax_testcase_restrictions=True))
        self.mock._is_domain_allowed.return_value = False
Exemplo n.º 4
0
 def setUp(self):
   helpers.patch(self, [
       'clusterfuzz._internal.metrics.crash_stats.get_last_successful_hour',
       'clusterfuzz._internal.metrics.crash_stats.get',
       'clusterfuzz._internal.base.utils.utcnow',
   ])
   self.mock.utcnow.return_value = test_utils.CURRENT_TIME
    def setUp(self):
        self.tmp_dir = tempfile.mkdtemp()
        os.environ['BOT_TMPDIR'] = os.path.join(self.tmp_dir, 'bot_tmpdir')

        test_helpers.patch(self, [
            'clusterfuzz._internal.datastore.data_handler.'
            'get_data_bundle_bucket_name',
            'clusterfuzz._internal.system.environment.'
            'set_environment_parameters_from_file',
        ])

        test_helpers.patch_environ(self)

        # Our tests write data/logs into subdirs of ROOT_DIR. Pivot the ROOT_DIR to
        # a temporary one.
        new_root = _create_test_root()

        os.environ['ROOT_DIR'] = new_root
        self.saved_cwd = os.getcwd()
        os.chdir(new_root)

        environment.set_bot_environment()

        fuzz_inputs = os.environ['FUZZ_INPUTS']
        shell.remove_directory(fuzz_inputs, recreate=True)

        worker_fuzz_inputs = file_host.rebase_to_worker_root(fuzz_inputs)
        shell.remove_directory(worker_fuzz_inputs, recreate=True)

        environment.set_value('GSUTIL_PATH', os.path.dirname(_which('gsutil')))

        test_utils.setup_pubsub('test-clusterfuzz')
        test_utils.create_pubsub_topic(pubsub.PubSubClient(),
                                       'test-clusterfuzz',
                                       'jobs-project-linux')
    def setUp(self):
        test_helpers.patch(self, [
            'clusterfuzz._internal.base.external_users._allowed_entities_for_user',
            'clusterfuzz._internal.base.external_users._get_permissions_query_for_user',
            'libs.access.get_user_job_type',
            'libs.access.has_access',
            'libs.helpers.get_user_email',
        ])
        flaskapp = flask.Flask('testflask')
        flaskapp.add_url_rule('/',
                              view_func=testcase_list.JsonHandler.as_view('/'))
        self.app = webtest.TestApp(flaskapp)

        self.testcases = []
        for i in range(10):
            t = data_types.Testcase()
            t.crash_type = ''
            t.crash_state = ''
            t.status = 'Processed'
            t.security_flag = True
            t.is_a_duplicate_flag = False
            t.one_time_crasher_flag = False
            t.open = True
            t.is_leader = True
            t.timestamp = datetime.datetime.fromtimestamp(100 - i)
            t.put()
            self.testcases.append(t)
Exemplo n.º 7
0
    def call_f(self, *args, **kwargs):
        test_helpers.patch(self,
                           ['clusterfuzz._internal.metrics.logs.log_error'])

        result = f(self, *args, **kwargs)
        self.assertEqual(0, self.mock.log_error.call_count)
        return result
    def test_syzkaller_kasan_android_with_env(self):
        """Test syzkaller kasan."""
        environment.set_value('OS_OVERRIDE', 'ANDROID_KERNEL')
        environment.set_bot_environment()
        self._real_read_data_from_file = utils.read_data_from_file
        test_helpers.patch(self, [
            'clusterfuzz._internal.platforms.android.fetch_artifact.get',
            'clusterfuzz._internal.platforms.android.kernel_utils.get_kernel_hash_and_build_id',
            'clusterfuzz._internal.platforms.android.kernel_utils.get_kernel_name',
            'clusterfuzz._internal.platforms.android.settings.get_product_brand',
            'clusterfuzz._internal.google_cloud_utils.storage.get_file_from_cache_if_exists',
            'clusterfuzz._internal.google_cloud_utils.storage.store_file_in_cache',
            'clusterfuzz._internal.base.utils.write_data_to_file',
            'clusterfuzz._internal.base.utils.read_data_from_file'
        ])
        self.mock.get.side_effect = _mock_fetch_artifact_get
        self.mock.get_kernel_hash_and_build_id.return_value = '40e9b2ff3a2', '12345'
        self.mock.get_kernel_name.return_value = 'device_kernel'
        self.mock.get_product_brand.return_value = 'google'
        self.mock.get_file_from_cache_if_exists.return_value = False
        self.mock.store_file_in_cache.return_value = None
        self.mock.write_data_to_file = None
        self.mock.read_data_from_file.side_effect = self._mock_read_data_from_file

        data = self._read_test_data('kasan_syzkaller_android.txt')
        expected_stack = self._read_test_data(
            'kasan_syzkaller_android_linkified.txt')
        actual_state = stack_analyzer.get_crash_data(data)
        self.assertEqual(actual_state.crash_stacktrace, expected_stack)
Exemplo n.º 9
0
    def setUp(self):
        test_helpers.patch(self, [
            'clusterfuzz._internal.build_management.build_manager.set_environment_vars',
            'clusterfuzz._internal.bot.untrusted_runner.host.stub',
        ])

        test_helpers.patch_environ(self)
Exemplo n.º 10
0
    def setUp(self):
        test_helpers.patch(self, [
            'clusterfuzz._internal.datastore.data_handler.get_issue_description',
            'clusterfuzz._internal.datastore.data_handler.get_issue_summary',
            'clusterfuzz._internal.datastore.data_handler.get_stacktrace',
            'clusterfuzz._internal.datastore.data_handler.update_group_bug',
            'libs.helpers.get_issue_tracker_for_testcase',
            'libs.auth.get_current_user',
            'handlers.testcase_detail.show.get_testcase_detail',
            'libs.access.get_access',
            'libs.issue_management.issue_tracker_policy.get',
            'libs.issue_management.issue_filer.get_memory_tool_labels',
        ])
        self.mock.get_access.return_value = access.UserAccess.Allowed
        self.mock.get_testcase_detail.return_value = {'testcase': 'yes'}
        self.mock.get_current_user().email = '*****@*****.**'
        self.mock.get.return_value = CHROMIUM_POLICY

        flaskapp = flask.Flask('testflask')
        flaskapp.add_url_rule('/', view_func=update_issue.Handler.as_view('/'))
        self.app = webtest.TestApp(flaskapp)

        self.testcase = data_types.Testcase()
        self.testcase.bug_information = ''
        self.testcase.crash_state = 'fake_crash_state'
        self.testcase.put()
    def setUp(self):
        BaseTest.setUp(self)
        self.fuchsia_corpus_dir = os.path.join(self.corpus_bucket, 'fuchsia')
        shutil.copytree(os.path.join(TEST_DIR, 'fuchsia'),
                        self.fuchsia_corpus_dir)
        self.temp_dir = tempfile.mkdtemp()
        builds_dir = os.path.join(self.temp_dir, 'builds')
        os.mkdir(builds_dir)
        urls_dir = os.path.join(self.temp_dir, 'urls')
        os.mkdir(urls_dir)

        environment.set_value('BUILDS_DIR', builds_dir)
        environment.set_value('BUILD_URLS_DIR', urls_dir)
        environment.set_value('QUEUE_OVERRIDE', 'FUCHSIA')
        environment.set_value('OS_OVERRIDE', 'FUCHSIA')

        env_string = ('RELEASE_BUILD_BUCKET_PATH = '
                      'gs://clusterfuchsia-builds-test/libfuzzer/'
                      'fuchsia-([0-9]+).zip')
        commands.update_environment_for_job(env_string)

        data_types.Job(name='libfuzzer_asan_fuchsia',
                       platform='FUCHSIA',
                       environment_string=env_string).put()
        data_types.FuzzTarget(binary='example-fuzzers/crash_fuzzer',
                              engine='libFuzzer',
                              project='fuchsia').put()

        environment.set_value('UNPACK_ALL_FUZZ_TARGETS_AND_FILES', True)
        helpers.patch(self, [
            'clusterfuzz._internal.system.shell.clear_temp_directory',
        ])
Exemplo n.º 12
0
 def setUp(self):
     helpers.patch(self, [
         'clusterfuzz._internal.build_management.revisions.get_start_and_end_revision',
         'clusterfuzz._internal.build_management.revisions.get_component_range_list',
         'clusterfuzz._internal.bot.testcase_manager.get_command_line_for_application',
         'clusterfuzz._internal.system.environment.is_android',
     ])
Exemplo n.º 13
0
    def setUp(self):
        helpers.patch(self, [
            'clusterfuzz._internal.build_management.build_manager.setup_production_build',
            'clusterfuzz._internal.system.environment.get_value',
            'clusterfuzz._internal.bot.testcase_manager.get_command_line_for_application',
            'clusterfuzz._internal.bot.testcase_manager.test_for_crash_with_retries',
        ])
        self.env = {
            'APP_PATH': 'app',
            'TEST_TIMEOUT': '9',
            'JOB_NAME': 'linux_asan_chrome',
            'TOOL_NAME': 'ASAN'
        }
        self.result = mock.Mock()
        self.result.is_crash = mock.Mock()
        self.result.get_stacktrace = mock.Mock()

        self.mock.setup_production_build.return_value = (
            build_manager.ProductionBuild('/base', '52', None, 'stable'))
        self.mock.get_value.side_effect = self.env.get
        self.mock.test_for_crash_with_retries.return_value = self.result
        self.result.is_crash.return_value = True
        self.result.get_stacktrace.return_value = 'crashed-trace'

        self.testcase = data_types.Testcase()
Exemplo n.º 14
0
    def setUp(self):
        helpers.patch(self, [
            'clusterfuzz._internal.bot.tasks.impact_task.get_impact_on_build',
            'clusterfuzz._internal.bot.tasks.impact_task.get_impacts_from_url',
            'clusterfuzz._internal.bot.testcase_manager.get_command_line_for_application',
            'clusterfuzz._internal.chrome.build_info.get_build_to_revision_mappings',
        ])
        self.mock.get_build_to_revision_mappings.return_value = {
            'stable': {
                'revision': '398287',
                'version': '74.0.1345.34'
            },
            'beta': {
                'revision': '399171',
                'version': '75.0.1353.43'
            },
            'canary': {
                'revision': '400000',
                'version': '76.0.1234.43'
            }
        }
        self.impacts = impact_task.Impacts(
            stable=impact_task.Impact('s', False),
            beta=impact_task.Impact('b', True),
            extended_stable=impact_task.Impact('es', False),
            head=impact_task.Impact('76.0.1234.43', False))

        self.testcase = data_types.Testcase()
        self.testcase.job_type = 'job'
        self.testcase.impact_extended_stable_version = 'es-ver'
        self.testcase.impact_stable_version = 's-ver'
        self.testcase.impact_beta_version = 'b-ver'
        self.testcase.regression = '123:456'
    def setUp(self):
        test_helpers.patch_environ(self)
        flaskapp = flask.Flask('testflask')
        flaskapp.add_url_rule(
            '/apply-ccs',
            view_func=oss_fuzz_apply_ccs.Handler.as_view('/apply-ccs'))
        self.app = webtest.TestApp(flaskapp)

        data_types.ExternalUserPermission(
            email='*****@*****.**',
            entity_name='job',
            entity_kind=data_types.PermissionEntityKind.JOB,
            is_prefix=False,
            auto_cc=data_types.AutoCCType.ALL).put()

        data_types.ExternalUserPermission(
            email='*****@*****.**',
            entity_name='job',
            entity_kind=data_types.PermissionEntityKind.JOB,
            is_prefix=False,
            auto_cc=data_types.AutoCCType.ALL).put()

        test_helpers.patch(self, [
            'clusterfuzz._internal.base.utils.utcnow',
            'handlers.base_handler.Handler.is_cron',
            'libs.issue_management.issue_tracker.IssueTracker.get_original_issue',
            'libs.issue_management.issue_tracker_policy.get',
            'libs.issue_management.issue_tracker_utils.'
            'get_issue_tracker_for_testcase',
        ])

        self.itm = IssueTrackerManager('oss-fuzz')
        self.mock.get_issue_tracker_for_testcase.return_value = (
            monorail.IssueTracker(self.itm))
        self.mock.utcnow.return_value = datetime.datetime(2016, 1, 1)
        self.mock.get.return_value = OSS_FUZZ_POLICY
        self.mock.get_original_issue.side_effect = get_original_issue

        self.job = data_types.Job(name='job', environment_string='')
        self.job.put()

        data_types.Testcase(open=True,
                            status='Processed',
                            bug_information='1337',
                            job_type='job').put()

        data_types.Testcase(open=True,
                            status='Processed',
                            bug_information='1338',
                            job_type='job').put()

        data_types.Testcase(open=True,
                            status='Processed',
                            bug_information='1339',
                            job_type='job').put()

        data_types.Testcase(open=True,
                            status='Processed',
                            bug_information='1340',
                            job_type='job').put()
Exemplo n.º 16
0
 def setUp(self):
     """Set up method for strategy pool generator tests with patch."""
     test_helpers.patch_environ(self)
     test_helpers.patch(self, [
         'clusterfuzz._internal.bot.fuzzers.engine_common.decide_with_probability'
     ])
     self.mock.decide_with_probability.return_value = True
Exemplo n.º 17
0
    def setUp(self):
        """Setup for upload tests to cloud storage test."""
        test_helpers.patch_environ(self)
        test_helpers.patch(self, [
            'clusterfuzz._internal.base.utils.utcnow',
            'clusterfuzz._internal.config.local_config.ProjectConfig.get',
            'clusterfuzz._internal.datastore.locks.acquire_lock',
            'clusterfuzz._internal.datastore.locks.release_lock',
            'clusterfuzz._internal.google_cloud_utils.gsutil.GSUtilRunner',
            'clusterfuzz._internal.google_cloud_utils.storage.list_blobs',
            'clusterfuzz._internal.google_cloud_utils.storage.read_data',
            'clusterfuzz._internal.google_cloud_utils.storage.write_data',
        ])

        test_utils.set_up_pyfakefs(self)

        self.mock.write_data.return_value = True
        self.mock.utcnow.side_effect = lambda: datetime.datetime(
            2018, 11, 1, 0, 0)

        FakeGSUtilRunner.rsync_calls = []
        self.mock.GSUtilRunner.side_effect = FakeGSUtilRunner
        self.mock.get.side_effect = _mock_config_get

        os.environ['BOT_NAME'] = 'test-bot'
        os.environ['BOT_TMPDIR'] = '/tmp'
        os.environ['FAIL_RETRIES'] = '1'
Exemplo n.º 18
0
    def setUp(self):
        helpers.patch_environ(self)
        helpers.patch(self, [
            'clusterfuzz._internal.base.persistent_cache.get_value',
            'clusterfuzz._internal.base.persistent_cache.set_value',
            'clusterfuzz._internal.base.utils.utcnow',
            'time.sleep',
        ])

        self.mock.get_value.return_value = None
        self.mock.sleep.return_value = None
        data_types.Job(name='job').put()

        client = pubsub.PubSubClient()
        topic = pubsub.topic_name('test-clusterfuzz', 'jobs-linux')
        client.create_topic(topic)
        client.create_subscription(
            pubsub.subscription_name('test-clusterfuzz', 'jobs-linux'), topic)

        topic = pubsub.topic_name('test-clusterfuzz', 'high-end-jobs-linux')
        client.create_topic(topic)
        client.create_subscription(
            pubsub.subscription_name('test-clusterfuzz',
                                     'high-end-jobs-linux'), topic)

        self.mock.utcnow.return_value = test_utils.CURRENT_TIME.replace(
            microsecond=0)
Exemplo n.º 19
0
    def setUp(self):
        os.environ['BUILD_DIR'] = DATA_DIRECTORY
        os.environ['FUZZ_INPUTS_DISK'] = TEMP_DIRECTORY
        os.environ['FAIL_RETRIES'] = '1'

        test_helpers.patch_environ(self)
        dont_use_strategies(self)

        # Make it easy to assert if things were logged.
        test_helpers.patch(self, [
            'clusterfuzz._internal.metrics.logs.log', 'os.getpid',
            'clusterfuzz._internal.bot.fuzzers.afl.launcher.rand_cmplog_level',
            'clusterfuzz._internal.bot.fuzzers.afl.launcher.rand_schedule'
        ])
        self.mock.rand_cmplog_level.return_value = '2'
        self.mock.rand_schedule.return_value = 'fast'
        self.logged_messages = []

        def mocked_log(message, **kwargs):  # pylint: disable=unused-argument
            self.logged_messages.append(message)

        self.mock.log.side_effect = mocked_log
        self.mock.getpid.return_value = 1337

        clear_temp_dir()
        create_temp_dir()
Exemplo n.º 20
0
  def setUp(self):
    """Setup for upload testcase output test."""
    test_helpers.patch_environ(self)
    test_utils.set_up_pyfakefs(self)
    self.testcase_path = '/test/fuzzer/testcase'
    self.fs.create_file(self.testcase_path, contents='')

    environment.set_value('FUZZ_LOGS_BUCKET', 'fake-gcs-logs')
    environment.set_value('FUZZER_NAME', 'fuzzer')
    environment.set_value('JOB_NAME', 'job')
    environment.set_value('APP_REVISION', '123')

    # To be used for generation of date and time when uploading a log.
    fake_utcnow = datetime.datetime(2017, 5, 15, 16, 10, 28, 374119)

    # Original utcfromtimestamp needs to be preserved, as test_helpres does not
    # allow to patch only datetime.datetime.utcnow.
    orig_utcfromtimestamp = datetime.datetime.utcfromtimestamp

    test_helpers.patch(self, [
        'clusterfuzz._internal.build_management.revisions.get_component_range_list',
        'clusterfuzz._internal.google_cloud_utils.storage.write_data',
        'datetime.datetime',
    ])

    self.mock.datetime.utcnow.return_value = fake_utcnow
    self.mock.datetime.utcfromtimestamp.side_effect = orig_utcfromtimestamp
    self.mock.get_component_range_list.return_value = [{
        'component': 'Component',
        'link_text': 'REVISION',
    }, {
        'component': 'Component2',
        'link_text': 'REVISION2',
    }]
Exemplo n.º 21
0
    def setUp(self):
        test_helpers.patch_environ(self)
        test_helpers.patch(self, [
            'clusterfuzz._internal.base.utils.random_weighted_choice',
        ])

        self.mock.random_weighted_choice.side_effect = _mock_random_weighted_choice
Exemplo n.º 22
0
 def setUp(self):
   helpers.patch(self, [
       'clusterfuzz._internal.base.utils.utcnow',
       'libs.helpers.get_user_email',
       'os.urandom',
   ])
   self.mock.get_user_email.return_value = '*****@*****.**'
  def setUp(self):
    test_helpers.patch(
        self, ['clusterfuzz._internal.base.utils.default_project_name'])

    # It's important to use chromium here to test they datastore key generation
    # logic which uses project qualified fuzz target names.
    self.mock.default_project_name.return_value = 'chromium'
Exemplo n.º 24
0
  def setUp(self):
    helpers.patch(self, [
        'clusterfuzz._internal.bot.untrusted_runner.host.stub',
    ])

    helpers.patch_environ(self)
    os.environ['WORKER_ROOT_DIR'] = '/worker'
Exemplo n.º 25
0
 def setUp(self):
   test_helpers.patch(self, [
       'clusterfuzz._internal.base.utils.is_oss_fuzz',
       'libs.auth.is_current_user_admin',
   ])
   test_helpers.patch_environ(self)
   self.mock.is_oss_fuzz.return_value = False
Exemplo n.º 26
0
    def setUp(self):
        helpers.patch(self, [
            'libs.issue_management.jira.issue_tracker_manager.'
            'IssueTrackerManager.get_watchers',
            'libs.issue_management.jira.issue_tracker_manager.'
            'IssueTrackerManager.get_issues',
            'libs.issue_management.jira.IssueTracker.get_issue',
            'libs.issue_management.jira.IssueTracker.new_issue',
            'clusterfuzz._internal.config.db_config.get'
        ])

        self.itm = issue_tracker_manager.IssueTrackerManager('VSEC')
        self.issue_tracker = jira.IssueTracker(self.itm)
        self.jira_issue = JiraIssue('VSEC-3112')
        self.mock.get_watchers.return_value = []

        self.mock_issue = Issue(self.itm, self.jira_issue)
        self.mock_issue.title = 'summary'
        self.mock_issue.body = 'body'
        self.mock_issue.reporter = 'reporter'
        self.mock_issue.status = 'NOT STARTED'
        self.mock_issue.labels.add('label1')
        self.mock_issue.labels.add('label2')
        self.mock_issue.components.add('A>B')
        self.mock_issue.components.add('C>D')
        self.mock_issue.ccs.add('*****@*****.**')
Exemplo n.º 27
0
    def setUp(self):
        test_helpers.patch(
            self, ['clusterfuzz._internal.platforms.android.adb.run_command'])
        test_helpers.patch_environ(self)

        output = _read_data_file('get_device_codename_output.txt')
        self.mock.run_command.return_value = output
Exemplo n.º 28
0
 def setUp(self):
     helpers.patch(self, [
         'clusterfuzz._internal.system.environment.platform',
         'clusterfuzz._internal.system.new_process.ChildProcess.kill'
     ])
     self.mock.platform.return_value = 'LINUX'
     self.mock.kill.side_effect = mock_kill
Exemplo n.º 29
0
    def setUp(self):
        self.maxDiff = None  # pylint: disable=invalid-name
        test_helpers.patch_environ(self)
        test_helpers.patch(self, [
            'clusterfuzz._internal.google_cloud_utils.blobs.get_blob_info',
            'clusterfuzz._internal.google_cloud_utils.blobs.write_blob',
            'libs.access.has_access',
            'libs.helpers.get_user_email',
            'clusterfuzz._internal.base.utils.current_date_time',
            'clusterfuzz._internal.base.utils.utcnow',
        ])

        self.mock.get_blob_info.return_value.filename = 'input'
        self.mock.get_blob_info.return_value.key.return_value = 'blob_key'
        self.mock.write_blob.return_value = 'blob_key'
        self.mock.has_access.return_value = True
        self.mock.current_date_time.return_value = '2021-01-01 00:00:00 UTC'
        self.mock.utcnow.return_value = datetime.datetime(2021, 1, 1)
        self.mock.get_user_email.return_value = 'uploader@email'

        data_types.FuzzTarget(engine='libFuzzer',
                              project='test-project',
                              binary='binary').put()

        data_types.Job(name='libfuzzer_proj_external',
                       environment_string='PROJECT_NAME = proj',
                       platform='LINUX',
                       external_reproduction_topic='topic',
                       external_updates_subscription='sub').put()

        self.app = flask.Flask('testflask')
        self.app.add_url_rule(
            '/', view_func=upload_testcase.UploadHandlerOAuth.as_view(''))
Exemplo n.º 30
0
 def setUp(self):
     """Setup for get impacts from url test."""
     super().setUp()
     helpers.patch(self, [
         'clusterfuzz._internal.bot.tasks.impact_task.get_start_and_end_revision',
         'clusterfuzz._internal.bot.tasks.impact_task.get_impact',
         'clusterfuzz._internal.chrome.build_info.get_build_to_revision_mappings',
         'clusterfuzz._internal.build_management.revisions.revision_to_branched_from',
         'clusterfuzz._internal.datastore.data_handler.get_component_name',
     ])
     self.mock.get_component_name.return_value = None
     self.mock.revision_to_branched_from.side_effect = (
         self.mock_revision_to_branched_from)
     self.mock.get_start_and_end_revision.return_value = (1, 100)
     self.mock.get_build_to_revision_mappings.return_value = {
         'stable': {
             'revision': '398287',
             'version': '74.0.1345.34'
         },
         'beta': {
             'revision': '399171',
             'version': '75.0.1353.43'
         },
         'canary': {
             'revision': '400000',
             'version': '76.0.1234.43'
         }
     }
     self.mock.get_impact.side_effect = [
         impact_task.Impact(),
         impact_task.Impact('s', False),
         impact_task.Impact('b', True),
         impact_task.Impact('c', False)
     ]