예제 #1
0
파일: test_crypto.py 프로젝트: chevah/utils
    def test_key_store_comment(self):
        """
        When serializing a SSH public key to a file, a random comment can be
        added.
        """
        key = Key.fromString(data=RSA_PUBLIC_KEY_OPENSSH)
        public_file = StringIO()
        comment = mk.string()
        public_key_serialization = u'%s %s' % (
            RSA_PUBLIC_KEY_OPENSSH, comment)

        key.store(public_file=public_file, comment=comment)

        result_key = Key.fromString(public_file.getvalue())
        self.assertEqual(key.data, result_key.data)
        self.assertEqual(
            public_file.getvalue().decode('utf-8'), public_key_serialization)
예제 #2
0
파일: test_crypto.py 프로젝트: chevah/utils
 def test_key_store_dsa(self):
     """
     Check file serialization for a DSA key.
     """
     key = Key.fromString(data=DSA_PRIVATE_KEY)
     public_file = StringIO()
     private_file = StringIO()
     key.store(private_file=private_file, public_file=public_file)
     self.assertEqual(DSA_PRIVATE_KEY, private_file.getvalue())
     self.assertEqual(DSA_PUBLIC_KEY_OPENSSH, public_file.getvalue())