def test_extract_payload_compressed(self, request_generator): data, headers = multipart_encode({ 'ProductName': 'Firefox', 'Version': '1.0', 'upload_file_minidump': ('fakecrash.dump', io.BytesIO(b'abcd1234')) }) data = compress(data) headers['Content-Encoding'] = 'gzip' req = request_generator( method='POST', path='/submit', headers=headers, body=data, ) bsp = BreakpadSubmitterResource(self.empty_config) expected_raw_crash = { 'ProductName': 'Firefox', 'Version': '1.0', } expected_dumps = { 'upload_file_minidump': b'abcd1234' } assert bsp.extract_payload(req) == (expected_raw_crash, expected_dumps)
def test_extract_payload_compressed(self, request_generator): data, headers = multipart_encode({ "ProductName": "Firefox", "Version": "1.0", "upload_file_minidump": ("fakecrash.dump", io.BytesIO(b"abcd1234")), }) data = compress(data) headers["Content-Encoding"] = "gzip" req = request_generator(method="POST", path="/submit", headers=headers, body=data) bsp = BreakpadSubmitterResource(self.empty_config) expected_raw_crash = { "ProductName": "Firefox", "Version": "1.0", "payload": "multipart", } expected_dumps = {"upload_file_minidump": b"abcd1234"} assert bsp.extract_payload(req) == (expected_raw_crash, expected_dumps)
def test_extract_payload_compressed(self, request_generator): data, headers = multipart_encode({ 'ProductName': 'Firefox', 'Version': '1.0', 'upload_file_minidump': ('fakecrash.dump', io.BytesIO(b'abcd1234')) }) data = compress(data) headers['Content-Encoding'] = 'gzip' req = request_generator( method='POST', path='/submit', headers=headers, body=data, ) bsp = BreakpadSubmitterResource(self.empty_config) expected_raw_crash = { 'ProductName': 'Firefox', 'Version': '1.0', } expected_dumps = {'upload_file_minidump': b'abcd1234'} assert bsp.extract_payload(req) == (expected_raw_crash, expected_dumps)
def test_compressed_payload_bad_header(self, posturl, s3conn, crash_generator): """Test crash with a compressed payload, but missing header is discarded""" raw_crash, dumps = crash_generator.generate() # Generate the payload and headers for a crash with no dumps payload, headers = mini_poster.multipart_encode(raw_crash) # Compress the payload, but don't set the header payload = mini_poster.compress(payload) resp = requests.post(posturl, headers=headers, data=payload) assert resp.status_code == 200 assert str(resp.content, encoding='utf-8') == 'Discarded=1'