def test_get_repo_keys(add_key): """ Test aptpkg.get_repo_keys when aptkey is False and True """ ret = aptpkg.get_repo_keys(aptkey=add_key) assert (ret["0E08A149DE57BFBE"]["uid"] == "SaltStack Packaging Team <*****@*****.**>")
def test_get_repo_keys(self): ''' Test - List known repo key details. ''' mock = MagicMock(return_value={'retcode': 0, 'stdout': APT_KEY_LIST}) with patch.dict(aptpkg.__salt__, {'cmd.run_all': mock}): self.assertEqual(aptpkg.get_repo_keys(), REPO_KEYS)
def test_get_repo_keys(self): """ Test - List known repo key details. """ mock = MagicMock(return_value={"retcode": 0, "stdout": APT_KEY_LIST}) with patch.dict(aptpkg.__salt__, {"cmd.run_all": mock}): self.assertEqual(aptpkg.get_repo_keys(), REPO_KEYS)
def test_get_repo_keys_keydir_not_exist(key): """ Test aptpkg.get_repo_keys when aptkey is False and True and keydir does not exist """ ret = aptpkg.get_repo_keys(aptkey=key, keydir="/doesnotexist/") if not key: assert not ret else: assert ret
def test_get_repo_keys(repo_keys_var): """ Test - List known repo key details. """ APT_KEY_LIST = r""" pub:-:1024:17:46181433FBB75451:1104433784:::-:::scSC: fpr:::::::::C5986B4F1257FFA86632CBA746181433FBB75451: uid:-::::1104433784::B4D41942D4B35FF44182C7F9D00C99AF27B93AD0::Ubuntu CD Image Automatic Signing Key <*****@*****.**>: """ mock = MagicMock(return_value={"retcode": 0, "stdout": APT_KEY_LIST}) with patch.dict(aptpkg.__salt__, {"cmd.run_all": mock}): if not HAS_APT: with patch("os.listdir", return_value="/tmp/keys"): with patch("pathlib.Path.is_dir", return_value=True): assert aptpkg.get_repo_keys() == repo_keys_var else: assert aptpkg.get_repo_keys() == repo_keys_var
def test_get_repo_keys(self): ''' Test - List known repo key details. ''' mock = MagicMock(return_value={ 'retcode': 0, 'stdout': APT_KEY_LIST }) with patch.dict(aptpkg.__salt__, {'cmd.run_all': mock}): self.assertEqual(aptpkg.get_repo_keys(), REPO_KEYS)
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