Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added more tests #96

Merged
merged 2 commits into from

3 participants

Alex Gaynor Coveralls Paul Kehrer
Alex Gaynor
Owner

No description provided.

Coveralls

Coverage Status

Coverage increased (+1.19%) when pulling ab5ee65 on alex:even-moar-coverage into ce20285 on pyca:master.

Coveralls

Coverage Status

Coverage increased (+1.19%) when pulling 8092075 on alex:even-moar-coverage into ce20285 on pyca:master.

Paul Kehrer reaperhulk merged commit b8863b8 into from
Alex Gaynor alex deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 16, 2014
  1. Alex Gaynor

    Added more tests

    alex authored
  2. Alex Gaynor

    flake8

    alex authored
This page is out of date. Refresh to see the latest.
Showing with 27 additions and 0 deletions.
  1. +5 −0 tests/test_raw.py
  2. +22 −0 tests/test_secret.py
5 tests/test_raw.py
View
@@ -160,6 +160,11 @@ def test_sign():
assert msg2 == msg
+def test_sign_wrong_lengths():
+ with pytest.raises(ValueError):
+ c.crypto_sign_seed_keypair(b"")
+
+
def secret_scalar():
pubkey, secretkey = c.crypto_box_keypair()
assert len(secretkey) == c.crypto_box_SECRETKEYBYTES
22 tests/test_secret.py
View
@@ -47,6 +47,14 @@ def test_secret_box_creation():
)
+def test_secret_box_bytes():
+ s = SecretBox(
+ b"ec2bee2d5be613ca82e377c96a0bf2220d823ce980cdff6279473edc52862798",
+ encoder=HexEncoder,
+ )
+ assert bytes(s) == s._key
+
+
@pytest.mark.parametrize(("key", "nonce", "plaintext", "ciphertext"), VECTORS)
def test_secret_box_encryption(key, nonce, plaintext, ciphertext):
box = SecretBox(key, encoder=HexEncoder)
@@ -87,3 +95,17 @@ def test_secret_box_decryption_combined(key, nonce, plaintext, ciphertext):
decrypted = binascii.hexlify(box.decrypt(combined, encoder=HexEncoder))
assert decrypted == plaintext
+
+
+def test_secret_box_wrong_lengths():
+ with pytest.raises(ValueError):
+ SecretBox(b"")
+
+ box = SecretBox(
+ b"ec2bee2d5be613ca82e377c96a0bf2220d823ce980cdff6279473edc52862798",
+ encoder=HexEncoder,
+ )
+ with pytest.raises(ValueError):
+ box.encrypt(b"", b"")
+ with pytest.raises(ValueError):
+ box.decrypt(b"", b"")
Something went wrong with that request. Please try again.