diff options
| author | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-06-07 08:23:14 +0200 | 
|---|---|---|
| committer | Christian Ehrhardt <christian.ehrhardt@canonical.com> | 2016-06-07 08:23:14 +0200 | 
| commit | 1f05fd90f38b8ff1f1b2d6418030545d502b3965 (patch) | |
| tree | d12ec1251503d07b64a6f462d8edeb21c2877aa3 /tests/unittests/test_handler/test_handler_apt_source.py | |
| parent | 5d74451a5838c346fcbb4b0eee0d817fbf84128a (diff) | |
| download | vyos-cloud-init-1f05fd90f38b8ff1f1b2d6418030545d502b3965.tar.gz vyos-cloud-init-1f05fd90f38b8ff1f1b2d6418030545d502b3965.zip  | |
drop gpg activity from aot-source key tests
While the unittest gets a bit less real by that change, it will work in
protected environment (e.g. sbuild) and leave the developers .gpg keyring
alone.
Diffstat (limited to 'tests/unittests/test_handler/test_handler_apt_source.py')
| -rw-r--r-- | tests/unittests/test_handler/test_handler_apt_source.py | 24 | 
1 files changed, 5 insertions, 19 deletions
diff --git a/tests/unittests/test_handler/test_handler_apt_source.py b/tests/unittests/test_handler/test_handler_apt_source.py index 1f76e770..6223674b 100644 --- a/tests/unittests/test_handler/test_handler_apt_source.py +++ b/tests/unittests/test_handler/test_handler_apt_source.py @@ -4,7 +4,6 @@ Testing various config variations of the apt_source config  import os  import re  import shutil -import socket  import tempfile  try: @@ -410,27 +409,14 @@ class TestAptSourceConfig(TestCase):          """          params = self._get_default_params() -        def fake_gpg_recv_key(key, keyserver): -            """try original gpg_recv_key, but allow fall back""" -            try: -                self.orig_gpg_recv_key(key, keyserver) -            except ValueError: -                # if this is a networking issue mock it's effect -                testsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) -                try: -                    testsock.connect((keyserver, 80)) -                    testsock.close() -                except socket.error: -                    # as fallback add the known key as a working recv would -                    util.subp(("gpg", "--import", "-"), EXPECTEDKEY, -                              capture=True) -          with mock.patch.object(cc_apt_configure, 'add_apt_key_raw') as mockkey: -            with mock.patch.object(util, 'gpg_recv_key', -                                   side_effect=fake_gpg_recv_key): +            with mock.patch.object(util, 'getkeybyid', +                                   return_value=expectedkey) as mockgetkey:                  cc_apt_configure.add_apt_sources([cfg], params) -        # no matter if really imported or faked, ensure we add the right key +        mockgetkey.assert_called_with(cfg['keyid'], +                                      cfg.get('keyserver', +                                              'keyserver.ubuntu.com'))          mockkey.assert_called_with(expectedkey)          # filename should be ignored on key only  | 
