def test_sign_no_check(self): try: crypto.validate_key(utilities.make_key(can_sign=False)) except GPGProblem as e: raise AssertionError(e)
def test_encrypt(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(can_encrypt=False), encrypt=True) self.assertEqual(caught.exception.code, GPGCode.KEY_CANNOT_ENCRYPT)
def test_sign(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(can_sign=False), sign=True) self.assertEqual(caught.exception.code, GPGCode.KEY_CANNOT_SIGN)
def test_expired(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(expired=True)) self.assertEqual(caught.exception.code, GPGCode.KEY_EXPIRED)
def test_invalid(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(invalid=True)) self.assertEqual(caught.exception.code, GPGCode.KEY_INVALID)
def test_sign_no_check(self): try: crypto.validate_key(utilities.make_key(can_sign=False)) except GPGProblem as e: raise AssertionError(e)
def test_valid(self): try: crypto.validate_key(utilities.make_key()) except GPGProblem as e: raise AssertionError(e)
def test_sign(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(can_sign=False), sign=True) self.assertEqual(caught.exception.code, GPGCode.KEY_CANNOT_SIGN)
def test_encrypt(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(can_encrypt=False), encrypt=True) self.assertEqual(caught.exception.code, GPGCode.KEY_CANNOT_ENCRYPT)
def test_invalid(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(invalid=True)) self.assertEqual(caught.exception.code, GPGCode.KEY_INVALID)
def test_expired(self): with self.assertRaises(GPGProblem) as caught: crypto.validate_key(utilities.make_key(expired=True)) self.assertEqual(caught.exception.code, GPGCode.KEY_EXPIRED)
def test_valid(self): try: crypto.validate_key(utilities.make_key()) except GPGProblem as e: raise AssertionError(e)