mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-23 00:25:18 +00:00
tests: Fix race condition bugs
This commit is contained in:
parent
71e77154d7
commit
8440cd840d
@ -143,18 +143,18 @@ def authenticate(optional=False):
|
|||||||
req.context["user"] = User.objects.get(user)
|
req.context["user"] = User.objects.get(user)
|
||||||
return func(resource, req, resp, *args, **kwargs)
|
return func(resource, req, resp, *args, **kwargs)
|
||||||
|
|
||||||
def wrapped(*args, **kwargs):
|
def wrapped(resource, req, resp, *args, **kwargs):
|
||||||
# If LDAP enabled and device is not Kerberos capable fall
|
# If LDAP enabled and device is not Kerberos capable fall
|
||||||
# back to LDAP bind authentication
|
# back to LDAP bind authentication
|
||||||
if "ldap" in config.AUTHENTICATION_BACKENDS:
|
if "ldap" in config.AUTHENTICATION_BACKENDS:
|
||||||
if "Android" in req.user_agent or "iPhone" in req.user_agent:
|
if "Android" in req.user_agent or "iPhone" in req.user_agent:
|
||||||
return ldap_authenticate(resource, req, resp, *args, **kwargs)
|
return ldap_authenticate(resource, req, resp, *args, **kwargs)
|
||||||
if "kerberos" in config.AUTHENTICATION_BACKENDS:
|
if "kerberos" in config.AUTHENTICATION_BACKENDS:
|
||||||
return kerberos_authenticate(*args, **kwargs)
|
return kerberos_authenticate(resource, req, resp, *args, **kwargs)
|
||||||
elif config.AUTHENTICATION_BACKENDS == {"pam"}:
|
elif config.AUTHENTICATION_BACKENDS == {"pam"}:
|
||||||
return pam_authenticate(*args, **kwargs)
|
return pam_authenticate(resource, req, resp, *args, **kwargs)
|
||||||
elif config.AUTHENTICATION_BACKENDS == {"ldap"}:
|
elif config.AUTHENTICATION_BACKENDS == {"ldap"}:
|
||||||
return ldap_authenticate(*args, **kwargs)
|
return ldap_authenticate(resource, req, resp, *args, **kwargs)
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError("Authentication backend %s not supported" % config.AUTHENTICATION_BACKENDS)
|
raise NotImplementedError("Authentication backend %s not supported" % config.AUTHENTICATION_BACKENDS)
|
||||||
return wrapped
|
return wrapped
|
||||||
|
@ -134,8 +134,6 @@ def clean_server():
|
|||||||
os.kill(int(fh.read()), 15)
|
os.kill(int(fh.read()), 15)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
if os.path.exists("/etc/krb5.conf"):
|
|
||||||
os.unlink("/etc/krb5.conf")
|
|
||||||
if os.path.exists("/etc/krb5.keytab"):
|
if os.path.exists("/etc/krb5.keytab"):
|
||||||
os.unlink("/etc/krb5.keytab")
|
os.unlink("/etc/krb5.keytab")
|
||||||
if os.path.exists("/etc/certidude/server.keytab"):
|
if os.path.exists("/etc/certidude/server.keytab"):
|
||||||
@ -171,6 +169,8 @@ def test_cli_setup_authority():
|
|||||||
os.system("samba-tool user setpassword administrator --newpassword=S4l4k4l4")
|
os.system("samba-tool user setpassword administrator --newpassword=S4l4k4l4")
|
||||||
os.symlink("/var/lib/samba/private/secrets.keytab", "/etc/krb5.keytab")
|
os.symlink("/var/lib/samba/private/secrets.keytab", "/etc/krb5.keytab")
|
||||||
os.chmod("/var/lib/samba/private/secrets.keytab", 0644) # To allow access to certidude server
|
os.chmod("/var/lib/samba/private/secrets.keytab", 0644) # To allow access to certidude server
|
||||||
|
if os.path.exists("/etc/krb5.conf"): # Remove the one from krb5-user package
|
||||||
|
os.unlink("/etc/krb5.conf")
|
||||||
os.symlink("/var/lib/samba/private/krb5.conf", "/etc/krb5.conf")
|
os.symlink("/var/lib/samba/private/krb5.conf", "/etc/krb5.conf")
|
||||||
with open("/etc/resolv.conf", "w") as fh:
|
with open("/etc/resolv.conf", "w") as fh:
|
||||||
fh.write("nameserver 127.0.0.1\nsearch example.lan\n")
|
fh.write("nameserver 127.0.0.1\nsearch example.lan\n")
|
||||||
|
Loading…
Reference in New Issue
Block a user