コード例 #1
0
 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)
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
    def test_gpg_encrypt_nomocks(self):

        self.assertTrue(
            gpg.gpg_encrypt("a message", "*****@*****.**", VALID_KEY))
コード例 #5
0
    def test_gpg_encrypt_all_ok(self, popen):
        popen.return_value.stdout = b"stdout"

        self.assertEqual(gpg.gpg_encrypt('acontent', 'arecipient', 'akey'),
                         'stdout')
コード例 #6
0
 def test_gpg_encrypt_nomocks(self):
     self.assertTrue(gpg.gpg_encrypt("a message", VALID_KEY))
コード例 #7
0
    def test_gpg_encrypt_all_ok(self, popen):
        popen.return_value.stdout = b"<stdout>"

        self.assertEqual(gpg.gpg_encrypt("acontent", "akey"), "<stdout>")
コード例 #8
0
    def test_gpg_encrypt_all_ok(self, popen):
        popen.return_value.stdout = b"<stdout>"

        self.assertEqual(gpg.gpg_encrypt('acontent', 'akey'),
                         '<stdout>')