python/tests: Add tests for 64 bit signed integers
authorAndrew Bartlett <abartlet@samba.org>
Tue, 1 Sep 2015 02:58:20 +0000 (14:58 +1200)
committerStefan Metzmacher <metze@samba.org>
Tue, 1 Sep 2015 12:01:23 +0000 (14:01 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11429

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
python/samba/tests/dcerpc/integer.py

index 1a392ee6bea0b4de040297bed8d3396200a855cd..f4fa482d8367f1db92a1d9b9b5ee9465af48bd10 100644 (file)
@@ -17,7 +17,7 @@
 
 """Tests for integer handling in PIDL generated bindings samba.dcerpc.*"""
 
-from samba.dcerpc import server_id, misc, srvsvc
+from samba.dcerpc import server_id, misc, srvsvc, samr
 import samba.tests
 
 class IntegerTests(samba.tests.TestCase):
@@ -146,6 +146,32 @@ class IntegerTests(samba.tests.TestCase):
             g.time_mid = misc.SV_TYPE_DOMAIN_ENUM
         self.assertRaises(OverflowError, assign)
 
+    def test_hyper_into_int64(self):
+        s = samr.DomInfo1()
+        def assign():
+            s.max_password_age = server_id.SERVERID_UNIQUE_ID_NOT_TO_VERIFY
+        self.assertRaises(OverflowError, assign)
+
+    def test_int_into_int64(self):
+        s = samr.DomInfo1()
+        s.max_password_age = 5
+        self.assertEquals(s.max_password_age, 5)
+
+    def test_negative_int_into_int64(self):
+        s = samr.DomInfo1()
+        s.max_password_age = -5
+        self.assertEquals(s.max_password_age, -5)
+
+    def test_larger_int_into_int64(self):
+        s = samr.DomInfo1()
+        s.max_password_age = server_id.NONCLUSTER_VNN
+        self.assertEquals(s.max_password_age, 0xFFFFFFFFL)
+
+    def test_larger_negative_int_into_int64(self):
+        s = samr.DomInfo1()
+        s.max_password_age = -2147483649
+        self.assertEquals(s.max_password_age, -2147483649L)
+
     def test_int_list_over_list(self):
         g = misc.GUID()
         g.node = [5, 0, 5, 0, 7, 4]