Exemple #1
0
    def test_create_hex_dump(self):
        not_enough_bytes = b'NotEnough'
        bad_result = create_hex_dump(not_enough_bytes)
        assert 'binary is too small for preview' == bad_result, 'binary should not be big enough'

        enough_bytes = b'\xFF' * 64 + b'\x00' * 64
        good_result = create_hex_dump(enough_bytes)
        assert 'ff ff' in good_result, 'hex dump was not created correctly'
Exemple #2
0
 def _show_hex_dump(self, uid):
     with ConnectTo(FrontEndDbInterface, self._config) as sc:
         object_exists = sc.existence_quick_check(uid)
     if not object_exists:
         return render_template('uid_not_found.html', uid=uid)
     else:
         with ConnectTo(InterComFrontEndBinding, self._config) as sc:
             result = sc.get_binary_and_filename(uid)
         if result is None:
             return render_template('error.html', message='timeout')
         else:
             binary, _ = result
             try:
                 hex_dump = create_hex_dump(binary)
                 return render_template('generic_view/hex_dump_popup.html', uid=uid, hex_dump=hex_dump)
             except Exception as exception:
                 return render_template('error.html', message=str(exception))