You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
737 B
20 lines
737 B
from unittest.mock import patch |
|
|
|
import pytest |
|
from django.db import OperationalError, connection |
|
|
|
|
|
@pytest.mark.django_db |
|
def test_health_checks_postgresql(client): |
|
assert connection.vendor == "postgresql" |
|
response = client.get("/health/") |
|
assert response.status_code == 200 |
|
assert response.json() == {"status": "ok"} |
|
|
|
|
|
def test_health_failure_does_not_disclose_connection_details(client): |
|
with patch("django.db.backends.postgresql.base.DatabaseWrapper.cursor", side_effect=OperationalError("private-host secret-password")): |
|
response = client.get("/health/") |
|
assert response.status_code == 503 |
|
assert response.json() == {"status": "unavailable"} |
|
assert b"secret-password" not in response.content
|
|
|