Page MenuHomePhabricator
Paste P7336

(An Untitled Masterwork)
ActivePublic

Authored by Vgutierrez on Jul 9 2018, 9:55 AM.
Tags
None
Referenced Files
F23501937:
Jul 9 2018, 9:55 AM
Subscribers
None
class PrivateKeyTest(unittest.TestCase):
def test_key_generation(self):
with tempfile.TemporaryDirectory() as tmpdir:
rsa_pk = PrivateKey(os.path.join(tmpdir, 'rsa.pem'), action="gen", key_type="rsa")
ec_pk = PrivateKey(os.path.join(tmpdir, 'ec.pem'), action="gen", key_type="ec")
rsa_stat = os.stat(os.path.join(tmpdir, 'rsa.pem'))
ec_stat = os.stat(os.path.join(tmpdir, 'ec.pem'))
self.assertIsInstance(rsa_pk.key, rsa.RSAPrivateKey)
self.assertIsInstance(ec_pk.key, ec.EllipticCurvePrivateKey)
# check private key file permissions
self.assertEqual(stat.S_IMODE(rsa_stat.st_mode), OPENER_MODE)
self.assertEqual(stat.S_IMODE(ec_stat.st_mode), OPENER_MODE)