def test_no_x00_character(self):
        config = self.get_standard_config()
        c = BreakpadCollector(config)

        eq_(c._no_x00_character('\x00hello'), 'hello')
        eq_(c._no_x00_character(u'\u0000bye'), 'bye')
        eq_(c._no_x00_character(u'\u0000\x00bye'), 'bye')
    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_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)
Example #3
0
    def test_no_x00_character(self):
        config = self.get_standard_config()
        c = BreakpadCollector(config)

        eq_(c._no_x00_character('\x00hello'), 'hello')
        eq_(c._no_x00_character(u'\u0000bye'), 'bye')
        eq_(c._no_x00_character(u'\u0000\x00bye'), 'bye')
Example #4
0
    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.collector.accept_submitted_crash_id = True
        config.collector.accept_submitted_legacy_processing = True
        c = BreakpadCollector(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]
        )
    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)
        eq_(rc.ProductName, 'FireSquid')
        eq_(rc.Version, '99')
        eq_(rc.some_field, '23')
        eq_(rc.some_other_field, 'XYZ')
    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.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])
Example #7
0
 def test_setup(self):
     config = self.get_standard_config()
     c = BreakpadCollector(config)
     eq_(c.config, config)
     eq_(c.logger, config.logger)
     eq_(c.throttler, config.throttler)
     eq_(c.crash_storage, config.crash_storage)
     eq_(c.dump_id_prefix, 'bp-')
     eq_(c.dump_field, 'dump')
Example #8
0
    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.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)
        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]
        )