Ejemplo n.º 1
0
    def test_gpg_list_args(self):
        """Verify correct command gets called to list keys
        """
        no_colons = [
            'gpg',
            '--with-fingerprint',
            '--no-default-keyring',
            '--list-keys',
            '--keyring',
            'key']
        colons = [
            'gpg',
            '--with-fingerprint',
            '--no-default-keyring',
            '--list-keys',
            '--keyring',
            '--with-colons',
            'key']
        with mock.patch.object(subp, 'subp', return_value=('', '')) as m_subp:
            gpg.list('key')
            assert mock.call(colons, capture=True) == m_subp.call_args

            gpg.list('key', human_output=True)
            test_calls = mock.call((no_colons), capture=True)
            assert test_calls == m_subp.call_args
Ejemplo n.º 2
0
    def test_gpg_list_args(self):
        """Verify correct command gets called to list keys"""
        no_colons = [
            "gpg",
            "--with-fingerprint",
            "--no-default-keyring",
            "--list-keys",
            "--keyring",
            "key",
        ]
        colons = [
            "gpg",
            "--with-fingerprint",
            "--no-default-keyring",
            "--list-keys",
            "--keyring",
            "--with-colons",
            "key",
        ]
        with mock.patch.object(subp, "subp",
                               return_value=SubpResult("", "")) as m_subp:
            gpg.list("key")
            assert mock.call(colons, capture=True) == m_subp.call_args

            gpg.list("key", human_output=True)
            test_calls = mock.call((no_colons), capture=True)
            assert test_calls == m_subp.call_args
Ejemplo n.º 3
0
    def apt_key_list():
        """apt-key list

        returns string of all trusted keys (in /etc/apt/trusted.gpg and
        /etc/apt/trusted.gpg.d/)
        """
        key_list = []
        for key_file in _get_key_files():
            try:
                key_list.append(gpg.list(key_file, human_output=human_output))
            except subp.ProcessExecutionError as error:
                LOG.warning('Failed to list key "%s": %s', key_file, error)
        return "\n".join(key_list)