1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

s4:selftest: add a new test for "samba-tool user list"

This commit is contained in:
Michael Adam 2012-03-09 14:32:55 +01:00
parent e625a319e2
commit a85d86129a

View File

@ -19,7 +19,10 @@ import os
import time import time
import ldb import ldb
from samba.tests.samba_tool.base import SambaToolCmdTest from samba.tests.samba_tool.base import SambaToolCmdTest
from samba import nttime2unix from samba import (
nttime2unix,
dsdb
)
class UserCmdTestCase(SambaToolCmdTest): class UserCmdTestCase(SambaToolCmdTest):
"""Tests for samba-tool user subcommands""" """Tests for samba-tool user subcommands"""
@ -174,6 +177,29 @@ class UserCmdTestCase(SambaToolCmdTest):
self.assertWithin(expires, twodays, 5, "Ensure account expires is within 5 seconds of the expected time") self.assertWithin(expires, twodays, 5, "Ensure account expires is within 5 seconds of the expected time")
def test_list(self):
(result, out, err) = self.runsubcmd("user", "list",
"-H", "ldap://%s" % os.environ["DC_SERVER"],
"-U%s%%%s" % (os.environ["DC_USERNAME"],
os.environ["DC_PASSWORD"]))
self.assertCmdSuccess(result, "Error runing list")
search_filter = ("(&(objectClass=user)(userAccountControl:%s:=%u))" %
(ldb.OID_COMPARATOR_AND, dsdb.UF_NORMAL_ACCOUNT))
userlist = self.samdb.search(base=self.samdb.domain_dn(),
scope=ldb.SCOPE_SUBTREE,
expression=search_filter,
attrs=["samaccountname"])
self.assertTrue(len(userlist) > 0, "no users found in samdb")
for userobj in userlist:
name = userobj.get("samaccountname", idx=0)
found = self.assertMatch(out, name,
"user '%s' not found" % name)
def _randomUser(self, base={}): def _randomUser(self, base={}):
"""create a user with random attribute values, you can specify base attributes""" """create a user with random attribute values, you can specify base attributes"""
user = { user = {