diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/kolla_container_tests/test_docker_worker.py | 73 | ||||
| -rw-r--r-- | tests/kolla_container_tests/test_podman_worker.py | 75 |
2 files changed, 89 insertions, 59 deletions
diff --git a/tests/kolla_container_tests/test_docker_worker.py b/tests/kolla_container_tests/test_docker_worker.py index c79022462..26fe020f2 100644 --- a/tests/kolla_container_tests/test_docker_worker.py +++ b/tests/kolla_container_tests/test_docker_worker.py @@ -42,7 +42,7 @@ FAKE_DATA = { 'container_engine': 'docker', 'api_version': None, 'auth_username': None, - 'auth_password': None, + 'auth_password': None, # nosec B105 'auth_registry': None, 'restart_policy': None, 'auth_email': None, @@ -125,7 +125,7 @@ FAKE_DATA = { FAKE_DATA_COMMON_OPTS = { 'auth_username': 'kevko', - 'auth_password': 'SECRET', + 'auth_password': 'SECRET', # nosec B105 'auth_registry': 'Quay.io/kolla', 'restart_policy': 'unless-stopped', 'auth_email': 'kevko@kevko.org', @@ -144,7 +144,7 @@ def get_DockerWorker(mod_param, docker_api_version='1.40'): common_options_defaults = { 'auth_email': None, - 'auth_password': None, + 'auth_password': None, # nosec B105 'auth_registry': None, 'auth_username': None, 'environment': None, @@ -405,10 +405,13 @@ class TestContainer(base.BaseTestCase): self.assertEqual(self.dw.create_volume.call_count, 2) def test_start_container_without_pull(self): - self.fake_data['params'].update({'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + params = { + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(params) self.dw = get_DockerWorker(self.fake_data['params']) self.dw.dc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -425,11 +428,14 @@ class TestContainer(base.BaseTestCase): self.dw.create_container.assert_called_once_with() def test_start_container_with_duplicate_name(self): - self.fake_data['params'].update({'name': 'my_container', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + params = { + 'name': 'my_container', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(params) self.dw = get_DockerWorker(self.fake_data['params']) self.dw.dc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -453,11 +459,14 @@ class TestContainer(base.BaseTestCase): self.dw.create_container.assert_called_once_with() def test_start_container(self): - self.fake_data['params'].update({'name': 'my_container', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + params = { + 'name': 'my_container', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(params) self.dw = get_DockerWorker(self.fake_data['params']) self.dw.dc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -497,12 +506,15 @@ class TestContainer(base.BaseTestCase): self.assertEqual(expected, self.dw.result) def test_start_container_no_systemd(self): - self.fake_data['params'].update({'name': 'my_container', - 'restart_policy': 'oneshot', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + params = { + 'name': 'my_container', + 'restart_policy': 'oneshot', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(params) self.dw = get_DockerWorker(self.fake_data['params']) self.dw.dc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -520,11 +532,14 @@ class TestContainer(base.BaseTestCase): self.dw.systemd.start.assert_not_called() def test_start_container_systemd_start_fail(self): - self.fake_data['params'].update({'name': 'my_container', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + params = { + 'name': 'my_container', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(params) self.dw = get_DockerWorker(self.fake_data['params']) self.dw.dc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -944,7 +959,7 @@ class TestImage(base.BaseTestCase): self.dw = get_DockerWorker( {'image': 'myregistrydomain.com:5000/ubuntu:16.04', 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', + 'auth_password': 'fake_psw', # nosec B105 'auth_registry': 'myrepo/myapp', 'auth_email': 'fake_mail@foogle.com' }) diff --git a/tests/kolla_container_tests/test_podman_worker.py b/tests/kolla_container_tests/test_podman_worker.py index b3bfcdce2..55ab5c165 100644 --- a/tests/kolla_container_tests/test_podman_worker.py +++ b/tests/kolla_container_tests/test_podman_worker.py @@ -299,10 +299,13 @@ class TestContainer(base.BaseTestCase): self.assertEqual(self.pw.create_volume.call_count, 2) def test_start_container_without_pull(self): - self.fake_data['params'].update({'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + auth_params = { + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(auth_params) self.pw = get_PodmanWorker(self.fake_data['params'].copy()) self.pw.pc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -322,11 +325,14 @@ class TestContainer(base.BaseTestCase): self.pw.create_container.assert_called_once_with() def test_start_container_with_duplicate_name(self): - self.fake_data['params'].update({'name': 'my_container', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + auth_params = { + 'name': 'my_container', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(auth_params) self.pw = get_PodmanWorker(self.fake_data['params']) self.pw.pc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -348,11 +354,13 @@ class TestContainer(base.BaseTestCase): self.pw.create_container.assert_called_once_with() def test_start_container(self): - self.fake_data['params'].update({'name': 'my_container', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + auth_params = { + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(auth_params) self.pw = get_PodmanWorker(self.fake_data['params']) self.pw.pc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -403,12 +411,15 @@ class TestContainer(base.BaseTestCase): self.assertEqual(expected, self.pw.result) def test_start_container_no_systemd(self): - self.fake_data['params'].update({'name': 'my_container', - 'restart_policy': 'oneshot', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'}) + auth_params = { + 'name': 'my_container', + 'restart_policy': 'oneshot', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(auth_params) self.pw = get_PodmanWorker(self.fake_data['params']) self.pw.pc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -426,12 +437,14 @@ class TestContainer(base.BaseTestCase): self.pw.systemd.start.assert_not_called() def test_start_container_systemd_start_fail(self): - self.fake_data['params'].update({'name': 'my_container', - 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', - 'auth_registry': 'myrepo/myapp', - 'auth_email': 'fake_mail@foogle.com'} - ) + params = { + 'name': 'my_container', + 'auth_username': 'fake_user', + 'auth_password': 'fake_psw', # nosec B105 + 'auth_registry': 'myrepo/myapp', + 'auth_email': 'fake_mail@foogle.com' + } + self.fake_data['params'].update(params) self.pw = get_PodmanWorker(self.fake_data['params']) self.pw.pc.images = mock.MagicMock( return_value=self.fake_data['images']) @@ -818,7 +831,7 @@ class TestImage(base.BaseTestCase): self.pw = get_PodmanWorker( {'image': 'myregistrydomain.com:5000/ubuntu:16.04', 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', + 'auth_password': 'fake_psw', # nosec B105 'auth_registry': 'myrepo/myapp', 'auth_email': 'fake_mail@foogle.com' }) @@ -832,7 +845,8 @@ class TestImage(base.BaseTestCase): tag='16.04', tls_verify=False, stream=False, - auth_config={'username': 'fake_user', 'password': 'fake_psw'} + auth_config={'username': 'fake_user', + 'password': 'fake_psw'} # nosec B105 ) self.assertTrue(self.pw.changed) @@ -840,7 +854,7 @@ class TestImage(base.BaseTestCase): self.pw = get_PodmanWorker( {'image': 'myregistrydomain.com:5000/ubuntu:16.04', 'auth_username': 'fake_user', - 'auth_password': 'fake_psw', + 'auth_password': 'fake_psw', # nosec B105 'auth_registry': 'myrepo/myapp', 'auth_email': 'fake_mail@foogle.com' }) @@ -854,7 +868,8 @@ class TestImage(base.BaseTestCase): tag='16.04', tls_verify=False, stream=False, - auth_config={'username': 'fake_user', 'password': 'fake_psw'} + auth_config={'username': 'fake_user', + 'password': 'fake_psw'} # nosec B105 ) self.assertFalse(self.pw.changed) |
