Esempio n. 1
0
    def test_POST_reject_browser_with_hangid(self, mocked_web, mocked_webapi,
                                             mocked_utc_now, mocked_time):
        config = self.get_standard_config()
        c = BreakpadCollector2015(config)
        rawform = DotDict()
        rawform[u'\u0000ProductName'] = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.HangID = 'xyz'
        rawform.ProcessType = 'browser'

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.throttle_rate = None
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (IGNORE, None)
        r = c.POST()
        eq_(r, "Unsupported=1\n")
        ok_(not c.crash_storage.save_raw_crash.call_count)
    def test_POST_with_existing_legacy_processing_and_use_it(
        self,
        mocked_web,
        mocked_webapi,
        mocked_utc_now,
        mocked_time
    ):
        config = self.get_standard_config()
        config.accept_submitted_crash_id = True
        config.accept_submitted_legacy_processing = True
        c = BreakpadCollector2015(config)

        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99\x00'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({'value': 'aux_dump contents', 'file': 'silliness'})
        rawform[u'some_field\u0000'] = '23'
        rawform[u'some_\u0000other_field'] = ObjectWithValue('XYZ')
        rawform.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        rawform.legacy_processing = str(DEFER)
        rawform.throttle_rate = 100

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = DEFER
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (DEFER, 100)
        r = c.POST()
        ok_(r.startswith('CrashID=bp-'))
        ok_(r.endswith('140107\n'))
        c.crash_storage.save_raw_crash.assert_called_with(
            erc,
            {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
            r[11:-1]
        )
Esempio n. 3
0
    def test_POST_with_existing_legacy_processing_and_use_it(self):
        config = self.get_standard_config()
        config.collector.accept_submitted_crash_id = True
        config.collector.accept_submitted_legacy_processing = True
        c = BreakpadCollector(config)

        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({
            'value': 'aux_dump contents',
            'file': 'silliness'
        })
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        rawform.legacy_processing = str(DEFER)
        rawform.throttle_rate = 100

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = DEFER
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        erc = dict(erc)

        with mock.patch(
                'socorro.collector.wsgi_breakpad_collector.web') as mocked_web:
            mocked_web.input.return_value = form
            with mock.patch('socorro.collector.wsgi_breakpad_collector.web.webapi') \
                    as mocked_webapi:
                mocked_webapi.rawinput.return_value = rawform
                with mock.patch('socorro.collector.wsgi_breakpad_collector.utc_now') \
                        as mocked_utc_now:
                    mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
                    with mock.patch('socorro.collector.wsgi_breakpad_collector.time') \
                            as mocked_time:
                        mocked_time.time.return_value = 3.0
                        c.throttler.throttle.return_value = (DEFER, 100)
                        r = c.POST()
                        ok_(r.startswith('CrashID=bp-'))
                        ok_(r.endswith('140107\n'))
                        c.crash_storage.save_raw_crash.assert_called_with(
                            erc, {
                                'dump': 'fake dump',
                                'aux_dump': 'aux_dump contents'
                            }, r[11:-1])
Esempio n. 4
0
    def test_POST_with_existing_crash_id_and_use_it(self, mocked_web,
                                                    mocked_webapi,
                                                    mocked_utc_now,
                                                    mocked_time):
        config = self.get_standard_config()
        config.accept_submitted_crash_id = True
        c = BreakpadCollector2015(config)

        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({
            'value': 'aux_dump contents',
            'file': 'silliness'
        })
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        rawform.legacy_processing = str(DEFER)
        rawform.throttle_rate = 100
        rawform.dump_checksums = "this is poised to overwrite and cause trouble"

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = DEFER
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (DEFER, 100)
        r = c.POST()
        ok_(r.startswith('CrashID=bp-'))
        ok_(r.endswith('140107\n'))
        c.crash_storage.save_raw_crash.assert_called_with(
            erc, {
                'dump': 'fake dump',
                'aux_dump': 'aux_dump contents'
            }, r[11:-1])
    def test_bad_capture_stats(self, mocked_web, mocked_webapi, mocked_utc_now, mocked_time):
        """Verify that a misbehaving capture_stats doesn't prevent collection"""
        config = self.get_standard_config()

        class MisbehavingMetrics(object):
            def __init__(self, config):
                self.capture_stats_calls = 0

            def capture_stats(self, stats):
                # Register that this was called
                self.capture_stats_calls += 1
                # Throw an exception because we're a misbehaving metrics
                raise Exception('ou812')

        config.metrics = MisbehavingMetrics(config)

        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = '\x00FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        # erc.some_field = '23'
        # erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.ctx.configure_mock(
            env={
                'CONTENT_LENGTH': 1000
            }
        )
        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (ACCEPT, 100)
        r = c.POST()

        # Verify capture_stats was called
        eq_(config.metrics.capture_stats_calls, 1)
        ok_(r.startswith('CrashID=bp-'))
    def test_POST(self, mocked_web, mocked_webapi, mocked_utc_now, mocked_time):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = '\x00FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({'value': 'aux_dump contents', 'file': 'silliness'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.ctx.configure_mock(
            env={
                'CONTENT_LENGTH': 1000
            }
        )
        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (ACCEPT, 100)
        r = c.POST()
        ok_(r.startswith('CrashID=bp-'))
        ok_(r.endswith('120504\n'))
        erc['uuid'] = r[11:-1]
        c.crash_storage.save_raw_crash.assert_called_with(
            erc,
            {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
            r[11:-1]
        )

        # Verify metrics were captured and .capture_stats() was called.
        config.metrics.capture_stats.assert_called_with(
            {'crash_report_size_accepted_uncompressed': 1000}
        )
    def test_POST_with_existing_legacy_processing_and_use_it(self):
        config = self.get_standard_config()
        config.collector.accept_submitted_crash_id = True
        config.collector.accept_submitted_legacy_processing = True
        c = BreakpadCollector(config)

        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({'value': 'aux_dump contents', 'file': 'silliness'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        rawform.legacy_processing = str(DEFER)
        rawform.throttle_rate = 100

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = DEFER
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.uuid = '332d798f-3c42-47a5-843f-a0f892140107'
        erc = dict(erc)

        with mock.patch('socorro.collector.wsgi_breakpad_collector.web') as mocked_web:
            mocked_web.input.return_value = form
            with mock.patch('socorro.collector.wsgi_breakpad_collector.web.webapi') \
                    as mocked_webapi:
                mocked_webapi.rawinput.return_value = rawform
                with mock.patch('socorro.collector.wsgi_breakpad_collector.utc_now') \
                        as mocked_utc_now:
                    mocked_utc_now.return_value = datetime(
                        2012, 5, 4, 15, 10
                        )
                    with mock.patch('socorro.collector.wsgi_breakpad_collector.time') \
                            as mocked_time:
                        mocked_time.time.return_value = 3.0
                        c.throttler.throttle.return_value = (DEFER, 100)
                        r = c.POST()
                        ok_(r.startswith('CrashID=bp-'))
                        ok_(r.endswith('140107\n'))
                        c.crash_storage.save_raw_crash.assert_called_with(
                          erc,
                          {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
                          r[11:-1]
                        )
Esempio n. 8
0
    def test_bad_capture_stats(self, mocked_web, mocked_webapi, mocked_utc_now,
                               mocked_time):
        """Verify that a misbehaving capture_stats doesn't prevent collection"""
        config = self.get_standard_config()

        class MisbehavingMetrics(object):
            def __init__(self, config):
                self.capture_stats_calls = 0

            def capture_stats(self, stats):
                # Register that this was called
                self.capture_stats_calls += 1
                # Throw an exception because we're a misbehaving metrics
                raise Exception('ou812')

        config.metrics = MisbehavingMetrics(config)

        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = '\x00FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        # erc.some_field = '23'
        # erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.ctx.configure_mock(env={'CONTENT_LENGTH': 1000})
        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (ACCEPT, 100)
        r = c.POST()

        # Verify capture_stats was called
        eq_(config.metrics.capture_stats_calls, 1)
        ok_(r.startswith('CrashID=bp-'))
Esempio n. 9
0
    def test_POST(self, mocked_web, mocked_webapi, mocked_utc_now,
                  mocked_time):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = '\x00FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({
            'value': 'aux_dump contents',
            'file': 'silliness'
        })
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.ctx.configure_mock(env={'CONTENT_LENGTH': 1000})
        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (ACCEPT, 100)
        r = c.POST()
        ok_(r.startswith('CrashID=bp-'))
        ok_(r.endswith('120504\n'))
        erc['uuid'] = r[11:-1]
        c.crash_storage.save_raw_crash.assert_called_with(
            erc, {
                'dump': 'fake dump',
                'aux_dump': 'aux_dump contents'
            }, r[11:-1])

        # Verify metrics were captured and .capture_stats() was called.
        config.metrics.capture_stats.assert_called_with(
            {'collector.crash_report_size_accepted_uncompressed': 1000})
    def test_POST_reject_browser_with_hangid(
        self,
        mocked_web,
        mocked_webapi,
        mocked_utc_now,
        mocked_time
    ):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform[u'\u0000ProductName'] = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.HangID = 'xyz'
        rawform.ProcessType = 'browser'

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.throttle_rate = None
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.type_tag = 'bp'
        erc = dict(erc)

        mocked_web.ctx.configure_mock(
            env={
                'CONTENT_LENGTH': 1000
            }
        )
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (IGNORE, None)
        r = c.POST()
        eq_(r, "Unsupported=1\n")
        ok_(not
            c.crash_storage.save_raw_crash.call_count
        )

        # Verify metrics were captured and .capture_stats() was called.
        config.metrics.capture_stats.assert_called_with(
            {'crash_report_size_rejected_uncompressed': 1000}
        )
    def test_POST_with_existing_crash_id_and_use_it(
        self,
        mocked_web,
        mocked_webapi,
        mocked_utc_now,
        mocked_time
    ):
        config = self.get_standard_config()
        config.accept_submitted_crash_id = True
        c = GenericCollector(config)

        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({'value': 'aux_dump contents', 'file': 'silliness'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.crash_id = '332d798f-3c42-47a5-843f-a0f892140107'

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.crash_id = '332d798f-3c42-47a5-843f-a0f892140107'
        erc.type_tag = 'XXX-'
        erc.dump_checksums = {
            'dump': 'a_hash',
            'aux_dump': 'a_hash',
        }
        erc = dict(erc)

        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        r = c.POST()
        ok_(r.startswith('CrashID=XXX-'))
        ok_(r.endswith('140107\n'))
        c.crash_storage.save_raw_crash.assert_called_with(
            erc,
            {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
            r[12:-1]
        )
Esempio n. 12
0
    def test_POST_with_existing_crash_id_and_use_it(self, mocked_web,
                                                    mocked_webapi,
                                                    mocked_utc_now,
                                                    mocked_time):
        config = self.get_standard_config()
        config.accept_submitted_crash_id = True
        c = GenericCollector(config)

        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({
            'value': 'aux_dump contents',
            'file': 'silliness'
        })
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.crash_id = '332d798f-3c42-47a5-843f-a0f892140107'

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.crash_id = '332d798f-3c42-47a5-843f-a0f892140107'
        erc.type_tag = 'XXX-'
        erc.dump_checksums = {
            'dump': 'a_hash',
            'aux_dump': 'a_hash',
        }
        erc = dict(erc)

        mocked_web.input.return_value = form
        mocked_webapi.rawinput.return_value = rawform
        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        r = c.POST()
        ok_(r.startswith('CrashID=XXX-'))
        ok_(r.endswith('140107\n'))
        c.crash_storage.save_raw_crash.assert_called_with(
            erc, {
                'dump': 'fake dump',
                'aux_dump': 'aux_dump contents'
            }, r[12:-1])
Esempio n. 13
0
    def test_POST(self):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({
            'value': 'aux_dump contents',
            'file': 'silliness'
        })
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc = dict(erc)

        with mock.patch(
                'socorro.collector.wsgi_breakpad_collector.web') as mocked_web:
            mocked_web.input.return_value = form
            with mock.patch('socorro.collector.wsgi_breakpad_collector.web.webapi') \
                    as mocked_webapi:
                mocked_webapi.rawinput.return_value = rawform
                with mock.patch('socorro.collector.wsgi_breakpad_collector.utc_now') \
                        as mocked_utc_now:
                    mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
                    with mock.patch('socorro.collector.wsgi_breakpad_collector.time') \
                            as mocked_time:
                        mocked_time.time.return_value = 3.0
                        c.throttler.throttle.return_value = (ACCEPT, 100)
                        r = c.POST()
                        ok_(r.startswith('CrashID=bp-'))
                        ok_(r.endswith('120504\n'))
                        erc['uuid'] = r[11:-1]
                        c.crash_storage.save_raw_crash.assert_called_with(
                            erc, {
                                'dump': 'fake dump',
                                'aux_dump': 'aux_dump contents'
                            }, r[11:-1])
Esempio n. 14
0
    def test_POST(self):
        config = self.get_standard_config()
        c = Collector(config)
        rawform = DotDict()
        rawform.ProductName = 'FireFloozy'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({
            'value': 'aux_dump contents',
            'file': 'silliness'
        })
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireFloozy'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc = dict(erc)

        with nested(mock.patch('socorro.collector.wsgicollector.web'),
                    mock.patch('socorro.collector.wsgicollector.web.webapi'),
                    mock.patch('socorro.collector.wsgicollector.utc_now'),
                    mock.patch('socorro.collector.wsgicollector.time')) \
            as (mocked_web, mocked_webapi, mocked_utc_now, mocked_time):
            mocked_web.input.return_value = form
            mocked_webapi.rawinput.return_value = rawform
            mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
            mocked_time.time.return_value = 3.0
            c.legacy_throttler.throttle.return_value = ACCEPT
            r = c.POST()
            self.assertTrue(r.startswith('CrashID=bp-'))
            self.assertTrue(r.endswith('120504\n'))
            self.crash_storage.save_raw.assert_called_with(
                r[11:-1],
                erc,
                {
                    'dump': 'fake dump',
                    'aux_dump': 'aux_dump contents'
                },
            )
    def test_POST(self):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({'value': 'aux_dump contents', 'file': 'silliness'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc = dict(erc)

        with mock.patch('socorro.collector.wsgi_breakpad_collector.web') as mocked_web:
            mocked_web.input.return_value = form
            with mock.patch('socorro.collector.wsgi_breakpad_collector.web.webapi') \
                    as mocked_webapi:
                mocked_webapi.rawinput.return_value = rawform
                with mock.patch('socorro.collector.wsgi_breakpad_collector.utc_now') \
                        as mocked_utc_now:
                    mocked_utc_now.return_value = datetime(
                        2012, 5, 4, 15, 10
                        )
                    with mock.patch('socorro.collector.wsgi_breakpad_collector.time') \
                            as mocked_time:
                        mocked_time.time.return_value = 3.0
                        c.throttler.throttle.return_value = (ACCEPT, 100)
                        r = c.POST()
                        ok_(r.startswith('CrashID=bp-'))
                        ok_(r.endswith('120504\n'))
                        erc['uuid'] = r[11:-1]
                        c.crash_storage.save_raw_crash.assert_called_with(
                          erc,
                          {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
                          r[11:-1]
                        )
Esempio n. 16
0
    def test_POST_reject_browser_with_hangid(self):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        rawform = DotDict()
        rawform.ProductName = 'FireSquid'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')
        rawform.HangID = 'xyz'
        rawform.ProcessType = 'browser'

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.throttle_rate = None
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc = dict(erc)

        with mock.patch('socorro.collector.wsgi_breakpad_collector.web') as mocked_web:
            mocked_web.input.return_value = form
            with mock.patch('socorro.collector.wsgi_breakpad_collector.web.webapi') \
                    as mocked_webapi:
                mocked_webapi.rawinput.return_value = rawform
                with mock.patch('socorro.collector.wsgi_breakpad_collector.utc_now') \
                        as mocked_utc_now:
                    mocked_utc_now.return_value = datetime(
                        2012, 5, 4, 15, 10
                        )
                    with mock.patch('socorro.collector.wsgi_breakpad_collector.time') \
                            as mocked_time:
                        mocked_time.time.return_value = 3.0
                        c.throttler.throttle.return_value = (IGNORE, None)
                        r = c.POST()
                        self.assertEqual(r, "Unsupported=1\n")
                        self.assertFalse(
                          c.crash_storage.save_raw_crash.call_count
                        )
Esempio n. 17
0
    def test_POST(self):
        config = self.get_standard_config()
        c = Collector(config)
        rawform = DotDict()
        rawform.ProductName = 'FireFloozy'
        rawform.Version = '99'
        rawform.dump = DotDict({'value': 'fake dump', 'file': 'faked file'})
        rawform.aux_dump = DotDict({'value': 'aux_dump contents', 'file':
                                    'silliness'})
        rawform.some_field = '23'
        rawform.some_other_field = ObjectWithValue('XYZ')

        form = DotDict(rawform)
        form.dump = rawform.dump.value

        erc = DotDict()
        erc.ProductName = 'FireFloozy'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc = dict(erc)

        with nested(mock.patch('socorro.collector.wsgicollector.web'),
                    mock.patch('socorro.collector.wsgicollector.web.webapi'),
                    mock.patch('socorro.collector.wsgicollector.utc_now'),
                    mock.patch('socorro.collector.wsgicollector.time')) \
            as (mocked_web, mocked_webapi, mocked_utc_now, mocked_time):
            mocked_web.input.return_value = form
            mocked_webapi.rawinput.return_value = rawform
            mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
            mocked_time.time.return_value = 3.0
            c.legacy_throttler.throttle.return_value = ACCEPT
            r = c.POST()
            self.assertTrue(r.startswith('CrashID=bp-'))
            self.assertTrue(r.endswith('120504\n'))
            self.crash_storage.save_raw.assert_called_with(
              r[11:-1],
              erc,
              {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
            )
Esempio n. 18
0
    def test_POST(self):
        config = self.get_standard_config()
        c = Collector(config)
        form = DotDict()
        form.ProductName = 'FireFloozy'
        form.Version = '99'
        form.dump = 'fake dump'
        form.some_field = '23'
        form.some_other_field = ObjectWithValue('XYZ')

        erc = DotDict()
        erc.ProductName = 'FireFloozy'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc = dict(erc)

        with mock.patch('socorro.collector.wsgi_collector.web') as mocked_web:
            mocked_web.input.return_value = form
            with mock.patch('socorro.collector.wsgi_collector.utc_now') \
              as mocked_utc_now:
                mocked_utc_now.return_value = datetime(
                  2012, 5, 4, 15, 10
                )
                with mock.patch('socorro.collector.wsgi_collector.time') \
                  as mocked_time:
                    mocked_time.time.return_value = 3.0
                    c.throttler.throttle.return_value = ACCEPT
                    r = c.POST()
                    self.assertTrue(r.startswith('CrashID=bp-'))
                    self.assertTrue(r.endswith('120504\n'))
                    c.crash_storage.save_raw_crash.assert_called_with(
                      erc,
                      'fake dump',
                      r[11:-1]
                    )
Esempio n. 19
0
    def test_make_raw_crash(self):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        form = DotDict()
        form.ProductName = 'FireSquid'
        form.Version = '99'
        form.dump = 'fake dump'
        form.some_field = '23'
        form.some_other_field = ObjectWithValue('XYZ')

        rc, dmp = c._make_raw_crash_and_dumps(form)
        self.assertEqual(rc.ProductName, 'FireSquid')
        self.assertEqual(rc.Version, '99')
        self.assertEqual(rc.some_field, '23')
        self.assertEqual(rc.some_other_field, 'XYZ')
Esempio n. 20
0
    def test_make_raw_crash(self):
        config = self.get_standard_config()
        c = Collector(config)
        form = DotDict()
        form.ProductName = 'FireFloozy'
        form.Version = '99'
        form.dump = 'fake dump'
        form.some_field = '23'
        form.some_other_field = ObjectWithValue('XYZ')

        rc = c.make_raw_crash(form)
        self.assertEqual(rc.ProductName, 'FireFloozy')
        self.assertEqual(rc.Version, '99')
        self.assertTrue('dump' not in rc)
        self.assertEqual(rc.some_field, '23')
        self.assertEqual(rc.some_other_field, 'XYZ')
    def test_make_raw_crash(self):
        config = self.get_standard_config()
        form = DotDict()
        form.ProductName = 'FireSquid'
        form.Version = '99'
        form.dump = 'fake dump'
        form.some_field = '23'
        form.some_other_field = ObjectWithValue('XYZ')

        class BreakpadCollectorWithMyForm(config.collector.collector_class):
            def _form_as_mapping(self):
                return form

        c = BreakpadCollectorWithMyForm(config)

        rc, dmp = c._get_raw_crash_from_form()
        eq_(rc.ProductName, 'FireSquid')
        eq_(rc.Version, '99')
        eq_(rc.some_field, '23')
        eq_(rc.some_other_field, 'XYZ')
Esempio n. 22
0
    def test_make_raw_crash(self):
        config = self.get_standard_config()
        form = DotDict()
        form.ProductName = 'FireSquid'
        form.Version = '99'
        form.dump = 'fake dump'
        form.some_field = '\x0023'
        form.some_other_field = ObjectWithValue('XYZ')

        class BreakpadCollectorWithMyForm(config.collector.collector_class):
            def _form_as_mapping(self):
                return form

        c = BreakpadCollectorWithMyForm(config)

        rc, dmp = c._get_raw_crash_from_form()
        eq_(rc.ProductName, 'FireSquid')
        eq_(rc.Version, '99')
        eq_(rc.some_field, '23')
        eq_(rc.some_other_field, 'XYZ')
    def test_POST_with_gzip(
        self,
        mocked_web_ctx,
        mocked_webapi,
        mocked_utc_now,
        mocked_time
    ):
        config = self.get_standard_config()
        c = BreakpadCollector(config)
        form = """
--socorro1234567
Content-Disposition: form-data; name="ProductName"

FireSquid
--socorro1234567
Content-Disposition: form-data; name="Version"

99
--socorro1234567
Content-Disposition: form-data; name="some_field"

23
--socorro1234567
Content-Disposition: form-data; name="some_other_field"

XYZ
--socorro1234567
Content-Disposition: form-data; name="dump"; filename="dump"
Content-Type: application/octet-stream

fake dump
--socorro1234567
Content-Disposition: form-data; name="aux_dump"; filename="aux_dump"
Content-Type: application/octet-stream

aux_dump contents
"""

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc = dict(erc)

        with closing(StringIO.StringIO()) as s:
            g = gzip.GzipFile(fileobj=s, mode='w')
            g.write(form)
            g.close()
            gzipped_form = s.getvalue()

        mocked_webapi.data.return_value = gzipped_form
        mocked_web_ctx.configure_mock(
            env={
                'HTTP_CONTENT_ENCODING': 'gzip',
                'CONTENT_ENCODING': 'gzip',
                'CONTENT_TYPE':
                    'multipart/form-data; boundary="socorro1234567"',
                'REQUEST_METHOD': 'POST'
            }
        )

        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (ACCEPT, 100)
        r = c.POST()
        ok_(r.startswith('CrashID=bp-'))
        ok_(r.endswith('120504\n'))
        erc['uuid'] = r[11:-1]
        c.crash_storage.save_raw_crash.assert_called_with(
            erc,
            {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
            r[11:-1]
        )
    def test_POST_with_gzip(
        self,
        mocked_web_ctx,
        mocked_webapi,
        mocked_utc_now,
        mocked_time
    ):
        config = self.get_standard_config()
        c = GenericCollector(config)
        form = """
--socorro1234567
Content-Disposition: form-data; name="ProductName"

FireSquid
--socorro1234567
Content-Disposition: form-data; name="Version"

99
--socorro1234567
Content-Disposition: form-data; name="some_field"

23
--socorro1234567
Content-Disposition: form-data; name="some_other_field"

XYZ
--socorro1234567
Content-Disposition: form-data; name="dump"; filename="dump"
Content-Type: application/octet-stream

fake dump
--socorro1234567
Content-Disposition: form-data; name="aux_dump"; filename="aux_dump"
Content-Type: application/octet-stream

aux_dump contents
"""

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.type_tag = 'XXX-'
        erc.dump_checksums = {
            'dump': 'a_hash',
            'aux_dump': 'a_hash',
        }
        erc = dict(erc)

        with closing(StringIO.StringIO()) as s:
            g = gzip.GzipFile(fileobj=s, mode='w')
            g.write(form)
            g.close()
            gzipped_form = s.getvalue()

        mocked_webapi.data.return_value = gzipped_form
        mocked_web_ctx.configure_mock(
            env={
                'HTTP_CONTENT_ENCODING': 'gzip',
                'CONTENT_ENCODING': 'gzip',
                'CONTENT_TYPE':
                    'multipart/form-data; boundary="socorro1234567"',
                'REQUEST_METHOD': 'POST'
            }
        )

        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        r = c.POST()
        ok_(r.startswith('CrashID=XXX-'))
        print r
        ok_(r.endswith('120504\n'))
        erc['crash_id'] = r[12:-1]
        c.crash_storage.save_raw_crash.assert_called_with(
            erc,
            {'dump':'fake dump', 'aux_dump':'aux_dump contents'},
            r[12:-1]
        )
Esempio n. 25
0
    def test_POST_with_gzip(self, mocked_web_ctx, mocked_webapi,
                            mocked_utc_now, mocked_time):
        config = self.get_standard_config()
        c = GenericCollector(config)
        form = """
--socorro1234567
Content-Disposition: form-data; name="ProductName"

FireSquid
--socorro1234567
Content-Disposition: form-data; name="Version"

99
--socorro1234567
Content-Disposition: form-data; name="some_field"

23
--socorro1234567
Content-Disposition: form-data; name="some_other_field"

XYZ
--socorro1234567
Content-Disposition: form-data; name="dump"; filename="dump"
Content-Type: application/octet-stream

fake dump
--socorro1234567
Content-Disposition: form-data; name="aux_dump"; filename="aux_dump"
Content-Type: application/octet-stream

aux_dump contents
"""

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.type_tag = 'XXX-'
        erc.dump_checksums = {
            'dump': 'a_hash',
            'aux_dump': 'a_hash',
        }
        erc = dict(erc)

        with closing(StringIO.StringIO()) as s:
            g = gzip.GzipFile(fileobj=s, mode='w')
            g.write(form)
            g.close()
            gzipped_form = s.getvalue()

        mocked_webapi.data.return_value = gzipped_form
        mocked_web_ctx.configure_mock(
            env={
                'HTTP_CONTENT_ENCODING': 'gzip',
                'CONTENT_ENCODING': 'gzip',
                'CONTENT_TYPE':
                'multipart/form-data; boundary="socorro1234567"',
                'REQUEST_METHOD': 'POST'
            })

        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        r = c.POST()
        ok_(r.startswith('CrashID=XXX-'))
        print r
        ok_(r.endswith('120504\n'))
        erc['crash_id'] = r[12:-1]
        c.crash_storage.save_raw_crash.assert_called_with(
            erc, {
                'dump': 'fake dump',
                'aux_dump': 'aux_dump contents'
            }, r[12:-1])
Esempio n. 26
0
    def test_POST_with_gzip(self, mocked_web_ctx, mocked_webapi,
                            mocked_utc_now, mocked_time):
        config = self.get_standard_config()
        c = BreakpadCollector2015(config)
        form = """
--socorro1234567
Content-Disposition: form-data; name="ProductName"

FireSquid
--socorro1234567
Content-Disposition: form-data; name="Version"

99
--socorro1234567
Content-Disposition: form-data; name="some_field"

23
--socorro1234567
Content-Disposition: form-data; name="some_other_field"

XYZ
--socorro1234567
Content-Disposition: form-data; name="dump"; filename="dump"
Content-Type: application/octet-stream

fake dump
--socorro1234567
Content-Disposition: form-data; name="aux_dump"; filename="aux_dump"
Content-Type: application/octet-stream

aux_dump contents
"""

        erc = DotDict()
        erc.ProductName = 'FireSquid'
        erc.Version = '99'
        erc.some_field = '23'
        erc.some_other_field = 'XYZ'
        erc.legacy_processing = ACCEPT
        erc.timestamp = 3.0
        erc.submitted_timestamp = '2012-05-04T15:10:00'
        erc.throttle_rate = 100
        erc.dump_checksums = {
            'dump': '2036fd064f93a0d086cf236c5f0fd8d4',
            'aux_dump': 'aa2e5bf71df8a4730446b2551d29cb3a',
        }
        erc.type_tag = 'bp'
        erc = dict(erc)

        with closing(StringIO.StringIO()) as s:
            g = gzip.GzipFile(fileobj=s, mode='w')
            g.write(form)
            g.close()
            gzipped_form = s.getvalue()

        mocked_webapi.data.return_value = gzipped_form
        mocked_web_ctx.configure_mock(
            env={
                'HTTP_CONTENT_ENCODING': 'gzip',
                'CONTENT_ENCODING': 'gzip',
                'CONTENT_TYPE':
                'multipart/form-data; boundary="socorro1234567"',
                'REQUEST_METHOD': 'POST'
            })

        mocked_utc_now.return_value = datetime(2012, 5, 4, 15, 10)
        mocked_time.time.return_value = 3.0
        c.throttler.throttle.return_value = (ACCEPT, 100)

        # the call to be tested
        r = c.POST()

        # this is what should have happened
        ok_(r.startswith('CrashID=bp-'))
        ok_(r.endswith('120504\n'))
        erc['uuid'] = r[11:-1]
        c.crash_storage.save_raw_crash.assert_called_with(
            erc, {
                'dump': 'fake dump',
                'aux_dump': 'aux_dump contents'
            }, r[11:-1])