Skip to content

Commit

Permalink
fix(ibm-classic): add missing whitespace in logging message
Browse files Browse the repository at this point in the history
Corrected a small typo in the IBM Classic logging call where a missing
whitespace was present between the port number and "to" in the log 
message.

Fixes: canonicalGH-455 (canonical#455)
  • Loading branch information
eddyoosthuizen authored Feb 4, 2025
1 parent 232fc39 commit 1022ad3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1!10.7.3
1!10.7.4
2 changes: 1 addition & 1 deletion pycloudlib/ibm_classic/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ def _add_rules_to_security_group(
port_max=port,
)
self._log.debug(
"Added rule allowing %s %s traffic on port %sto security group %s",
"Added rule allowing %s %s traffic on port %s to security group %s",
ethertype,
direction,
port,
Expand Down
26 changes: 25 additions & 1 deletion tests/unit_tests/ibm_classic/test_cloud.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import List
import mock
import pytest
import logging

from pycloudlib.errors import InvalidTagNameError
from pycloudlib.ibm_classic.cloud import IBMClassic
Expand Down Expand Up @@ -41,8 +42,16 @@ def mock_ibmclassic():
],
)
def test_add_rules_valid_input(
mock_ibmclassic, directions, ipv6, port, protocol, expected_call_count
mock_ibmclassic,
directions,
ipv6,
port,
protocol,
expected_call_count,
caplog,
):
mock_ibmclassic._log = logging.getLogger("ibm_classic_logger")
caplog.set_level(logging.DEBUG)
mock_ibmclassic._add_rules_to_security_group(
group_id="sg-1234",
directions=directions,
Expand All @@ -51,6 +60,21 @@ def test_add_rules_valid_input(
protocol=protocol,
)

expected_log_messages = []
ethertypes = ["IPv4", "IPv6"] if ipv6 else ["IPv4"]

for direction in directions:
for ethertype in ethertypes:
expected_log_messages.append(
f"Added rule allowing {ethertype} {direction} traffic on port {port} to security group sg-1234",
)

for expected_log in expected_log_messages:
assert any(
expected_log in message for message in caplog.messages
), f"Expected log not found: {expected_log}"

caplog.clear()
assert mock_ibmclassic._network_manager.add_securitygroup_rule.call_count == expected_call_count


Expand Down

0 comments on commit 1022ad3

Please sign in to comment.