def test_is_valid_assertion(self): # Test that an AssertionError is raised when dealing with a # default SignedObject() because it does not have an signature temp2 = SignedObject() try: # will always print error # Does not have a signautre when created with default paramaters temp2.verify_signature("unused") # should throw an an assertion error, Otherwise fail test self.fail("Should have raised an Assertion Error") except AssertionError, e: self.assertIsInstance(e, AssertionError)
def test_is_valid(self): # Verify that is_valid only returns true if working with a valid # Signed Object # test a valid signature temp = SignedObject({"TestSignatureDictKey": "test"}, "TestSignatureDictKey") self.assertTrue(temp.is_valid("unused")) # test OriginatorID ogid = temp.OriginatorID self.assertTrue(temp.verify_signature(ogid)) # test invalid OriginatorID self.assertFalse(temp.verify_signature("invalid"))
def test_is_valid(self): # Verify that is_valid only returns true if working with a valid # Signed Object # test a valid signature signkey = SigObj.generate_signing_key() temp = SignedObject({signkey: "test"}, signkey) self.assertTrue(temp.is_valid("unused")) # test OriginatorID ogid = temp.OriginatorID self.assertTrue(temp.verify_signature(ogid)) # test invalid OriginatorID self.assertFalse(temp.verify_signature("invalid"))