# Import nacl libs
import libnacl

# Import python libs
import unittest


class TestAuthVerify(unittest.TestCase):
    '''
    Test onetimeauth functions
    '''
    def test_auth_verify(self):
        msg = b'Anybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.'
        key1 = libnacl.utils.rand_nonce()
        key2 = libnacl.utils.rand_nonce()

        sig1 = libnacl.crypto_auth(msg, key1)
        sig2 = libnacl.crypto_auth(msg, key2)

        self.assertTrue(libnacl.crypto_auth_verify(sig1, msg, key1))
        with self.assertRaises(ValueError) as context:
            libnacl.crypto_auth_verify(sig1, msg, key2)
        self.assertTrue('Failed to auth msg' in context.exception)

        with self.assertRaises(ValueError) as context:
            libnacl.crypto_auth_verify(sig2, msg, key1)
        self.assertTrue('Failed to auth msg' in context.exception)
        self.assertTrue(libnacl.crypto_auth_verify(sig2, msg, key2))

    '''
    Test onetimeauth functions
    '''
    def test_onetimeauth_verify(self):
        msg = b'Anybody can invent a cryptosystem he cannot break himself. Except Bruce Schneier.'
        key1 = libnacl.utils.rand_nonce()
        key2 = libnacl.utils.rand_nonce()

        sig1 = libnacl.crypto_onetimeauth(msg, key1)
        sig2 = libnacl.crypto_onetimeauth(msg, key2)

        self.assertTrue(libnacl.crypto_onetimeauth_verify(sig1, msg, key1))
        with self.assertRaises(ValueError) as context:
            libnacl.crypto_onetimeauth_verify(sig1, msg, key2)
        self.assertTrue('Failed to auth msg' in context.exception)

        with self.assertRaises(ValueError) as context:
            libnacl.crypto_onetimeauth_verify(sig2, msg, key1)
        self.assertTrue('Failed to auth msg' in context.exception)
        self.assertTrue(libnacl.crypto_onetimeauth_verify(sig2, msg, key2))

@@ -525,32 +525,101 @@
 g1, msg, key1))%0A
+        self.assertTrue(libnacl.crypto_auth_verify(sig2, msg, key2))%0A
         with sel
@@ -649,32 +649,32 @@
 or) as context:%0A
-
             libn
@@ -962,77 +962,8 @@
 ion)
-%0A        self.assertTrue(libnacl.crypto_auth_verify(sig2, msg, key2))
 %0A%0A  
@@ -1405,32 +1405,108 @@
 g1, msg, key1))%0A
+        self.assertTrue(libnacl.crypto_onetimeauth_verify(sig2, msg, key2))%0A
         with sel
@@ -1864,80 +1864,5 @@
 on)%0A
-        self.assertTrue(libnacl.crypto_onetimeauth_verify(sig2, msg, key2))
 %0A

Move the key2/sig2 checks up.