forked from Github-Mirrors/canaille
Avoid direct call to ldap in configuration unit tests
This commit is contained in:
parent
9393f0b98e
commit
2b0b5a5213
1 changed files with 3 additions and 9 deletions
|
@ -2,8 +2,7 @@ import smtplib
|
|||
import warnings
|
||||
from unittest import mock
|
||||
|
||||
import ldap
|
||||
from flask import g
|
||||
from canaille import create_app
|
||||
from flask_webtest import TestApp
|
||||
|
||||
|
||||
|
@ -186,20 +185,15 @@ def test_default_from_addr(testclient, user, smtpd):
|
|||
assert smtpd.messages[0]["From"] == '"Canaille" <admin@localhost>'
|
||||
|
||||
|
||||
def test_default_from_flask_server_name(app, user, smtpd, slapd_server):
|
||||
def test_default_from_flask_server_name(configuration, user, smtpd, slapd_server):
|
||||
app = create_app(configuration)
|
||||
del app.config["SMTP"]["FROM_ADDR"]
|
||||
app.config["SERVER_NAME"] = "foobar.tld"
|
||||
|
||||
with app.app_context():
|
||||
g.ldap_connection = ldap.ldapobject.SimpleLDAPObject(slapd_server.ldap_uri)
|
||||
g.ldap_connection.protocol_version = 3
|
||||
g.ldap_connection.simple_bind_s(slapd_server.root_dn, slapd_server.root_pw)
|
||||
|
||||
testclient = TestApp(app)
|
||||
res = testclient.get("/reset", status=200)
|
||||
res.form["login"] = "user"
|
||||
res = res.form.submit(status=200)
|
||||
assert smtpd.messages[0]["X-MailFrom"] == "admin@foobar.tld"
|
||||
assert smtpd.messages[0]["From"] == '"Canaille" <admin@foobar.tld>'
|
||||
|
||||
g.ldap_connection.unbind_s()
|
||||
|
|
Loading…
Reference in a new issue