summaryrefslogtreecommitdiff
path: root/python/samba/tests/auth_log.py
diff options
context:
space:
mode:
authorTim Beale <timbeale@catalyst.net.nz>2019-01-16 13:20:12 +1300
committerJeremy Allison <jra@samba.org>2019-01-17 01:40:31 +0100
commit914e9d359010361c7fcaae8f17ef6404d5c18805 (patch)
treee53e36a6e0559fbde9483187fd482fd705656a88 /python/samba/tests/auth_log.py
parente82e1b31e39631f6603be6d14debf79d2d9b16cd (diff)
downloadsamba-914e9d359010361c7fcaae8f17ef6404d5c18805.tar.gz
tests: Refactor auth_log SMB connection to be in a single place
This should not alter the behaviour of the tests at all. It just makes it easier to switch over the underlying SMB client bindings. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'python/samba/tests/auth_log.py')
-rw-r--r--python/samba/tests/auth_log.py62
1 files changed, 20 insertions, 42 deletions
diff --git a/python/samba/tests/auth_log.py b/python/samba/tests/auth_log.py
index 9c93589638e..e0738770f9f 100644
--- a/python/samba/tests/auth_log.py
+++ b/python/samba/tests/auth_log.py
@@ -47,6 +47,11 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
def tearDown(self):
super(AuthLogTests, self).tearDown()
+ def smb_connection(self, creds, use_spnego=True, ntlmv2_auth=True):
+ lp = self.get_loadparm()
+ return smb.SMB(self.server, "sysvol", lp=lp, creds=creds,
+ use_spnego=use_spnego, ntlmv2_auth=ntlmv2_auth)
+
def _test_rpc_ncacn_np(self, authTypes, creds, service,
binding, protection, checkFunction):
def isLastExpectedMessage(msg):
@@ -706,10 +711,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
msg["Authorization"]["transportProtection"] == "SMB")
creds = self.insta_creds(template=self.get_credentials())
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds)
+ self.smb_connection(creds)
messages = self.waitForMessages(isLastExpectedMessage)
self.assertEquals(3,
@@ -757,10 +759,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
thrown = False
try:
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds)
+ self.smb_connection(creds)
except NTSTATUSError:
thrown = True
self.assertEquals(thrown, True)
@@ -790,10 +789,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
thrown = False
try:
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds)
+ self.smb_connection(creds)
except NTSTATUSError:
thrown = True
self.assertEquals(thrown, True)
@@ -918,10 +914,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
creds = self.insta_creds(template=self.get_credentials(),
kerberos_state=DONT_USE_KERBEROS)
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds)
+ self.smb_connection(creds)
messages = self.waitForMessages(isLastExpectedMessage)
self.assertEquals(2,
@@ -961,10 +954,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
thrown = False
try:
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds)
+ self.smb_connection(creds)
except NTSTATUSError:
thrown = True
self.assertEquals(thrown, True)
@@ -993,10 +983,7 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
thrown = False
try:
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds)
+ self.smb_connection(creds)
except NTSTATUSError:
thrown = True
self.assertEquals(thrown, True)
@@ -1015,12 +1002,9 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
creds = self.insta_creds(template=self.get_credentials(),
kerberos_state=DONT_USE_KERBEROS)
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds,
- ntlmv2_auth=False,
- use_spnego=False)
+ self.smb_connection(creds,
+ ntlmv2_auth=False,
+ use_spnego=False)
messages = self.waitForMessages(isLastExpectedMessage)
self.assertEquals(2,
@@ -1060,12 +1044,9 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
thrown = False
try:
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds,
- ntlmv2_auth=False,
- use_spnego=False)
+ self.smb_connection(creds,
+ ntlmv2_auth=False,
+ use_spnego=False)
except NTSTATUSError:
thrown = True
self.assertEquals(thrown, True)
@@ -1094,12 +1075,9 @@ class AuthLogTests(samba.tests.auth_log_base.AuthLogTestBase):
thrown = False
try:
- smb.SMB(self.server,
- "sysvol",
- lp=self.get_loadparm(),
- creds=creds,
- ntlmv2_auth=False,
- use_spnego=False)
+ self.smb_connection(creds,
+ ntlmv2_auth=False,
+ use_spnego=False)
except NTSTATUSError:
thrown = True
self.assertEquals(thrown, True)