diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 16:04:21 +0000 |
commit | 8a754e0858d922e955e71b253c139e071ecec432 (patch) | |
tree | 527d16e74bfd1840c85efd675fdecad056c54107 /test/units/modules/test_apt_key.py | |
parent | Initial commit. (diff) | |
download | ansible-core-8a754e0858d922e955e71b253c139e071ecec432.tar.xz ansible-core-8a754e0858d922e955e71b253c139e071ecec432.zip |
Adding upstream version 2.14.3.upstream/2.14.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | test/units/modules/test_apt_key.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/units/modules/test_apt_key.py b/test/units/modules/test_apt_key.py new file mode 100644 index 0000000..37cd53b --- /dev/null +++ b/test/units/modules/test_apt_key.py @@ -0,0 +1,32 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +import os + +from units.compat.mock import patch, Mock +from units.compat import unittest + +from ansible.modules import apt_key + + +def returnc(x): + return 'C' + + +class AptKeyTestCase(unittest.TestCase): + + @patch.object(apt_key, 'apt_key_bin', '/usr/bin/apt-key') + @patch.object(apt_key, 'lang_env', returnc) + @patch.dict(os.environ, {'HTTP_PROXY': 'proxy.example.com'}) + def test_import_key_with_http_proxy(self): + m_mock = Mock() + m_mock.run_command.return_value = (0, '', '') + apt_key.import_key( + m_mock, keyring=None, keyserver='keyserver.example.com', + key_id='0xDEADBEEF') + self.assertEqual( + m_mock.run_command.call_args_list[0][0][0], + '/usr/bin/apt-key adv --no-tty --keyserver keyserver.example.com' + ' --keyserver-options http-proxy=proxy.example.com' + ' --recv 0xDEADBEEF' + ) |