Update of /cvsroot/pywin32/pywin32/win32/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17051/win32/test
Modified Files:
test_security.py
Log Message:
* setup.py now allows sources to be specified; win32security and win32net
now do so, making their .dsp files redundant.
* Existing win32security Ds* (DirectoryService) functions (not to be
confused with the COM related win32com.adsi module!) split into
new win32security_ds.cpp module.
* New win32security functions TranslateName, DsGetDcName and DsCrackNames
* Release the GIL when calling SSPI and DS functions.
* New Ds related constants in ntsecuritycon.
* New tests for these functions.
Index: test_security.py
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/test/test_security.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** test_security.py 23 Oct 2003 05:17:04 -0000 1.2
--- test_security.py 24 May 2005 13:55:30 -0000 1.3
***************
*** 2,6 ****
import unittest
! import win32api, win32con, win32security
class SecurityTests(unittest.TestCase):
--- 2,6 ----
import unittest
! import win32api, win32con, win32security, ntsecuritycon
class SecurityTests(unittest.TestCase):
***************
*** 31,34 ****
--- 31,77 ----
sd4.SetSecurityDescriptorSacl(1,sacl,0)
+ class TestDS(unittest.TestCase):
+ def testDsGetDcName(self):
+ # Not sure what we can actually test here! At least calling it
+ # does something :)
+ win32security.DsGetDcName()
+
+ def testDsCrackNames(self):
+ h = win32security.DsBind()
+ fmt_offered = ntsecuritycon.DS_FQDN_1779_NAME
+ name = win32api.GetUserNameEx(fmt_offered)
+ result = win32security.DsCrackNames(h, 0, fmt_offered, fmt_offered, (name,))
+ self.failUnlessEqual(name, result[0][2])
+
+ def testDsCrackNamesSyntax(self):
+ # Do a syntax check only - that allows us to avoid binding.
+ # But must use DS_CANONICAL_NAME (or _EX)
+ expected = win32api.GetUserNameEx(win32api.NameCanonical)
+ fmt_offered = ntsecuritycon.DS_FQDN_1779_NAME
+ name = win32api.GetUserNameEx(fmt_offered)
+ result = win32security.DsCrackNames(None, ntsecuritycon.DS_NAME_FLAG_SYNTACTICAL_ONLY,
+ fmt_offered, ntsecuritycon.DS_CANONICAL_NAME,
+ (name,))
+ self.failUnlessEqual(expected, result[0][2])
+
+ class TestTranslate(unittest.TestCase):
+ def _testTranslate(self, fmt_from, fmt_to):
+ name = win32api.GetUserNameEx(fmt_from)
+ expected = win32api.GetUserNameEx(fmt_to)
+ got = win32security.TranslateName(name, fmt_from, fmt_to)
+ self.failUnlessEqual(got, expected)
+
+ def testTranslate1(self):
+ self._testTranslate(win32api.NameFullyQualifiedDN, win32api.NameSamCompatible)
+
+ def testTranslate2(self):
+ self._testTranslate(win32api.NameSamCompatible, win32api.NameFullyQualifiedDN)
+
+ def testTranslate3(self):
+ self._testTranslate(win32api.NameFullyQualifiedDN, win32api.NameUniqueId)
+
+ def testTranslate4(self):
+ self._testTranslate(win32api.NameUniqueId, win32api.NameFullyQualifiedDN)
+
if __name__=='__main__':
unittest.main()
|