コード例 #1
0
ファイル: test_gpg.py プロジェクト: mojodna/curtin
    def test_getkeybyid_exists(self, mock_export, mock_recv, mock_del):
        key = 'DEADBEEF'

        mock_export.side_effect = iter([
            "-----BEGIN PGP PUBLIC KEY BLOCK-----",
        ])

        gpg.getkeybyid(key)

        mock_export.assert_has_calls([call(key)])
        self.assertEqual([], mock_recv.call_args_list)
        self.assertEqual([], mock_del.call_args_list)
コード例 #2
0
ファイル: test_gpg.py プロジェクト: mojodna/curtin
    def test_getkeybyid(self, mock_export, mock_recv, mock_del):
        key = 'DEADBEEF'
        keyserver = 'my.keyserver.xyz.co.uk'

        mock_export.side_effect = iter([
            None,
            "-----BEGIN PGP PUBLIC KEY BLOCK-----",
        ])

        gpg.getkeybyid(key, keyserver=keyserver)

        mock_export.assert_has_calls([call(key), call(key)])
        mock_recv.assert_has_calls([
            call(key, keyserver=keyserver, retries=None)])
        mock_del.assert_has_calls([call(key)])
コード例 #3
0
ファイル: test_gpg.py プロジェクト: mojodna/curtin
    def test_getkeybyid_raises(self, mock_export, mock_recv, mock_del):
        key = 'DEADBEEF'
        keyserver = 'my.keyserver.xyz.co.uk'

        mock_export.side_effect = iter([
            None,
            "-----BEGIN PGP PUBLIC KEY BLOCK-----",
        ])
        mock_recv.side_effect = iter([
            ValueError("Failed to import key %s from server %s" %
                       (key, keyserver)),
        ])

        with self.assertRaises(ValueError):
            gpg.getkeybyid(key, keyserver=keyserver)

        mock_export.assert_has_calls([call(key)])
        mock_recv.assert_has_calls([
            call(key, keyserver=keyserver, retries=None)])
        mock_del.assert_has_calls([call(key)])
コード例 #4
0
ファイル: apt_config.py プロジェクト: idryzhov/curtin
def add_apt_key(filename, ent, target=None):
    """
    Add key to the system as defined in ent (if any).
    Supports raw keys or keyid's
    The latter will as a first step fetched to get the raw key
    """
    if 'keyid' in ent and 'key' not in ent:
        keyserver = DEFAULT_KEYSERVER
        if 'keyserver' in ent:
            keyserver = ent['keyserver']

        ent['key'] = gpg.getkeybyid(ent['keyid'],
                                    keyserver,
                                    retries=(1, 2, 5, 10))

    if 'key' in ent:
        add_apt_key_raw(filename, ent['key'], target)