Skip to content

Commit 6c673ad

Browse files
committed
Update test cases for update_firewall_lists_test
1 parent f3f94a4 commit 6c673ad

1 file changed

Lines changed: 23 additions & 18 deletions

File tree

aikido_zen/background_process/cloud_connection_manager/update_firewall_lists_test.py

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
CloudConnectionManager,
66
)
77
from .update_firewall_lists import update_firewall_lists
8-
from ...helpers.is_ip_allowed_by_allowlist import is_ip_allowed_by_allowlist
98

109

1110
class MockApi:
@@ -93,17 +92,19 @@ def test_update_firewall_lists_success(connection_manager):
9392
update_firewall_lists(connection_manager)
9493

9594
# Check that the blocked IPs were set correctly
96-
assert connection_manager.conf.is_blocked_ip("192.168.1.1")
97-
assert connection_manager.conf.is_blocked_ip("192.168.1.2")
95+
assert connection_manager.firewall_lists.is_blocked_ip("192.168.1.1")
96+
assert connection_manager.firewall_lists.is_blocked_ip("192.168.1.2")
9897

9998
# Check that the allowed IPs were set correctly
100-
assert is_ip_allowed_by_allowlist(connection_manager.conf, "192.168.1.3")
101-
assert is_ip_allowed_by_allowlist(connection_manager.conf, "192.168.2.50")
99+
assert connection_manager.firewall_lists.is_allowed_ip("192.168.1.3")
100+
assert connection_manager.firewall_lists.is_allowed_ip("192.168.2.50")
102101

103102
# Check that the blocked user agents were set correctly
104-
assert connection_manager.conf.is_user_agent_blocked("bAdBoT test woop wop")
105-
assert not connection_manager.conf.is_user_agent_blocked("")
106-
assert not connection_manager.conf.is_user_agent_blocked(None)
103+
assert connection_manager.firewall_lists.is_user_agent_blocked(
104+
"bAdBoT test woop wop"
105+
)
106+
assert not connection_manager.firewall_lists.is_user_agent_blocked("")
107+
assert not connection_manager.firewall_lists.is_user_agent_blocked(None)
107108

108109

109110
def test_update_firewall_lists_no_ua(connection_manager):
@@ -112,13 +113,15 @@ def test_update_firewall_lists_no_ua(connection_manager):
112113
update_firewall_lists(connection_manager)
113114

114115
# Check that the blocked IPs were set correctly
115-
assert connection_manager.conf.is_blocked_ip("192.168.1.1")
116-
assert connection_manager.conf.is_blocked_ip("192.168.1.2")
116+
assert connection_manager.firewall_lists.is_blocked_ip("192.168.1.1")
117+
assert connection_manager.firewall_lists.is_blocked_ip("192.168.1.2")
117118

118119
# Check that the blocked user agents were set correctly
119-
assert not connection_manager.conf.is_user_agent_blocked("bAdBoT test woop wop")
120-
assert not connection_manager.conf.is_user_agent_blocked("")
121-
assert connection_manager.conf.blocked_user_agent_regex is None
120+
assert not connection_manager.firewall_lists.is_user_agent_blocked(
121+
"bAdBoT test woop wop"
122+
)
123+
assert not connection_manager.firewall_lists.is_user_agent_blocked("")
124+
assert connection_manager.firewall_lists.blocked_user_agent_regex is None
122125

123126

124127
def test_update_firewall_lists_invalid_regex(connection_manager):
@@ -127,13 +130,15 @@ def test_update_firewall_lists_invalid_regex(connection_manager):
127130
update_firewall_lists(connection_manager)
128131

129132
# Check that the blocked IPs were set correctly
130-
assert connection_manager.conf.is_blocked_ip("192.168.1.1")
131-
assert connection_manager.conf.is_blocked_ip("192.168.1.2")
133+
assert connection_manager.firewall_lists.is_blocked_ip("192.168.1.1")
134+
assert connection_manager.firewall_lists.is_blocked_ip("192.168.1.2")
132135

133136
# Check that the blocked user agents were set correctly
134-
assert not connection_manager.conf.is_user_agent_blocked("bAdBoT test woop wop")
135-
assert not connection_manager.conf.is_user_agent_blocked("")
136-
assert connection_manager.conf.blocked_user_agent_regex is None
137+
assert not connection_manager.firewall_lists.is_user_agent_blocked(
138+
"bAdBoT test woop wop"
139+
)
140+
assert not connection_manager.firewall_lists.is_user_agent_blocked("")
141+
assert connection_manager.firewall_lists.blocked_user_agent_regex is None
137142

138143

139144
def test_update_firewall_lists_no_token(connection_manager):

0 commit comments

Comments
 (0)