From: Gary Lockyer Date: Wed, 13 Feb 2019 01:34:06 +0000 (+1300) Subject: s2 decrpc samr: Add tests for QueryDomainInfo X-Git-Tag: ldb-1.6.1~137 X-Git-Url: http://git.samba.org/?p=samba.git;a=commitdiff_plain;h=f3fd2d9457920b3da3e0ce6c1c6ee77be6849c65 s2 decrpc samr: Add tests for QueryDomainInfo Add tests for the number of domain users, groups and aliases returned by QueryDomainInfo. These tests revealed that the existing code was not checking the returned elements to ensure they were part of the domain. Signed-off-by: Gary Lockyer Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/dcerpc/sam.py b/python/samba/tests/dcerpc/sam.py index ab710861383..4d787214b1d 100644 --- a/python/samba/tests/dcerpc/sam.py +++ b/python/samba/tests/dcerpc/sam.py @@ -20,6 +20,7 @@ """Tests for samba.dcerpc.sam.""" from samba.dcerpc import samr, security, lsa +from samba.dcerpc.samr import DomainGeneralInformation from samba.tests import RpcInterfaceTestCase from samba.tests import env_loadparm, delete_force @@ -748,3 +749,57 @@ class SamrTests(RpcInterfaceTestCase): check_results(expected, actual) self.delete_dns(dns) + + def test_DomGeneralInformation_num_users(self): + info = self.conn.QueryDomainInfo( + self.domain_handle, DomainGeneralInformation) + # + # Enumerate through all the domain users and compare the number + # returned against QueryDomainInfo they should be the same + max_size = calc_max_size(1) + (resume_handle, a, num_entries) = self.conn.EnumDomainUsers( + self.domain_handle, 0, 0, max_size) + count = num_entries + while resume_handle: + self.assertEquals(1, num_entries) + (resume_handle, a, num_entries) = self.conn.EnumDomainUsers( + self.domain_handle, resume_handle, 0, max_size) + count += num_entries + + self.assertEquals(count, info.num_users) + + def test_DomGeneralInformation_num_groups(self): + info = self.conn.QueryDomainInfo( + self.domain_handle, DomainGeneralInformation) + # + # Enumerate through all the domain groups and compare the number + # returned against QueryDomainInfo they should be the same + max_size = calc_max_size(1) + (resume_handle, a, num_entries) = self.conn.EnumDomainGroups( + self.domain_handle, 0, max_size) + count = num_entries + while resume_handle: + self.assertEquals(1, num_entries) + (resume_handle, a, num_entries) = self.conn.EnumDomainGroups( + self.domain_handle, resume_handle, max_size) + count += num_entries + + self.assertEquals(count, info.num_groups) + + def test_DomGeneralInformation_num_aliases(self): + info = self.conn.QueryDomainInfo( + self.domain_handle, DomainGeneralInformation) + # + # Enumerate through all the domain aliases and compare the number + # returned against QueryDomainInfo they should be the same + max_size = calc_max_size(1) + (resume_handle, a, num_entries) = self.conn.EnumDomainAliases( + self.domain_handle, 0, max_size) + count = num_entries + while resume_handle: + self.assertEquals(1, num_entries) + (resume_handle, a, num_entries) = self.conn.EnumDomainAliases( + self.domain_handle, resume_handle, max_size) + count += num_entries + + self.assertEquals(count, info.num_aliases) diff --git a/selftest/knownfail.d/dom_general_information b/selftest/knownfail.d/dom_general_information new file mode 100644 index 00000000000..6891e22faa2 --- /dev/null +++ b/selftest/knownfail.d/dom_general_information @@ -0,0 +1 @@ +^samba.tests.dcerpc.sam.samba.tests.dcerpc.sam.SamrTests.test_DomGeneralInformation_num_aliases