canaille-globuzma/tests/backends/ldap/test_errors.py

32 lines
902 B
Python
Raw Normal View History

2023-06-03 17:47:05 +00:00
import pytest
from flask_webtest import TestApp
from canaille import create_app
2023-06-03 17:47:05 +00:00
@pytest.fixture
def configuration(slapd_server, ldap_configuration):
yield ldap_configuration
def test_ldap_connection_remote_ldap_unreachable(configuration):
app = create_app(configuration)
testclient = TestApp(app)
app.config["CANAILLE_LDAP"]["URI"] = "ldap://invalid-ldap.com"
app.config["DEBUG"] = False
res = testclient.get("/", status=500, expect_errors=True)
res.mustcontain(no="Could not connect to the LDAP server")
def test_ldap_connection_remote_ldap_wrong_credentials(configuration):
app = create_app(configuration)
testclient = TestApp(app)
app.config["CANAILLE_LDAP"]["BIND_PW"] = "invalid-password"
app.config["DEBUG"] = False
res = testclient.get("/", status=500, expect_errors=True)
res.mustcontain(no="LDAP authentication failed with user")