diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2014-11-02 08:30:23 -0800 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2014-11-22 02:23:10 +0100 |
commit | 8d933a84c96859cbb782d5ac693f9badf2531947 (patch) | |
tree | eacd8afc8ebadddb2025a7a4f5306284d76de18c /auth/credentials/tests | |
parent | 21280da0d6a4e3c547de8f486fe6ae84eea3f135 (diff) | |
download | samba-8d933a84c96859cbb782d5ac693f9badf2531947.tar.gz |
credentials test: Use samba.tests.subunitrun.
Change-Id: I8970c66de9535cb8d48b17d88b2759b7d1e39cb8
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'auth/credentials/tests')
-rwxr-xr-x | auth/credentials/tests/bind.py | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/auth/credentials/tests/bind.py b/auth/credentials/tests/bind.py index ceb3e8ffb7c..91e493df7e7 100755 --- a/auth/credentials/tests/bind.py +++ b/auth/credentials/tests/bind.py @@ -5,24 +5,20 @@ import optparse import sys import base64 -import re -import os import copy import time sys.path.insert(0, "bin/python") import samba -samba.ensure_external_module("testtools", "testtools") -samba.ensure_external_module("subunit", "subunit/python") +from samba.tests.subunitrun import SubunitOptions, TestProgram import samba.getopt as options from ldb import SCOPE_BASE, SCOPE_SUBTREE from samba import gensec -import samba.tests, unittest +import samba.tests from samba.tests import delete_force -from subunit.run import SubunitTestRunner parser = optparse.OptionParser("ldap [options] <host>") sambaopts = options.SambaOptions(parser) @@ -31,6 +27,8 @@ parser.add_option_group(sambaopts) # use command line creds if available credopts = options.CredentialsOptions(parser) parser.add_option_group(credopts) +subunitopts = SubunitOptions(parser) +parser.add_option_group(subunitopts) opts, args = parser.parse_args() if len(args) < 1: @@ -53,8 +51,11 @@ class BindTests(samba.tests.TestCase): def setUp(self): super(BindTests, self).setUp() # fetch rootDSEs + + self.ldb = samba.tests.connect_samdb(host, credentials=creds, lp=lp, ldap_only=True) + if self.info_dc is None: - res = ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) + res = self.ldb.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) self.assertEquals(len(res), 1) BindTests.info_dc = res[0] # cache some of RootDSE props @@ -70,8 +71,8 @@ class BindTests(samba.tests.TestCase): def test_computer_account_bind(self): # create a computer acocount for the test - delete_force(ldb, self.computer_dn) - ldb.add_ldif(""" + delete_force(self.ldb, self.computer_dn) + self.ldb.add_ldif(""" dn: """ + self.computer_dn + """ cn: CENTOS53 displayName: CENTOS53$ @@ -89,7 +90,7 @@ dNSHostName: centos53.alabala.test operatingSystemVersion: 5.2 (3790) operatingSystem: Windows Server 2003 """) - ldb.modify_ldif(""" + self.ldb.modify_ldif(""" dn: """ + self.computer_dn + """ changetype: modify replace: unicodePwd @@ -106,8 +107,8 @@ unicodePwd:: """ + base64.b64encode("\"P@ssw0rd\"".encode('utf-16-le')) + """ def test_user_account_bind(self): # create user - ldb.newuser(username=self.username, password=self.password) - ldb_res = ldb.search(base=self.domain_dn, + self.ldb.newuser(username=self.username, password=self.password) + ldb_res = self.ldb.search(base=self.domain_dn, scope=SCOPE_SUBTREE, expression="(samAccountName=%s)" % self.username) self.assertEquals(len(ldb_res), 1) @@ -138,11 +139,4 @@ unicodePwd:: """ + base64.b64encode("\"P@ssw0rd\"".encode('utf-16-le')) + """ res = ldb_user3.search(base="", expression="", scope=SCOPE_BASE, attrs=["*"]) -ldb = samba.tests.connect_samdb(host, credentials=creds, lp=lp, ldap_only=True) - -runner = SubunitTestRunner() -rc = 0 -if not runner.run(unittest.makeSuite(BindTests)).wasSuccessful(): - rc = 1 - -sys.exit(rc) +TestProgram(module=__name__, opts=subunitopts) |