Beispiel #1
0
    def test_fileinfo_result(self):
        pipelines = dict()
        pipe = FakePipeline('fileinfo')
        pipe.add_module(FileInfoModule(dict()))
        pipelines['fileinfo'] = pipe

        thread = self._start_server(pipelines=pipelines)
        client = ProcessClient(thread.server._transport)

        for filename, desc, mime in TESTFILES:
            filepath = os.path.join(os.path.dirname(test.__file__),
                "data", filename)

            with open(filepath, 'rb') as fp:
                data = fp.read()

            result = client.process_raw(str(uuid.uuid4()), 'fileinfo',
                {'path': filepath, 'name': filename}, data, autosave=False, wait_for_result=True)

            self.assertEqual(desc, result['filetype'])
            self.assertEqual(mime, result['mimetype'])
            self.assertEqual(len(data), result['filesize'])
            self.assertEqual(os.path.splitext(filename)[1][1:], result['extension'])

        self._stop_server(client, thread)
Beispiel #2
0
    def test_fileinfo_result(self):
        pipelines = dict()
        pipe = FakePipeline('fileinfo')
        pipe.add_module(FileInfoModule(dict()))
        pipelines['fileinfo'] = pipe

        thread = self._start_server(pipelines=pipelines)
        client = ProcessClient(thread.server._transport)

        for filename, desc, mime in TESTFILES:
            filepath = os.path.join(os.path.dirname(test.__file__), "data",
                                    filename)

            with open(filepath, 'rb') as fp:
                data = fp.read()

            result = client.process_raw(str(uuid.uuid4()),
                                        'fileinfo', {
                                            'path': filepath,
                                            'name': filename
                                        },
                                        data,
                                        autosave=False,
                                        wait_for_result=True)

            self.assertEqual(desc, result['filetype'])
            self.assertEqual(mime, result['mimetype'])
            self.assertEqual(len(data), result['filesize'])
            self.assertEqual(
                os.path.splitext(filename)[1][1:], result['extension'])

        self._stop_server(client, thread)
Beispiel #3
0
    def test_result(self):
        pipelines = dict()
        pipe = FakePipeline('hashing')
        pipe.add_module(HashModule(dict()))
        pipelines['hashing'] = pipe

        thread = self._start_server(pipelines=pipelines)
        client = ProcessClient(thread.server._transport)

        data = client.process_raw(str(uuid.uuid4()), 'hashing', dict(), TEST_DATA,
            autosave=False, wait_for_result=True)

        self._stop_server(client, thread)

        self.assertTrue('hash-md5' in data)
        md5 = hashlib.md5()
        md5.update(TEST_DATA)
        self.assertEqual(md5.hexdigest(), data['hash-md5'])

        self.assertTrue('hash-sha1' in data)
        sha1 = hashlib.sha1()
        sha1.update(TEST_DATA)
        self.assertEqual(sha1.hexdigest(), data['hash-sha1'])

        self.assertTrue('hash-sha256' in data)
        sha256 = hashlib.sha256()
        sha256.update(TEST_DATA)
        self.assertEqual(sha256.hexdigest(), data['hash-sha256'])

        self.assertTrue('hash-sha512' in data)
        sha512 = hashlib.sha512()
        sha512.update(TEST_DATA)
        self.assertEqual(sha512.hexdigest(), data['hash-sha512'])
Beispiel #4
0
    def test_result(self):
        pipelines = dict()
        pipe = FakePipeline('hashing')
        pipe.add_module(HashModule(dict()))
        pipelines['hashing'] = pipe

        thread = self._start_server(pipelines=pipelines)
        client = ProcessClient(thread.server._transport)

        data = client.process_raw(str(uuid.uuid4()),
                                  'hashing',
                                  dict(),
                                  TEST_DATA,
                                  autosave=False,
                                  wait_for_result=True)

        self._stop_server(client, thread)

        self.assertTrue('hash-md5' in data)
        md5 = hashlib.md5()
        md5.update(TEST_DATA)
        self.assertEqual(md5.hexdigest(), data['hash-md5'])

        self.assertTrue('hash-sha1' in data)
        sha1 = hashlib.sha1()
        sha1.update(TEST_DATA)
        self.assertEqual(sha1.hexdigest(), data['hash-sha1'])

        self.assertTrue('hash-sha256' in data)
        sha256 = hashlib.sha256()
        sha256.update(TEST_DATA)
        self.assertEqual(sha256.hexdigest(), data['hash-sha256'])

        self.assertTrue('hash-sha512' in data)
        sha512 = hashlib.sha512()
        sha512.update(TEST_DATA)
        self.assertEqual(sha512.hexdigest(), data['hash-sha512'])