1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-10 12:58:35 +03:00

credentials test: Use samba.tests.subunitrun.

Change-Id: I8970c66de9535cb8d48b17d88b2759b7d1e39cb8
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Jelmer Vernooij 2014-11-02 08:30:23 -08:00
parent 21280da0d6
commit 8d933a84c9
2 changed files with 15 additions and 21 deletions

View File

@ -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)

View File

@ -497,7 +497,7 @@ plantestsuite("samba4.blackbox.setpassword.py", "none", ["PYTHON=%s" % python, o
plantestsuite("samba4.blackbox.newuser.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_newuser.sh"), '$PREFIX/provision'])
plantestsuite("samba4.blackbox.group.py", "none", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_group.sh"), '$PREFIX/provision'])
plantestsuite("samba4.blackbox.spn.py(dc:local)", "dc:local", ["PYTHON=%s" % python, os.path.join(samba4srcdir, "setup/tests/blackbox_spn.sh"), '$PREFIX/dc'])
plantestsuite("samba4.ldap.bind(dc)", "dc", [python, os.path.join(srcdir(), "auth/credentials/tests/bind.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"'])
plantestsuite_loadlist("samba4.ldap.bind(dc)", "dc", [python, os.path.join(srcdir(), "auth/credentials/tests/bind.py"), '$SERVER', '-U"$USERNAME%$PASSWORD"', '$LOADLIST', '$LISTOPT'])
# This makes sure we test the rid allocation code
t = "rpc.samr.large-dc"