예제 #1
0
 def test_add_repo_key_failed(self):
     '''
     Test - Add a repo key using incomplete input data.
     '''
     with pytest.raises(SaltInvocationError) as ex:
         aptpkg.add_repo_key(keyserver='keyserver.ubuntu.com')
     assert ' No keyid or keyid too short for keyserver: keyserver.ubuntu.com' in str(ex)
예제 #2
0
파일: test_aptpkg.py 프로젝트: mcalmer/salt
def test_add_repo_key_failed(repo_keys_var):
    """
    Test - Add a repo key using incomplete input data.
    """
    with patch("salt.modules.aptpkg.get_repo_keys",
               MagicMock(return_value=repo_keys_var)):
        kwargs = {"keyserver": "keyserver.ubuntu.com"}
        mock = MagicMock(return_value={"retcode": 0, "stdout": "OK"})
        with patch.dict(aptpkg.__salt__, {"cmd.run_all": mock}):
            with pytest.raises(SaltInvocationError):
                aptpkg.add_repo_key(**kwargs)
예제 #3
0
 def test_add_repo_key(self):
     '''
     Test - Add a repo key.
     '''
     mock = MagicMock(return_value={'retcode': 0, 'stdout': 'OK'})
     with patch.dict(aptpkg.__salt__, {'cmd.run_all': mock}):
         self.assertTrue(
             aptpkg.add_repo_key(keyserver='keyserver.ubuntu.com',
                                 keyid='FBB75451'))
예제 #4
0
파일: test_aptpkg.py 프로젝트: rgroux/salt
def test_add_repo_key(repo_keys_var):
    """
    Test - Add a repo key.
    """
    with patch("salt.modules.aptpkg.get_repo_keys",
               MagicMock(return_value=repo_keys_var)):
        mock = MagicMock(return_value={"retcode": 0, "stdout": "OK"})
        with patch.dict(aptpkg.__salt__, {"cmd.run_all": mock}):
            assert (aptpkg.add_repo_key(keyserver="keyserver.ubuntu.com",
                                        keyid="FBB75451") is True)
예제 #5
0
파일: aptpkg_test.py 프로젝트: bryson/salt
 def test_add_repo_key(self):
     '''
     Test - Add a repo key.
     '''
     mock = MagicMock(return_value={
         'retcode': 0,
         'stdout': 'OK'
     })
     with patch.dict(aptpkg.__salt__, {'cmd.run_all': mock}):
         self.assertTrue(aptpkg.add_repo_key(keyserver='keyserver.ubuntu.com',
                                             keyid='FBB75451'))
예제 #6
0
def test_add_del_repo_key(get_key_file, aptkey):
    """
    Test both add_repo_key and del_repo_key when
    aptkey is both False and True
    """
    try:
        assert aptpkg.add_repo_key("salt://{}".format(get_key_file),
                                   aptkey=aptkey)
        keyfile = pathlib.Path("/etc", "apt", "keyrings", get_key_file)
        if not aptkey:
            assert keyfile.is_file()
        query_key = aptpkg.get_repo_keys(aptkey=aptkey)
        assert (query_key["0E08A149DE57BFBE"]["uid"] ==
                "SaltStack Packaging Team <*****@*****.**>")
    finally:
        aptpkg.del_repo_key(keyid="0E08A149DE57BFBE", aptkey=aptkey)
        if not aptkey:
            assert not keyfile.is_file()
        query_key = aptpkg.get_repo_keys(aptkey=aptkey)
        assert "0E08A149DE57BFBE" not in query_key
예제 #7
0
    def test_version(self):
        """
        Test - Returns a string representing the package version or an empty string if
        not installed.
        '''
        assert aptpkg.version(*['wget']) == aptpkg.__salt__['pkg_resource.version']()

    @patch('salt.modules.aptpkg.latest_version', MagicMock(return_value=''))
    def test_upgrade_available(self):
        """
        Test - Check whether or not an upgrade is available for a given package.
        '''
        assert not aptpkg.upgrade_available('wget')

    @patch('salt.modules.aptpkg.get_repo_keys', MagicMock(return_value=REPO_KEYS))
    @patch('salt.modules.aptpkg.__salt__', {'cmd.run_all': MagicMock(return_value={'retcode': 0, 'stdout': 'OK'})})
    def test_add_repo_key(self):
        """
        Test - Add a repo key.
        '''
        assert aptpkg.add_repo_key(keyserver='keyserver.ubuntu.com', keyid='FBB75451')
예제 #8
0
 def add_key(self):
     keydir = pathlib.Path("/etc", "apt", "keyrings")
     if not keydir.is_dir():
         keydir.mkdir()
     aptpkg.add_repo_key("salt://{}".format(self.keyname),
                         aptkey=self.aptkey)
예제 #9
0
 def test_add_repo_key(self):
     '''
     Test - Add a repo key.
     '''
     assert aptpkg.add_repo_key(keyserver='keyserver.ubuntu.com',
                                keyid='FBB75451')