33 lines
967 B
Python
33 lines
967 B
Python
import os
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
SCRIPT = Path(__file__).resolve().parents[1] / "scripts" / "deploy_docker.sh"
|
|
|
|
|
|
def test_invalid_public_port_is_rejected_before_contacting_docker():
|
|
result = subprocess.run(
|
|
["bash", str(SCRIPT)],
|
|
env={**os.environ, "DEPLOY_IMAGE": "test-image", "DEPLOY_PORT": "0"},
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
assert result.returncode == 2
|
|
assert "Invalid deployment port" in result.stdout
|
|
|
|
|
|
def test_invalid_container_name_and_bind_ip_cannot_be_used():
|
|
for configuration in (
|
|
{"DEPLOY_NAME": "other;service"},
|
|
{"DEPLOY_BIND_IP": "example.invalid"},
|
|
):
|
|
result = subprocess.run(
|
|
["bash", str(SCRIPT)],
|
|
env={**os.environ, "DEPLOY_IMAGE": "test-image", **configuration},
|
|
capture_output=True,
|
|
text=True,
|
|
check=False,
|
|
)
|
|
assert result.returncode == 2
|