Skip to content

Commit fc73391

Browse files
committed
Fix PyTest container test suite.
expected_code is by default 200, so remove duplicate information. Also start url with http:// Signed-off-by: Petr "Stone" Hracek <[email protected]>
1 parent 4032a4c commit fc73391

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

test/test_container_httpd.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ def test_dockerfiles(self, dockerfile):
5050
assert self.app.test_app_dockerfile()
5151
cip = self.app.get_cip()
5252
assert cip
53-
assert self.app.test_response(url=cip, expected_code=200, expected_output="Welcome to your static httpd application on OpenShift")
53+
assert self.app.test_response(
54+
url=f"http://{cip}",
55+
expected_output="Welcome to your static httpd application on OpenShift"
56+
)
5457

5558
@pytest.mark.parametrize(
5659
"mpm_config",
@@ -67,7 +70,7 @@ def test_mpm_config(self, mpm_config):
6770
# Let's check that server really response HTTP-403
6871
# See function here: in test/run `_run_mpm_config_test`
6972
# https://github.com/sclorg/httpd-container/blob/master/test/run#L97
70-
assert self.app.test_response(url=cip, port=8080, expected_code=403)
73+
assert self.app.test_response(url=f"http://{cip}", expected_code=403)
7174
logs = self.app.get_logs(cid_file_name=cid_name)
7275
assert re.search(f"mpm_{mpm_config}:notice.*resuming normal operations", logs)
7376

@@ -86,7 +89,7 @@ def test_log_to_data_volume(self):
8689
container_args=f"-e HTTPD_LOG_TO_VOLUME=1 --user 0 -v {data_dir}:/var/log/httpd"
8790
)
8891
cip = self.app.get_cip(cid_file_name="test_log_dir")
89-
assert self.app.test_response(url=cip, port=8080, expected_code=403)
92+
assert self.app.test_response(url=f"http://{cip}", expected_code=403)
9093
assert ContainerTestLibUtils.check_files_are_present(
9194
dir_name=data_dir, file_name_to_check=[
9295
"access_log",
@@ -113,4 +116,4 @@ def test_data_volume(self):
113116
)
114117
cip = self.app.get_cip(cid_file_name="doc_root")
115118
assert cip
116-
assert self.app.test_response(url=cip, port=8080, expected_code=200, expected_output="hello")
119+
assert self.app.test_response(url=f"http://{cip}", expected_output="hello")

test/test_container_httpd_s2i.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ def test_run_pre_init_test(self):
3939
cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name)
4040
assert cip
4141
assert self.s2i_app.test_response(
42-
url=cip,
43-
expected_code=200,
42+
url=f"http://{cip}",
4443
expected_output="This content was replaced by pre-init script."
4544
)
4645

@@ -59,8 +58,7 @@ def test_sample_app(self):
5958
assert cip
6059
response = "This is a sample s2i application with static content."
6160
assert self.s2i_app.test_response(
62-
url=cip,
63-
expected_code=200,
61+
url=f"http://{cip}",
6462
expected_output=response
6563
)
6664
assert self.s2i_app.test_response(
@@ -135,7 +133,7 @@ def test_self_cert_test(self):
135133
assert self.s2i_app.create_container(cid_file_name=self.s2i_app.app_name, container_args="--user 1000")
136134
cip = self.s2i_app.get_cip(cid_file_name=self.s2i_app.app_name)
137135
assert cip
138-
assert self.s2i_app.test_response(url=cip, expected_code=200, expected_output="SSL test works")
136+
assert self.s2i_app.test_response(url=f"http://{cip}", expected_output="SSL test works")
139137
assert self.s2i_app.test_response(url=f"https://{cip}", port=8443, expected_output="SSL test works")
140138
server_cmd = f"openssl s_client -showcerts -servername {cip} -connect {cip}:8443 2>/dev/null"
141139
server_output = ContainerTestLibUtils.run_command(cmd=server_cmd)

0 commit comments

Comments
 (0)