def execute(self): secret = self._fetch_secret() gpg_key = self._get_gpg_key() encrypted_content = gpg.gpg_encrypt( content=secret, public_gpg_key=gpg_key, ) self._output(encrypted_content)
def get_encrypted_credentials(credentials_name, user, settings): credentials_map = settings['credentials'] credentials_map_item = \ [c for c in credentials_map if c['name'] == credentials_name] if len(credentials_map_item) != 1: return None secret = credentials_map_item[0]['secret'] secret_reader = SecretReader(settings=settings) credentials = secret_reader.read(secret) public_gpg_key = user['public_gpg_key'] encrypted_credentials = \ gpg_encrypt(credentials, public_gpg_key) return encrypted_credentials
def get_encrypted_credentials(credentials_name, user, settings): credentials_map = settings["credentials"] credentials_map_item = [ c for c in credentials_map if c["name"] == credentials_name ] if len(credentials_map_item) != 1: return None secret = credentials_map_item[0]["secret"] secret_reader = SecretReader(settings=settings) credentials = secret_reader.read(secret) public_gpg_key = user["public_gpg_key"] encrypted_credentials = gpg_encrypt(credentials, public_gpg_key) return encrypted_credentials
def test_gpg_encrypt_nomocks(self): self.assertTrue( gpg.gpg_encrypt("a message", "*****@*****.**", VALID_KEY))
def test_gpg_encrypt_all_ok(self, popen): popen.return_value.stdout = b"stdout" self.assertEqual(gpg.gpg_encrypt('acontent', 'arecipient', 'akey'), 'stdout')
def test_gpg_encrypt_nomocks(self): self.assertTrue(gpg.gpg_encrypt("a message", VALID_KEY))
def test_gpg_encrypt_all_ok(self, popen): popen.return_value.stdout = b"<stdout>" self.assertEqual(gpg.gpg_encrypt("acontent", "akey"), "<stdout>")
def test_gpg_encrypt_all_ok(self, popen): popen.return_value.stdout = b"<stdout>" self.assertEqual(gpg.gpg_encrypt('acontent', 'akey'), '<stdout>')