class TestMessageCryptoSystem(unittest.TestCase):

    def setUp(self):
        self.crypto_system = MessageCryptoSystem('1111111111111111', 'some_shared_key')
        self.crypto = MessageCrypto('1111111111111111')
        self.authenticator = MessageAuthenticator('some_shared_key')

    def test_wrap_unwrap(self):
        self.assertEqual(self.crypto_system.unwrap_message(self.crypto_system.wrap_message('test')), 'test')

    def test_wrap_bad_inner_signature(self):
        message = self.bad_inner_signature('test')
        self.assertNotEqual(self.crypto_system.wrap_message('test'), message)

    def test_wrap_bad_outer_signature(self):
        message = self.bad_outer_signature('test')
        self.assertNotEqual(self.crypto_system.wrap_message('test'), message)

    def test_wrap_bad_crypto(self):
        message = self.bad_crypto('test')
        self.assertNotEqual(self.crypto_system.wrap_message('test'), message)

    def test_unwrap_bad_inner_signature(self):
        message = self.bad_inner_signature('test')
        self.assertNotEqual(self.crypto_system.wrap_message(message), None)

    def test_unwrap_bad_outer_signature(self):
        message = self.bad_outer_signature('test')
        self.assertNotEqual(self.crypto_system.wrap_message(message), None)

    def test_unwrap_bad_crypto(self):
        message = self.bad_crypto('test')
        try:
            self.crypto_system.unwrap_message(message)
        except TypeError, e:
            self.assertEqual(type(e), TypeError)
 def setUp(self):
     self.crypto_system = MessageCryptoSystem('1111111111111111', 'some_shared_key')
     self.crypto = MessageCrypto('1111111111111111')
     self.authenticator = MessageAuthenticator('some_shared_key')