From 3f8e08f410793d6379cfe22daf785b5a1c75a656 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 23 Aug 2021 08:45:10 -0500 Subject: [PATCH 1/3] testing: Fix ssh keys integration test Home directory permissions changed in hirsute. The integration test assumed permissions from earlier releases. Test was fixed to take both permissions into account --- tests/integration_tests/modules/test_ssh_keysfile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/integration_tests/modules/test_ssh_keysfile.py b/tests/integration_tests/modules/test_ssh_keysfile.py index 3159feb924d..5787654e3b2 100644 --- a/tests/integration_tests/modules/test_ssh_keysfile.py +++ b/tests/integration_tests/modules/test_ssh_keysfile.py @@ -77,13 +77,15 @@ def common_verify(client, expected_keys): # Ensure we haven't messed with any /home permissions # See LP: #1940233 home_dir = '/home/{}'.format(user) - home_perms = '755' + # Home permissions aren't consistent between releases. On ubuntu + # this can change to 750 once focal is unsupported. + home_perms = '75' if user == 'root': home_dir = '/root' home_perms = '700' - assert '{} {}'.format(user, home_perms) == client.execute( + client.execute( 'stat -c "%U %a" {}'.format(home_dir) - ) + ).startswith('{} {}'.format(user, home_perms)) if client.execute("test -d {}/.ssh".format(home_dir)).ok: assert '{} 700'.format(user) == client.execute( 'stat -c "%U %a" {}/.ssh'.format(home_dir) From de2430e150ca185be757740732ac45ee3575af63 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 23 Aug 2021 14:46:26 -0500 Subject: [PATCH 2/3] Update tests/integration_tests/modules/test_ssh_keysfile.py Co-authored-by: Chad Smith --- tests/integration_tests/modules/test_ssh_keysfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/integration_tests/modules/test_ssh_keysfile.py b/tests/integration_tests/modules/test_ssh_keysfile.py index 5787654e3b2..6a7b12f77ff 100644 --- a/tests/integration_tests/modules/test_ssh_keysfile.py +++ b/tests/integration_tests/modules/test_ssh_keysfile.py @@ -79,7 +79,10 @@ def common_verify(client, expected_keys): home_dir = '/home/{}'.format(user) # Home permissions aren't consistent between releases. On ubuntu # this can change to 750 once focal is unsupported. - home_perms = '75' + if ImageSpecification.from_os_image().release in ("bionic", "focal"): + home_perms = '755' + else: + home_perms = '750' if user == 'root': home_dir = '/root' home_perms = '700' From 274b01e9890aee7e6e71002d603663d549156aa0 Mon Sep 17 00:00:00 2001 From: James Falcon Date: Mon, 23 Aug 2021 15:58:20 -0500 Subject: [PATCH 3/3] 3rd times a charm? --- tests/integration_tests/modules/test_ssh_keysfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/integration_tests/modules/test_ssh_keysfile.py b/tests/integration_tests/modules/test_ssh_keysfile.py index 6a7b12f77ff..5c720578827 100644 --- a/tests/integration_tests/modules/test_ssh_keysfile.py +++ b/tests/integration_tests/modules/test_ssh_keysfile.py @@ -3,6 +3,7 @@ from io import StringIO from paramiko.ssh_exception import SSHException +from tests.integration_tests.clouds import ImageSpecification from tests.integration_tests.instances import IntegrationInstance from tests.integration_tests.util import get_test_rsa_keypair @@ -86,9 +87,9 @@ def common_verify(client, expected_keys): if user == 'root': home_dir = '/root' home_perms = '700' - client.execute( + assert '{} {}'.format(user, home_perms) == client.execute( 'stat -c "%U %a" {}'.format(home_dir) - ).startswith('{} {}'.format(user, home_perms)) + ) if client.execute("test -d {}/.ssh".format(home_dir)).ok: assert '{} 700'.format(user) == client.execute( 'stat -c "%U %a" {}/.ssh'.format(home_dir)