Skip to content

Commit

Permalink
Merge cf246bf into f6bacb8
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion committed Dec 5, 2019
2 parents f6bacb8 + cf246bf commit 9d36f5e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tests/test_sign_cryptography.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import os
import unittest

from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes

from adb_shell.auth.keygen import keygen
from adb_shell.auth.sign_cryptography import CryptographySigner

Expand All @@ -16,8 +19,13 @@ def setUp(self):

def test_sign(self):
"""Test that the ``Sign`` method does not raise an exception."""
with self.assertRaises(ValueError):
self.signer.Sign(b'notadb')
# https://www.programcreek.com/python/example/107988/cryptography.hazmat.primitives.hashes.Hash
hash_ctx = hashes.Hash(hashes.SHA1(), default_backend())
hash_ctx.update(b'notadb')
data = hash_ctx.finalize()
self.assertEqual(data, b'(\x8b\x9e\x88|JY\xb5\x18\x13b_\xe0\xc4\xfb\xa5\x83\xbdx\xfc')

self.signer.Sign(data)
self.assertTrue(True)

def test_get_public_key(self):
Expand Down

0 comments on commit 9d36f5e

Please sign in to comment.