mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
drs torture python: convert 'except X, (tuple)' to 'except X as e'
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
0de23d27d6
commit
9f61bf115e
@ -89,7 +89,8 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.ldb_dc1.delete(self.ou, ["tree_delete:1"])
|
||||
except ldb.LdbError as (enum, string):
|
||||
except ldb.LdbError as e:
|
||||
(enum, string) = e.args
|
||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||
pass
|
||||
super(DrsReplicaSyncTestCase, self).tearDown()
|
||||
@ -233,7 +234,8 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = self.drs.DsGetNCChanges(self.drs_handle, 8, req8)
|
||||
self.fail("Expected DsGetNCChanges to fail with WERR_DS_CANT_FIND_EXPECTED_NC")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e1:
|
||||
(enum, estr) = e1.args
|
||||
self.assertEquals(enum, werror.WERR_DS_CANT_FIND_EXPECTED_NC)
|
||||
|
||||
def test_link_utdv_hwm(self):
|
||||
@ -610,7 +612,8 @@ class DrsReplicaPrefixMapTestCase(drs_base.DrsBaseTestCase):
|
||||
super(DrsReplicaPrefixMapTestCase, self).tearDown()
|
||||
try:
|
||||
self.ldb_dc1.delete(self.ou, ["tree_delete:1"])
|
||||
except ldb.LdbError as (enum, string):
|
||||
except ldb.LdbError as e2:
|
||||
(enum, string) = e2.args
|
||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||
pass
|
||||
|
||||
@ -661,7 +664,8 @@ class DrsReplicaPrefixMapTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = drs.DsGetNCChanges(drs_handle, 8, req8)
|
||||
self.fail("Invalid attid (99999) should have triggered an error")
|
||||
except RuntimeError as (ecode, emsg):
|
||||
except RuntimeError as e3:
|
||||
(ecode, emsg) = e3.args
|
||||
self.assertEqual(ecode, 0x000020E2, "Error code should have been "
|
||||
"WERR_DS_DRA_SCHEMA_MISMATCH")
|
||||
|
||||
@ -950,7 +954,8 @@ class DrsReplicaSyncSortTestCase(drs_base.DrsBaseTestCase):
|
||||
# tidyup groups and users
|
||||
try:
|
||||
self.ldb_dc1.delete(self.ou, ["tree_delete:1"])
|
||||
except ldb.LdbError as (enum, string):
|
||||
except ldb.LdbError as e4:
|
||||
(enum, string) = e4.args
|
||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||
pass
|
||||
|
||||
|
@ -89,7 +89,8 @@ class DrsReplicaSyncUnprivTestCase(drs_base.DrsBaseTestCase):
|
||||
self.sd_utils.modify_sd_on_dn(self.base_dn, self.desc_sddl)
|
||||
try:
|
||||
self.ldb_dc1.delete(self.ou, ["tree_delete:1"])
|
||||
except ldb.LdbError as (enum, string):
|
||||
except ldb.LdbError as e1:
|
||||
(enum, string) = e1.args
|
||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||
pass
|
||||
super(DrsReplicaSyncUnprivTestCase, self).tearDown()
|
||||
@ -117,7 +118,8 @@ class DrsReplicaSyncUnprivTestCase(drs_base.DrsBaseTestCase):
|
||||
(level, ctr) = self.user_drs.DsGetNCChanges(self.user_drs_handle,
|
||||
8, req8)
|
||||
self.fail("Should have failed with user denied access")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e:
|
||||
(enum, estr) = e.args
|
||||
self.assertTrue(enum in expected_error,
|
||||
"Got unexpected error: %s" % estr)
|
||||
|
||||
|
@ -63,7 +63,8 @@ class DrsReplicaSyncIntegrityTestCase(drs_base.DrsBaseTestCase):
|
||||
# tidyup groups and users
|
||||
try:
|
||||
self.ldb_dc2.delete(self.ou, ["tree_delete:1"])
|
||||
except ldb.LdbError as (enum, string):
|
||||
except ldb.LdbError as e:
|
||||
(enum, string) = e.args
|
||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||
pass
|
||||
|
||||
|
@ -89,7 +89,8 @@ class DrsMoveObjectTestCase(drs_base.DrsBaseTestCase):
|
||||
def tearDown(self):
|
||||
try:
|
||||
self.ldb_dc1.delete(self.ou1_dn, ["tree_delete:1"])
|
||||
except ldb.LdbError as (enum, string):
|
||||
except ldb.LdbError as e:
|
||||
(enum, string) = e.args
|
||||
if enum == ldb.ERR_NO_SUCH_OBJECT:
|
||||
pass
|
||||
|
||||
|
@ -199,14 +199,16 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = self.rodc_drs.DsGetNCChanges(self.rodc_drs_handle, 10, req10)
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e:
|
||||
(enum, estr) = e.args
|
||||
self.assertEquals(enum, 8630) # ERROR_DS_DRA_SECRETS_DENIED
|
||||
|
||||
# send the same request again and we should get the same response
|
||||
try:
|
||||
(level, ctr) = self.rodc_drs.DsGetNCChanges(self.rodc_drs_handle, 10, req10)
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e1:
|
||||
(enum, estr) = e1.args
|
||||
self.assertEquals(enum, 8630) # ERROR_DS_DRA_SECRETS_DENIED
|
||||
|
||||
# Retry with Administrator credentials, ignores password replication groups
|
||||
@ -245,7 +247,8 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
|
||||
(level, ctr) = self.rodc_drs.DsGetNCChanges(self.rodc_drs_handle, 8, req8)
|
||||
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except RuntimeError as (enum, estr):
|
||||
except RuntimeError as e2:
|
||||
(enum, estr) = e2.args
|
||||
pass
|
||||
|
||||
def test_msDSRevealedUsers_admin(self):
|
||||
@ -506,7 +509,8 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = self.rodc_drs.DsGetNCChanges(self.rodc_drs_handle, 10, req10)
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e3:
|
||||
(enum, estr) = e3.args
|
||||
self.assertEquals(enum, 8630) # ERROR_DS_DRA_SECRETS_DENIED
|
||||
|
||||
req10 = self._getnc_req10(dest_dsa=str(self.rodc_ctx.ntds_guid),
|
||||
@ -520,7 +524,8 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = other_rodc_drs.DsGetNCChanges(other_rodc_drs_handle, 10, req10)
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e4:
|
||||
(enum, estr) = e4.args
|
||||
self.assertEquals(enum, 8630) # ERROR_DS_DRA_SECRETS_DENIED
|
||||
|
||||
def test_msDSRevealedUsers_local_deny_allow(self):
|
||||
@ -589,7 +594,8 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = self.rodc_drs.DsGetNCChanges(self.rodc_drs_handle, 10, req10)
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e5:
|
||||
(enum, estr) = e5.args
|
||||
self.assertEquals(enum, 8630) # ERROR_DS_DRA_SECRETS_DENIED
|
||||
|
||||
m = ldb.Message()
|
||||
@ -605,7 +611,8 @@ class DrsRodcTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
(level, ctr) = self.rodc_drs.DsGetNCChanges(self.rodc_drs_handle, 10, req10)
|
||||
self.fail("Successfully replicated secrets to an RODC that shouldn't have been replicated.")
|
||||
except WERRORError as (enum, estr):
|
||||
except WERRORError as e6:
|
||||
(enum, estr) = e6.args
|
||||
self.assertEquals(enum, 8630) # ERROR_DS_DRA_SECRETS_DENIED
|
||||
|
||||
def _assert_in_revealed_users(self, user_dn, attrlist):
|
||||
|
@ -132,7 +132,8 @@ class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase):
|
||||
# add it to the Schema
|
||||
try:
|
||||
ldb_ctx.add(rec)
|
||||
except LdbError, (enum, estr):
|
||||
except LdbError as e:
|
||||
(enum, estr) = e.args
|
||||
self.fail("Adding record failed with %d/%s" % (enum, estr))
|
||||
|
||||
self._ldap_schemaUpdateNow(ldb_ctx)
|
||||
@ -170,7 +171,8 @@ class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase):
|
||||
res_dc2 = self.ldb_dc2.search(base=obj_dn,
|
||||
scope=SCOPE_BASE,
|
||||
attrs=["*"])
|
||||
except LdbError, (enum, estr):
|
||||
except LdbError as e1:
|
||||
(enum, estr) = e1.args
|
||||
if enum == ERR_NO_SUCH_OBJECT:
|
||||
self.fail("%s doesn't exists on %s" % (obj_dn, self.dnsname_dc2))
|
||||
raise
|
||||
@ -439,7 +441,8 @@ class DrsReplSchemaTestCase(drs_base.DrsBaseTestCase):
|
||||
c_dn.get_component_value(0) + "-NEW")
|
||||
try:
|
||||
self.ldb_dc1.rename(c_dn, c_dn_new)
|
||||
except LdbError, (num, _):
|
||||
except LdbError as e2:
|
||||
(num, _) = e2.args
|
||||
self.fail("failed to change CN for %s: %s" % (c_dn, _))
|
||||
|
||||
# force replication from DC1 to DC2
|
||||
|
@ -62,11 +62,13 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
|
||||
if guid is not None:
|
||||
try:
|
||||
self.ldb_dc2.delete('<GUID=%s>' % guid, ["tree_delete:1"])
|
||||
except LdbError, (num, _):
|
||||
except LdbError as e:
|
||||
(num, _) = e.args
|
||||
self.assertEquals(num, ERR_NO_SUCH_OBJECT)
|
||||
try:
|
||||
self.ldb_dc1.delete('<GUID=%s>' % guid, ["tree_delete:1"])
|
||||
except LdbError, (num, _):
|
||||
except LdbError as e1:
|
||||
(num, _) = e1.args
|
||||
self.assertEquals(num, ERR_NO_SUCH_OBJECT)
|
||||
|
||||
def test_ReplEnabled(self):
|
||||
|
@ -217,7 +217,8 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
|
||||
try:
|
||||
# ldb_dc1 is now RID MASTER (as VAMPIREDC)
|
||||
ldb_dc1.modify(m)
|
||||
except ldb.LdbError, (num, msg):
|
||||
except ldb.LdbError as e1:
|
||||
(num, msg) = e1.args
|
||||
self.fail("Failed to reassign RID Master " + msg)
|
||||
|
||||
try:
|
||||
@ -257,7 +258,8 @@ class DrsReplicaSyncTestCase(drs_base.DrsBaseTestCase):
|
||||
m["becomeRidMaster"] = ldb.MessageElement("1", ldb.FLAG_MOD_REPLACE, "becomeRidMaster")
|
||||
try:
|
||||
ldb_dc2.modify(m)
|
||||
except ldb.LdbError, (num, msg):
|
||||
except ldb.LdbError as e:
|
||||
(num, msg) = e.args
|
||||
self.fail("Failed to restore RID Master " + msg)
|
||||
|
||||
def test_offline_samba_tool_seized_ridalloc(self):
|
||||
|
Loading…
Reference in New Issue
Block a user