summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGary Lockyer <gary@catalyst.net.nz>2017-03-16 16:24:20 +1300
committerAndrew Bartlett <abartlet@samba.org>2017-03-29 02:37:25 +0200
commit41f1da3a1ae0335ad485118c14394b98b9890abe (patch)
treec7dcd13860b282a92757cf41b67df8e4e1c520d5 /python
parent76692faa9f991f7460a778fbaf7e5cd902a9608f (diff)
downloadsamba-41f1da3a1ae0335ad485118c14394b98b9890abe.tar.gz
TestBase: move insta_creds from password_lockout.py
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Diffstat (limited to 'python')
-rw-r--r--python/samba/tests/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/samba/tests/__init__.py b/python/samba/tests/__init__.py
index d6c8d863d2e..fb6f0b41dea 100644
--- a/python/samba/tests/__init__.py
+++ b/python/samba/tests/__init__.py
@@ -24,6 +24,7 @@ import samba
from samba import param
from samba import credentials
from samba.credentials import Credentials
+from samba import gensec
import socket
import struct
import subprocess
@@ -81,6 +82,36 @@ class TestCase(unittest.TestCase):
N += 16
return result
+ def insta_creds(self, template=None, username=None, userpass=None, kerberos_state=None):
+
+ if template is None:
+ assert template is not None
+
+ if username is not None:
+ assert userpass is not None
+
+ if username is None:
+ assert userpass is None
+
+ username = template.get_username()
+ userpass = template.get_password()
+
+ if kerberos_state is None:
+ kerberos_state = template.get_kerberos_state()
+
+ # get a copy of the global creds or a the passed in creds
+ c = Credentials()
+ c.set_username(username)
+ c.set_password(userpass)
+ c.set_domain(template.get_domain())
+ c.set_realm(template.get_realm())
+ c.set_workstation(template.get_workstation())
+ c.set_gensec_features(c.get_gensec_features())
+ c.set_kerberos_state(kerberos_state)
+ return c
+
+
+
# These functions didn't exist before Python2.7:
if sys.version_info < (2, 7):
import warnings