forked from Github-Mirrors/canaille
Test refactoring
This commit is contained in:
parent
345044e7b9
commit
d976d47b1a
5 changed files with 25 additions and 16 deletions
|
@ -236,7 +236,8 @@ def user(app, slapd_connection):
|
|||
userPassword="{SSHA}fw9DYeF/gHTHuVMepsQzVYAkffGcU8Fz",
|
||||
)
|
||||
u.save(slapd_connection)
|
||||
return u
|
||||
yield u
|
||||
u.delete(slapd_connection)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -252,7 +253,8 @@ def admin(app, slapd_connection):
|
|||
userPassword="{SSHA}Vmgh2jkD0idX3eZHf8RzGos31oerjGiU",
|
||||
)
|
||||
u.save(slapd_connection)
|
||||
return u
|
||||
yield u
|
||||
u.delete(slapd_connection)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -268,7 +270,8 @@ def moderator(app, slapd_connection):
|
|||
userPassword="{SSHA}+eHyxWqajMHsOWnhONC2vbtfNZzKTkag",
|
||||
)
|
||||
u.save(slapd_connection)
|
||||
return u
|
||||
yield u
|
||||
u.delete(slapd_connection)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -327,14 +330,3 @@ def bar_group(app, admin, slapd_connection):
|
|||
@pytest.fixture
|
||||
def jpeg_photo():
|
||||
return b"\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x01,\x01,\x00\x00\xff\xfe\x00\x13Created with GIMP\xff\xe2\x02\xb0ICC_PROFILE\x00\x01\x01\x00\x00\x02\xa0lcms\x040\x00\x00mntrRGB XYZ \x07\xe5\x00\x0c\x00\x08\x00\x0f\x00\x16\x00(acspAPPL\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf6\xd6\x00\x01\x00\x00\x00\x00\xd3-lcms\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\rdesc\x00\x00\x01 \x00\x00\x00@cprt\x00\x00\x01`\x00\x00\x006wtpt\x00\x00\x01\x98\x00\x00\x00\x14chad\x00\x00\x01\xac\x00\x00\x00,rXYZ\x00\x00\x01\xd8\x00\x00\x00\x14bXYZ\x00\x00\x01\xec\x00\x00\x00\x14gXYZ\x00\x00\x02\x00\x00\x00\x00\x14rTRC\x00\x00\x02\x14\x00\x00\x00 gTRC\x00\x00\x02\x14\x00\x00\x00 bTRC\x00\x00\x02\x14\x00\x00\x00 chrm\x00\x00\x024\x00\x00\x00$dmnd\x00\x00\x02X\x00\x00\x00$dmdd\x00\x00\x02|\x00\x00\x00$mluc\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0cenUS\x00\x00\x00$\x00\x00\x00\x1c\x00G\x00I\x00M\x00P\x00 \x00b\x00u\x00i\x00l\x00t\x00-\x00i\x00n\x00 \x00s\x00R\x00G\x00Bmluc\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0cenUS\x00\x00\x00\x1a\x00\x00\x00\x1c\x00P\x00u\x00b\x00l\x00i\x00c\x00 \x00D\x00o\x00m\x00a\x00i\x00n\x00\x00XYZ \x00\x00\x00\x00\x00\x00\xf6\xd6\x00\x01\x00\x00\x00\x00\xd3-sf32\x00\x00\x00\x00\x00\x01\x0cB\x00\x00\x05\xde\xff\xff\xf3%\x00\x00\x07\x93\x00\x00\xfd\x90\xff\xff\xfb\xa1\xff\xff\xfd\xa2\x00\x00\x03\xdc\x00\x00\xc0nXYZ \x00\x00\x00\x00\x00\x00o\xa0\x00\x008\xf5\x00\x00\x03\x90XYZ \x00\x00\x00\x00\x00\x00$\x9f\x00\x00\x0f\x84\x00\x00\xb6\xc4XYZ \x00\x00\x00\x00\x00\x00b\x97\x00\x00\xb7\x87\x00\x00\x18\xd9para\x00\x00\x00\x00\x00\x03\x00\x00\x00\x02ff\x00\x00\xf2\xa7\x00\x00\rY\x00\x00\x13\xd0\x00\x00\n[chrm\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\xa3\xd7\x00\x00T|\x00\x00L\xcd\x00\x00\x99\x9a\x00\x00&g\x00\x00\x0f\\mluc\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0cenUS\x00\x00\x00\x08\x00\x00\x00\x1c\x00G\x00I\x00M\x00Pmluc\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x0cenUS\x00\x00\x00\x08\x00\x00\x00\x1c\x00s\x00R\x00G\x00B\xff\xdb\x00C\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xdb\x00C\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\xff\xc2\x00\x11\x08\x00\x01\x00\x01\x03\x01\x11\x00\x02\x11\x01\x03\x11\x01\xff\xc4\x00\x14\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\xff\xc4\x00\x14\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x0c\x03\x01\x00\x02\x10\x03\x10\x00\x00\x01\x7f\x0f\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x01\x00\x01\x05\x02\x7f\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x03\x01\x01?\x01\x7f\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x02\x01\x01?\x01\x7f\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x01\x00\x06?\x02\x7f\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x01\x00\x01?!\x7f\xff\xda\x00\x0c\x03\x01\x00\x02\x00\x03\x00\x00\x00\x10\x1f\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x03\x01\x01?\x10\x7f\xff\xc4\x00\x14\x11\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x02\x01\x01?\x10\x7f\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x01\x00\x01?\x10\x7f\xff\xd9"
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def cleanup_users_and_groups(slapd_connection):
|
||||
yield
|
||||
User.ldap_object_classes(slapd_connection)
|
||||
Group.ldap_object_classes(slapd_connection)
|
||||
for user in User.all(conn=slapd_connection):
|
||||
user.delete(conn=slapd_connection)
|
||||
for group in Group.all(conn=slapd_connection):
|
||||
group.delete(conn=slapd_connection)
|
||||
|
|
|
@ -25,6 +25,8 @@ def test_dn_when_leading_space_in_id_attribute(slapd_connection):
|
|||
assert ldap.dn.dn2str(ldap.dn.str2dn(user.dn)) == user.dn
|
||||
assert user.dn == "cn=Doe,ou=users,dc=slapd-test,dc=python-ldap,dc=org"
|
||||
|
||||
user.delete(slapd_connection)
|
||||
|
||||
|
||||
def test_dn_when_ldap_special_char_in_id_attribute(slapd_connection):
|
||||
User.initialize(slapd_connection)
|
||||
|
@ -40,3 +42,5 @@ def test_dn_when_ldap_special_char_in_id_attribute(slapd_connection):
|
|||
assert ldap.dn.is_dn(user.dn)
|
||||
assert ldap.dn.dn2str(ldap.dn.str2dn(user.dn)) == user.dn
|
||||
assert user.dn == "cn=\\#Doe,ou=users,dc=slapd-test,dc=python-ldap,dc=org"
|
||||
|
||||
user.delete(slapd_connection)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from canaille.ldap_backend.ldapobject import LDAPObject
|
||||
from canaille.models import User
|
||||
|
||||
|
||||
|
@ -80,6 +81,8 @@ def test_user_without_password_first_login(testclient, slapd_connection):
|
|||
|
||||
assert "First login" in res
|
||||
|
||||
u.delete(slapd_connection)
|
||||
|
||||
|
||||
def test_user_deleted_in_session(testclient, slapd_connection):
|
||||
User.ldap_object_classes(slapd_connection)
|
||||
|
@ -143,7 +146,9 @@ def test_wrong_login(testclient, slapd_connection, user):
|
|||
|
||||
|
||||
def test_admin_self_deletion(testclient, slapd_connection):
|
||||
User.ldap_object_classes(slapd_connection)
|
||||
LDAPObject.ldap_object_classes(slapd_connection)
|
||||
LDAPObject.ldap_object_attributes(slapd_connection)
|
||||
|
||||
admin = User(
|
||||
objectClass=["inetOrgPerson"],
|
||||
cn="Temp admin",
|
||||
|
@ -171,7 +176,9 @@ def test_admin_self_deletion(testclient, slapd_connection):
|
|||
|
||||
|
||||
def test_user_self_deletion(testclient, slapd_connection):
|
||||
User.ldap_object_classes(slapd_connection)
|
||||
LDAPObject.ldap_object_classes(slapd_connection)
|
||||
LDAPObject.ldap_object_attributes(slapd_connection)
|
||||
|
||||
user = User(
|
||||
objectClass=["inetOrgPerson"],
|
||||
cn="Temp user",
|
||||
|
|
|
@ -58,6 +58,8 @@ def test_set_groups_with_leading_space_in_user_id_attribute(
|
|||
foo_dns = {m.dn for m in foo_group.get_members(conn=slapd_connection)}
|
||||
assert user.dn not in foo_dns
|
||||
|
||||
user.delete(slapd_connection)
|
||||
|
||||
|
||||
def test_moderator_can_create_edit_and_delete_group(
|
||||
testclient, slapd_connection, logged_moderator, foo_group
|
||||
|
|
|
@ -372,6 +372,8 @@ def test_first_login_mail_button(smtpd, testclient, slapd_connection, logged_adm
|
|||
res = testclient.get("/profile/temp", status=200)
|
||||
assert "This user does not have a password yet" not in res
|
||||
|
||||
u.delete(slapd_connection)
|
||||
|
||||
|
||||
def test_email_reset_button(smtpd, testclient, slapd_connection, logged_admin):
|
||||
User.ldap_object_classes(slapd_connection)
|
||||
|
@ -397,6 +399,8 @@ def test_email_reset_button(smtpd, testclient, slapd_connection, logged_admin):
|
|||
assert "Send again" in res
|
||||
assert len(smtpd.messages) == 1
|
||||
|
||||
u.delete(slapd_connection)
|
||||
|
||||
|
||||
def test_photo_edition(
|
||||
testclient,
|
||||
|
|
Loading…
Reference in a new issue