Beispiel #1
0
    def test_prefix(self):
        pipelines = dict()
        pipe = FakePipeline('hashing')
        pipe.add_module(HashModule({'prefix': 'verify'}))
        pipelines['hashing'] = pipe

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

        data = client.process_url(str(uuid.uuid4()),
                                  'hashing',
                                  dict(),
                                  'fake://blank',
                                  autosave=False,
                                  wait_for_result=True)

        self._stop_server(client, thread)

        self.assertTrue('verify-hash-md5' in data)
        self.assertTrue('verify-hash-sha1' in data)
        self.assertTrue('verify-hash-sha256' in data)
        self.assertTrue('verify-hash-sha512' in data)
Beispiel #2
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'])