Skip to content

Commit a86d7b6

Browse files
pre-commit-ci[bot]ciarams87
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 0d3abc1 commit a86d7b6

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

tests/suite/test_app_protect_watch_namespace_label.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ def test_responses(self, request, kube_apis, crd_ingress_controller_with_ap, bac
144144
"""
145145
Test file-block AppProtect policy with -watch-namespace-label
146146
"""
147-
patch_namespace_with_label(kube_apis.v1, backend_setup.test_namespace, "watch", f"{TEST_DATA}/common/ns-patch.yaml")
147+
patch_namespace_with_label(
148+
kube_apis.v1, backend_setup.test_namespace, "watch", f"{TEST_DATA}/common/ns-patch.yaml"
149+
)
148150
wait_before_test()
149151
print("------------- Run test for AP policy: file-block not enforced --------------")
150152
# The policy namespace does not have the watched label, show the policy is not enforced
@@ -163,18 +165,24 @@ def test_responses(self, request, kube_apis, crd_ingress_controller_with_ap, bac
163165
assert resp.status_code == 200
164166

165167
# Add the label to the policy namespace, show the policy is now enforced
166-
patch_namespace_with_label(kube_apis.v1, backend_setup.policy_namespace, "watch", f"{TEST_DATA}/common/ns-patch.yaml")
168+
patch_namespace_with_label(
169+
kube_apis.v1, backend_setup.policy_namespace, "watch", f"{TEST_DATA}/common/ns-patch.yaml"
170+
)
167171
wait_before_test(15)
168172
print("------------- Run test for AP policy: file-block is enforced now --------------")
169173
print(f"Request URL: {backend_setup.req_url} and Host: {backend_setup.ingress_host}")
170174

171175
ensure_response_from_backend(backend_setup.req_url, backend_setup.ingress_host, check404=True)
172176

173177
print("----------------------- Send request ----------------------")
174-
resp = requests.get(f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False)
178+
resp = requests.get(
179+
f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False
180+
)
175181
retry = 0
176182
while invalid_resp_body not in resp.text and retry <= 60:
177-
resp = requests.get(f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False)
183+
resp = requests.get(
184+
f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False
185+
)
178186
retry += 1
179187
wait_before_test(1)
180188
print(f"Policy not yet enforced, retrying... #{retry}")
@@ -183,18 +191,24 @@ def test_responses(self, request, kube_apis, crd_ingress_controller_with_ap, bac
183191
assert resp.status_code == 200
184192

185193
# Remove the label again fro the policy namespace, show the policy is not enforced again
186-
patch_namespace_with_label(kube_apis.v1, backend_setup.policy_namespace, "nowatch", f"{TEST_DATA}/common/ns-patch.yaml")
194+
patch_namespace_with_label(
195+
kube_apis.v1, backend_setup.policy_namespace, "nowatch", f"{TEST_DATA}/common/ns-patch.yaml"
196+
)
187197
wait_before_test(15)
188198
print("------------- Run test for AP policy: file-block not enforced again --------------")
189199
print(f"Request URL: {backend_setup.req_url} and Host: {backend_setup.ingress_host}")
190200

191201
ensure_response_from_backend(backend_setup.req_url, backend_setup.ingress_host, check404=True)
192202

193203
print("----------------------- Send request ----------------------")
194-
resp = requests.get(f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False)
204+
resp = requests.get(
205+
f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False
206+
)
195207
retry = 0
196208
while valid_resp_body not in resp.text and retry <= 60:
197-
resp = requests.get(f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False)
209+
resp = requests.get(
210+
f"{backend_setup.req_url}/test.bat", headers={"host": backend_setup.ingress_host}, verify=False
211+
)
198212
retry += 1
199213
wait_before_test(1)
200214
print(f"Policy not yet removed, retrying... #{retry}")

0 commit comments

Comments
 (0)