Skip to content

Commit

Permalink
Merge 2ece557 into f6bacb8
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffLIrion authored Dec 6, 2019
2 parents f6bacb8 + 2ece557 commit 12ed9ef
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 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,14 @@ 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()
# For reference:
# 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 12ed9ef

Please sign in to comment.