Skip to content

Commit

Permalink
fix: correct deprecated_version=22.2 for users.sudo
Browse files Browse the repository at this point in the history
Update test to reduce expected deprecation count when
below deprecation boundary. changed_version messages are still logged.
  • Loading branch information
blackboxsw committed Jul 2, 2024
1 parent b0d6c7d commit 0a7036e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cloudinit/distros/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def create_user(self, name, **kwargs):
util.deprecate(
deprecated=f"The value of 'false' in user {name}'s "
"'sudo' config",
deprecated_version="22.3",
deprecated_version="22.2",
extra_message="Use 'null' instead.",
)

Expand Down
9 changes: 7 additions & 2 deletions tests/integration_tests/modules/test_combined.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,23 @@ def test_deprecated_message(self, class_client: IntegrationInstance):
version_boundary = get_feature_flag_value(
class_client, "DEPRECATION_INFO_BOUNDARY"
)
# the deprecation_version is 22.2 in schema for apt_* keys in
# the changed_version is 22.2 in schema for user.sudo key in
# user-data. Pass 22.2 in against the client's version_boundary.
if should_log_deprecation("22.2", version_boundary):
log_level = "DEPRECATED"
deprecation_count = 2
else:
# Expect the distros deprecated call to be redacted.
# jsonschema still emits deprecation log due to changed_version
# instead of deprecated_version
log_level = "INFO"
deprecation_count = 1

assert (
f"[{log_level}]: The value of 'false' in user craig's 'sudo'"
" config is deprecated" in log
)
assert 2 == log.count("DEPRECATE")
assert deprecation_count == log.count("DEPRECATE")

def test_ntp_with_apt(self, class_client: IntegrationInstance):
"""LP #1628337.
Expand Down
6 changes: 3 additions & 3 deletions tests/unittests/distros/test_create_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ def test_explicit_sudo_false(self, m_subp, dist, caplog):
expected_levels = (
["WARNING", "DEPRECATED"]
if should_log_deprecation(
"22.3", features.DEPRECATION_INFO_BOUNDARY
"22.2", features.DEPRECATION_INFO_BOUNDARY
)
else ["INFO"]
)
assert caplog.records[1].levelname in expected_levels
assert (
"The value of 'false' in user foo_user's 'sudo' "
"config is deprecated in 22.3 and scheduled to be removed"
" in 27.3. Use 'null' instead."
"config is deprecated in 22.2 and scheduled to be removed"
" in 27.2. Use 'null' instead."
) in caplog.text

def test_explicit_sudo_none(self, m_subp, dist, caplog):
Expand Down

0 comments on commit 0a7036e

Please sign in to comment.