Example #1
0
 def test_bad_private_key(self):
     private_key_encoded = base64.b64encode(
         "this is not a valid private key".encode('utf-8')).decode('utf-8')
     err = "Error! ssh private key provided in invalid format"
     with self.assertRaises(InvalidArgumentValueError) as cm:
         get_protected_settings(private_key_encoded, '', '', '')
     self.assertEqual(str(cm.exception), err)
Example #2
0
 def test_dsa_private_key(self):
     key = DSA.generate(2048)
     private_key_encoded = base64.b64encode(
         key.export_key()).decode('utf-8')
     protected_settings = get_protected_settings(private_key_encoded, '',
                                                 '', '')
     self.assertEqual('sshPrivateKey' in protected_settings, True)
     self.assertEqual(protected_settings.get('sshPrivateKey'),
                      private_key_encoded)
Example #3
0
 def test_ed25519_private_key(self):
     ed25519_key = "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFNd0FBQUF0emMyZ3RaVwpReU5UVXhPUUFBQUNCNjF0RzkrNGFmOTZsWGoyUStjWjJMT2JpV1liMlRtWVR6N3NSV0JDM1hVZ0FBQUtCRzFWRWZSdFZSCkh3QUFBQXR6YzJndFpXUXlOVFV4T1FBQUFDQjYxdEc5KzRhZjk2bFhqMlErY1oyTE9iaVdZYjJUbVlUejdzUldCQzNYVWcKQUFBRURRTStLcCtOSWpJVUhSUklqRFE5VDZ0U0V0SG9Ic0w1QjlwbHpCNlZ2MnluclcwYjM3aHAvM3FWZVBaRDV4bllzNQp1SlpodlpPWmhQUHV4RllFTGRkU0FBQUFGMnB2YVc1dWFYTkFSRVZUUzFSUFVDMVFUVlZHVURaTkFRSURCQVVHCi0tLS0tRU5EIE9QRU5TU0ggUFJJVkFURSBLRVktLS0tLQo="
     protected_settings = get_protected_settings(ed25519_key, '', '', '')
     self.assertEqual('sshPrivateKey' in protected_settings, True)
     self.assertEqual(protected_settings.get('sshPrivateKey'), ed25519_key)
Example #4
0
 def test_ecdsa_private_key(self):
     ecdsa_key = "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUFhQUFBQUJObFkyUnpZUwoxemFHRXlMVzVwYzNSd01qVTJBQUFBQ0c1cGMzUndNalUyQUFBQVFRUjBRc1BjWmJKeWZPaXE2a1M1d0VaeE5DbmR2YVJHCm1ETEUvVVBjakpDTDZQTVIyZmdPS2NnWlhzTEZkTUFzSnExS2d6TmNDN0ZXNGE0L0wrYTFWWUxDQUFBQXNIZ1RqTFY0RTQKeTFBQUFBRTJWalpITmhMWE5vWVRJdGJtbHpkSEF5TlRZQUFBQUlibWx6ZEhBeU5UWUFBQUJCQkhSQ3c5eGxzbko4NktycQpSTG5BUm5FMEtkMjlwRWFZTXNUOVE5eU1rSXZvOHhIWitBNHB5Qmxld3NWMHdDd21yVXFETTF3THNWYmhyajh2NXJWVmdzCklBQUFBZ0h1U3laU0NUZzJZbVNpOG9aY2c0cnVpODh0T1NUSm1aRVhkR09hdExySHNBQUFBWGFtOXBibTVwYzBCRVJWTkwKVkU5UUxWQk5WVVpRTmswQgotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K"
     protected_settings = get_protected_settings(ecdsa_key, '', '', '')
     self.assertEqual('sshPrivateKey' in protected_settings, True)
     self.assertEqual(protected_settings.get('sshPrivateKey'), ecdsa_key)
Example #5
0
 def test_rsa_private_key(self):
     rsa_key = "LS0tLS1CRUdJTiBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0KYjNCbGJuTnphQzFyWlhrdGRqRUFBQUFBQkc1dmJtVUFBQUFFYm05dVpRQUFBQUFBQUFBQkFBQUJsd0FBQUFkemMyZ3RjbgpOaEFBQUFBd0VBQVFBQUFZRUF1bVA5M09qRHdjdlEyZHZhRlJNNWYrMEhVSnFvOFJnbmdwaGN3NFZidnd1TVNoQTZ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JFVlRTMVJQVUMxUVRWVkdVRFpOQVFJRAotLS0tLUVORCBPUEVOU1NIIFBSSVZBVEUgS0VZLS0tLS0K"
     protected_settings = get_protected_settings(rsa_key, '', '', '')
     self.assertEqual('sshPrivateKey' in protected_settings, True)
     self.assertEqual(protected_settings.get('sshPrivateKey'), rsa_key)