From 4004de7b7dec06e7ee0040f8a07c7f4fb967a4c1 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Thu, 29 Nov 2007 15:08:22 +0100 Subject: r26199: Allow constructing new sids, implement __eq__ for sids. (This used to be commit 87472e35c04fdf0c61c9133bab3c05bda11eba00) --- source4/libcli/security/security.i | 9 +++++++-- source4/libcli/security/tests/bindings.py | 12 +++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) (limited to 'source4/libcli') diff --git a/source4/libcli/security/security.i b/source4/libcli/security/security.i index cc5afb40c0..1f100b0b8f 100644 --- a/source4/libcli/security/security.i +++ b/source4/libcli/security/security.i @@ -84,7 +84,7 @@ typedef struct security_descriptor { NTSTATUS dacl_del(const struct security_ace *ace); NTSTATUS sacl_del(const struct security_ace *ace); #ifdef SWIGPYTHON - %rename(equal) __eq__; + %rename(__eq__) equal; #endif bool equal(const struct security_descriptor *other); } @@ -94,12 +94,17 @@ typedef struct security_descriptor { typedef struct dom_sid { %extend { - bool equal(const struct dom_sid *other); + dom_sid(TALLOC_CTX *mem_ctx, const char *text) { + return dom_sid_parse_talloc(mem_ctx, text); + } + ~dom_sid() { talloc_free($self); } #ifdef SWIGPYTHON const char *__str__(TALLOC_CTX *mem_ctx) { return dom_sid_string(mem_ctx, $self); } + %rename(__eq__) equal; #endif + bool equal(const struct dom_sid *other); } } dom_sid; diff --git a/source4/libcli/security/tests/bindings.py b/source4/libcli/security/tests/bindings.py index 15e2381a2b..59a5e69640 100644 --- a/source4/libcli/security/tests/bindings.py +++ b/source4/libcli/security/tests/bindings.py @@ -50,7 +50,17 @@ class SecurityDescriptorTests(unittest.TestCase): self.descriptor = security.SecurityDescriptor() -class RandomSidTests(unittest.TestCase): +class DomSidTests(unittest.TestCase): + def test_parse_sid(self): + sid = security.Sid("S-1-5-21") + self.assertEquals("S-1-5-21", str(sid)) + + def test_sid_equal(self): + sid1 = security.Sid("S-1-5-21") + sid2 = security.Sid("S-1-5-21") + self.assertTrue(sid1.__eq__(sid1)) + self.assertTrue(sid1.__eq__(sid2)) + def test_random(self): sid = security.random_sid() self.assertTrue(str(sid).startswith("S-1-5-21-")) -- cgit