This commit is contained in:
@@ -43,6 +43,7 @@ def test_public_url_rejects_unsafe_or_unsupported_values(raw):
|
||||
with pytest.raises((ImproperlyConfigured, ConfigurationError)):
|
||||
normalize_public_base_url(raw)
|
||||
|
||||
|
||||
def test_configure_public_url_updates_only_public_security_settings(tmp_path: Path):
|
||||
env_file = tmp_path / ".env"
|
||||
env_file.write_text(
|
||||
@@ -66,20 +67,22 @@ def test_configure_public_url_updates_only_public_security_settings(tmp_path: Pa
|
||||
assert "DJANGO_DEBUG=0" in content
|
||||
assert "vacatureradar.itworx.tech" in content
|
||||
assert (
|
||||
"DJANGO_CSRF_TRUSTED_ORIGINS="
|
||||
"http://192.168.10.150:1226,https://vacatureradar.itworx.tech"
|
||||
"DJANGO_CSRF_TRUSTED_ORIGINS=http://192.168.10.150:1226,https://vacatureradar.itworx.tech"
|
||||
) in content
|
||||
assert "CACHE_URL=redis://127.0.0.1:6379/1" in content
|
||||
assert "TRUSTED_PROXY_CIDRS=172.18.0.0/16" in content
|
||||
assert "DJANGO_SECRET_KEY=keep-this-secret" in content
|
||||
assert "POSTGRES_PASSWORD=keep-this-password" in content
|
||||
assert env_file.stat().st_mode & 0o777 == 0o600
|
||||
if os.name != "nt":
|
||||
assert env_file.stat().st_mode & 0o777 == 0o600
|
||||
assert "DJANGO_SECRET_KEY" not in changed
|
||||
|
||||
|
||||
def test_configure_public_url_rejects_plain_http(tmp_path: Path):
|
||||
with pytest.raises(ConfigurationError, match="HTTPS"):
|
||||
configure_env(tmp_path / ".env", "http://vacatureradar.example.be")
|
||||
|
||||
|
||||
def test_public_base_url_populates_django_host_and_csrf_settings():
|
||||
environment = os.environ.copy()
|
||||
environment.update(
|
||||
@@ -91,7 +94,7 @@ def test_public_base_url_populates_django_host_and_csrf_settings():
|
||||
"SECURE_HSTS_SECONDS": "300",
|
||||
}
|
||||
)
|
||||
result = subprocess.run(
|
||||
result = subprocess.run( # noqa: S603 - fixed interpreter and static assertion program
|
||||
[
|
||||
sys.executable,
|
||||
"-c",
|
||||
@@ -111,9 +114,10 @@ def test_public_base_url_populates_django_host_and_csrf_settings():
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
) # noqa: S603 - fixed interpreter and static assertion program
|
||||
)
|
||||
assert result.returncode == 0, result.stderr
|
||||
|
||||
|
||||
def test_configure_public_url_is_idempotent(tmp_path: Path):
|
||||
env_file = tmp_path / ".env"
|
||||
env_file.write_text("DJANGO_ALLOWED_HOSTS=localhost\n", encoding="utf-8")
|
||||
|
||||
Reference in New Issue
Block a user