summaryrefslogtreecommitdiff
path: root/tests/integration_tests
diff options
context:
space:
mode:
authordermotbradley <dermot_bradley@yahoo.com>2021-11-30 20:08:42 +0000
committerGitHub <noreply@github.com>2021-11-30 14:08:42 -0600
commitc39d4f455d6663948c06c1f8186ab69b24ea0013 (patch)
treef07a683107c19099fe5b1d424df8e94f1ce19322 /tests/integration_tests
parent4bf4de25ea487ceb7005dc63d01f73fe56a13a16 (diff)
downloadvyos-cloud-init-c39d4f455d6663948c06c1f8186ab69b24ea0013.tar.gz
vyos-cloud-init-c39d4f455d6663948c06c1f8186ab69b24ea0013.zip
cc_ssh_authkey_fingerprints.py: prevent duplicate messages on console (#1081)
When cloud-init is configured to show SSH user key fingerprints during boot two of the same message appears for each user. This appears to be as the util.multi_log call defaults to send to both console directly and to stderr (which also goes to console). This change sends them only to console directly.
Diffstat (limited to 'tests/integration_tests')
-rw-r--r--tests/integration_tests/modules/test_keys_to_console.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/integration_tests/modules/test_keys_to_console.py b/tests/integration_tests/modules/test_keys_to_console.py
index 39e06b55..e79db3c7 100644
--- a/tests/integration_tests/modules/test_keys_to_console.py
+++ b/tests/integration_tests/modules/test_keys_to_console.py
@@ -23,6 +23,15 @@ ssh:
emit_keys_to_console: false
"""
+ENABLE_KEYS_TO_CONSOLE_USER_DATA = """\
+#cloud-config
+ssh:
+ emit_keys_to_console: true
+users:
+ - default
+ - name: barfoo
+"""
+
@pytest.mark.user_data(BLACKLIST_USER_DATA)
class TestKeysToConsoleBlacklist:
@@ -70,3 +79,32 @@ class TestKeysToConsoleDisabled:
def test_footer_excluded(self, class_client):
syslog = class_client.read_from_file("/var/log/syslog")
assert "END SSH HOST KEY FINGERPRINTS" not in syslog
+
+
+@pytest.mark.user_data(ENABLE_KEYS_TO_CONSOLE_USER_DATA)
+@pytest.mark.ec2
+@pytest.mark.lxd_container
+@pytest.mark.oci
+@pytest.mark.openstack
+class TestKeysToConsoleEnabled:
+ """Test that output can be enabled disabled."""
+
+ def test_duplicate_messaging_console_log(self, class_client):
+ class_client.execute('cloud-init status --wait --long').ok
+ try:
+ console_log = class_client.instance.console_log()
+ except NotImplementedError:
+ # Assume that an exception here means that we can't use the console
+ # log
+ pytest.skip("NotImplementedError when requesting console log")
+ return
+ if console_log.lower() == 'no console output':
+ # This test retries because we might not have the full console log
+ # on the first fetch. However, if we have no console output
+ # at all, we don't want to keep retrying as that would trigger
+ # another 5 minute wait on the pycloudlib side, which could
+ # leave us waiting for a couple hours
+ pytest.fail('no console output')
+ return
+ msg = "no authorized SSH keys fingerprints found for user barfoo."
+ assert 1 == console_log.count(msg)