Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cloudinit/config/cc_ssh_authkey_fingerprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _pprint_key_entries(user, key_fn, key_entries, hash_meth='sha256',
if not key_entries:
message = ("%sno authorized SSH keys fingerprints found for user %s.\n"
% (prefix, user))
util.multi_log(message)
util.multi_log(message, console=True, stderr=False)
Comment thread
dermotbradley marked this conversation as resolved.
return
tbl_fields = ['Keytype', 'Fingerprint (%s)' % (hash_meth), 'Options',
'Comment']
Expand Down
38 changes: 38 additions & 0 deletions tests/integration_tests/modules/test_keys_to_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
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:
Expand Down Expand Up @@ -70,3 +79,32 @@ def test_header_excluded(self, class_client):
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)