예제 #1
0
    def test_wrong_dif(self):
        content1 = b"foo"
        fileobj1 = ContentFile(content1)

        content2 = b"bar"
        fileobj2 = ContentFile(content2)

        content3 = b"baz"
        fileobj3 = ContentFile(content3)

        total_checksum = sha1(content2 + content1 + content3).hexdigest()

        # The order here is on purpose because we check for the order of checksums
        blob1 = FileBlob.from_file(fileobj1)
        blob3 = FileBlob.from_file(fileobj3)
        blob2 = FileBlob.from_file(fileobj2)

        chunks = [blob2.checksum, blob1.checksum, blob3.checksum]

        assemble_dif(project_id=self.project.id,
                     name="foo.sym",
                     checksum=total_checksum,
                     chunks=chunks)

        status, _ = get_assemble_status(AssembleTask.DIF, self.project.id,
                                        total_checksum)
        assert status == ChunkFileState.ERROR
예제 #2
0
    def test_dif_response(self):
        sym_file = self.load_fixture('crash.sym')
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()
        chunks = [blob1.checksum]

        assemble_dif(
            project_id=self.project.id,
            name='crash.sym',
            checksum=total_checksum,
            chunks=chunks,
        )

        response = self.client.post(
            self.url,
            data={
                total_checksum: {
                    'name': 'test.sym',
                    'chunks': chunks,
                }
            },
            HTTP_AUTHORIZATION=u'Bearer {}'.format(self.token.token)
        )

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]['state'] == ChunkFileState.OK
        assert response.data[total_checksum]['dif']['cpuName'] == 'x86_64'
        assert response.data[total_checksum]['dif']['uuid'] == '67e9247c-814e-392b-a027-dbde6748fcbf'
예제 #3
0
    def test_wrong_dif(self):
        content1 = 'foo'.encode('utf-8')
        fileobj1 = ContentFile(content1)

        content2 = 'bar'.encode('utf-8')
        fileobj2 = ContentFile(content2)

        content3 = 'baz'.encode('utf-8')
        fileobj3 = ContentFile(content3)

        total_checksum = sha1(content2 + content1 + content3).hexdigest()

        # The order here is on purpose because we check for the order of checksums
        blob1 = FileBlob.from_file(fileobj1)
        blob3 = FileBlob.from_file(fileobj3)
        blob2 = FileBlob.from_file(fileobj2)

        chunks = [blob2.checksum, blob1.checksum, blob3.checksum]

        assemble_dif(
            project_id=self.project.id,
            name='foo.sym',
            checksum=total_checksum,
            chunks=chunks,
        )

        assert get_assemble_status(self.project,
                                   total_checksum)[0] == ChunkFileState.ERROR
예제 #4
0
    def test_dif_error_response(self):
        sym_file = 'fail'
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()
        chunks = [blob1.checksum]

        assemble_dif(
            project_id=self.project.id,
            name='test.sym',
            checksum=total_checksum,
            chunks=chunks,
        )

        response = self.client.post(
            self.url,
            data={
                total_checksum: {
                    'name': 'test.sym',
                    'chunks': [],
                }
            },
            HTTP_AUTHORIZATION=u'Bearer {}'.format(self.token.token)
        )

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]['state'] == ChunkFileState.ERROR
        assert response.data[total_checksum]['detail'].startswith('Invalid debug information file')
    def test_dif_error_response(self):
        sym_file = 'fail'
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()
        chunks = [blob1.checksum]

        assemble_dif(
            project_id=self.project.id,
            name='test.sym',
            checksum=total_checksum,
            chunks=chunks,
        )

        response = self.client.post(
            self.url,
            data={
                total_checksum: {
                    'name': 'test.sym',
                    'chunks': [],
                }
            },
            HTTP_AUTHORIZATION='Bearer {}'.format(self.token.token)
        )

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]['state'] == ChunkFileState.ERROR
        assert response.data[total_checksum]['detail'].startswith('Invalid debug information file')
예제 #6
0
    def test_dif_response(self):
        sym_file = self.load_fixture("crash.sym")
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()
        chunks = [blob1.checksum]

        assemble_dif(project_id=self.project.id,
                     name="crash.sym",
                     checksum=total_checksum,
                     chunks=chunks)

        response = self.client.post(
            self.url,
            data={total_checksum: {
                "name": "test.sym",
                "chunks": chunks
            }},
            HTTP_AUTHORIZATION=f"Bearer {self.token.token}",
        )

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]["state"] == ChunkFileState.OK
        assert response.data[total_checksum]["dif"]["cpuName"] == "x86_64"
        assert (response.data[total_checksum]["dif"]["uuid"] ==
                "67e9247c-814e-392b-a027-dbde6748fcbf")
예제 #7
0
    def test_wrong_dif(self):
        content1 = 'foo'.encode('utf-8')
        fileobj1 = ContentFile(content1)

        content2 = 'bar'.encode('utf-8')
        fileobj2 = ContentFile(content2)

        content3 = 'baz'.encode('utf-8')
        fileobj3 = ContentFile(content3)

        total_checksum = sha1(content2 + content1 + content3).hexdigest()

        # The order here is on purpose because we check for the order of checksums
        blob1 = FileBlob.from_file(fileobj1)
        blob3 = FileBlob.from_file(fileobj3)
        blob2 = FileBlob.from_file(fileobj2)

        chunks = [blob2.checksum, blob1.checksum, blob3.checksum]

        assemble_dif(
            project_id=self.project.id,
            name='foo.sym',
            checksum=total_checksum,
            chunks=chunks,
        )

        assert get_assemble_status(self.project, total_checksum)[0] == ChunkFileState.ERROR
    def test_dif_response(self):
        sym_file = self.load_fixture('crash.sym')
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()
        chunks = [blob1.checksum]

        assemble_dif(
            project_id=self.project.id,
            name='crash.sym',
            checksum=total_checksum,
            chunks=chunks,
        )

        response = self.client.post(
            self.url,
            data={
                total_checksum: {
                    'name': 'test.sym',
                    'chunks': chunks,
                }
            },
            HTTP_AUTHORIZATION='Bearer {}'.format(self.token.token)
        )

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]['state'] == ChunkFileState.OK
        assert response.data[total_checksum]['dif']['cpuName'] == 'x86_64'
        assert response.data[total_checksum]['dif']['uuid'] == '67e9247c-814e-392b-a027-dbde6748fcbf'
예제 #9
0
    def test_dif_error_reponse(self):
        sym_file = 'fail'
        blob1 = FileBlob.from_file(ContentFile(sym_file))

        total_checksum = sha1(sym_file).hexdigest()

        file = File.objects.create(
            name='test.sym',
            checksum=total_checksum,
            type='chunked',
            headers={CHUNK_STATE_HEADER: ChunkFileState.CREATED})

        file_blob_id_order = [blob1.id]

        assemble_dif(
            project_id=self.project.id,
            file_id=file.id,
            file_blob_ids=file_blob_id_order,
            checksum=total_checksum,
        )

        response = self.client.post(self.url,
                                    data={
                                        total_checksum: {
                                            'name': 'test.sym',
                                            'chunks': [blob1.checksum]
                                        }
                                    },
                                    HTTP_AUTHORIZATION='Bearer {}'.format(
                                        self.token.token))

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]['error'] == 'Invalid object file'
예제 #10
0
    def test_dif(self):
        sym_file = self.load_fixture("crash.sym")
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()

        assemble_dif(
            project_id=self.project.id,
            name="crash.sym",
            checksum=total_checksum,
            chunks=[blob1.checksum],
        )

        status, _ = get_assemble_status(AssembleTask.DIF, self.project.id, total_checksum)
        assert status == ChunkFileState.OK

        dif = ProjectDebugFile.objects.filter(project=self.project, checksum=total_checksum).get()

        assert dif.file.headers == {"Content-Type": "text/x-breakpad"}
예제 #11
0
    def test_dif(self):
        sym_file = self.load_fixture('crash.sym')
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()

        assemble_dif(
            project_id=self.project.id,
            name='crash.sym',
            checksum=total_checksum,
            chunks=[blob1.checksum],
        )

        dif = ProjectDebugFile.objects.filter(
            project=self.project,
            file__checksum=total_checksum,
        ).get()

        assert dif.file.headers == {'Content-Type': 'text/x-breakpad'}
예제 #12
0
    def test_dif(self):
        sym_file = self.load_fixture('crash.sym')
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()

        assemble_dif(
            project_id=self.project.id,
            name='crash.sym',
            checksum=total_checksum,
            chunks=[blob1.checksum],
        )

        dif = ProjectDSymFile.objects.filter(
            project=self.project,
            file__checksum=total_checksum,
        ).get()

        assert dif.file.headers == {'Content-Type': 'text/x-breakpad'}
    def test_dif_error_response(self):
        sym_file = b"fail"
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()
        chunks = [blob1.checksum]

        assemble_dif(
            project_id=self.project.id, name="test.sym", checksum=total_checksum, chunks=chunks
        )

        response = self.client.post(
            self.url,
            data={total_checksum: {"name": "test.sym", "chunks": []}},
            HTTP_AUTHORIZATION=f"Bearer {self.token.token}",
        )

        assert response.status_code == 200, response.content
        assert response.data[total_checksum]["state"] == ChunkFileState.ERROR
        assert "unsupported object file format" in response.data[total_checksum]["detail"]
예제 #14
0
    def test_wrong_dif(self):
        content1 = 'foo'.encode('utf-8')
        fileobj1 = ContentFile(content1)

        content2 = 'bar'.encode('utf-8')
        fileobj2 = ContentFile(content2)

        content3 = 'baz'.encode('utf-8')
        fileobj3 = ContentFile(content3)

        total_checksum = sha1(content2 + content1 + content3).hexdigest()

        # The order here is on purpose because we check for the order of checksums
        blob1 = FileBlob.from_file(fileobj1)
        bolb3 = FileBlob.from_file(fileobj3)
        bolb2 = FileBlob.from_file(fileobj2)

        file = File.objects.create(
            name='test',
            checksum=total_checksum,
            type='chunked',
            headers={CHUNK_STATE_HEADER: ChunkFileState.CREATED})

        file_blob_id_order = [bolb2.id, blob1.id, bolb3.id]

        file = File.objects.create(
            name='test',
            checksum=total_checksum,
            type='chunked',
            headers={CHUNK_STATE_HEADER: ChunkFileState.CREATED})

        assemble_dif(
            project_id=self.project.id,
            file_id=file.id,
            file_blob_ids=file_blob_id_order,
            checksum=total_checksum,
        )

        file = File.objects.filter(id=file.id, ).get()

        assert file.headers.get(CHUNK_STATE_HEADER) == ChunkFileState.ERROR
예제 #15
0
    def test_assemble_debug_id_override(self):
        sym_file = self.load_fixture("crash.sym")
        blob1 = FileBlob.from_file(ContentFile(sym_file))
        total_checksum = sha1(sym_file).hexdigest()

        assemble_dif(
            project_id=self.project.id,
            name="crash.sym",
            checksum=total_checksum,
            chunks=[blob1.checksum],
            debug_id="67e9247c-814e-392b-a027-dbde6748fcbf-beef",
        )

        status, _ = get_assemble_status(AssembleTask.DIF, self.project.id,
                                        total_checksum)
        assert status == ChunkFileState.OK

        dif = ProjectDebugFile.objects.filter(
            project=self.project, file__checksum=total_checksum).get()

        assert dif.file.headers == {"Content-Type": "text/x-breakpad"}
        assert dif.debug_id == "67e9247c-814e-392b-a027-dbde6748fcbf-beef"
예제 #16
0
    def test_dif(self):
        sym_file = self.load_fixture('crash.sym')
        blob1 = FileBlob.from_file(ContentFile(sym_file))

        total_checksum = sha1(sym_file).hexdigest()

        file = File.objects.create(
            name='test.sym',
            checksum=total_checksum,
            type='chunked',
            headers={CHUNK_STATE_HEADER: ChunkFileState.CREATED})

        file_blob_id_order = [blob1.id]

        assemble_dif(
            project_id=self.project.id,
            file_id=file.id,
            file_blob_ids=file_blob_id_order,
            checksum=total_checksum,
        )

        file = File.objects.filter(checksum=total_checksum, ).get()

        assert file.headers == {'Content-Type': 'text/x-breakpad'}