mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Remove unused variables in tests
This commit removes or marks unused variables as "expected to be unused" by using '_' prefix. Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
This commit is contained in:
parent
0f88f8fe88
commit
9d83be3647
@ -345,7 +345,7 @@ def validate_positional_substitutions(s, prog_langs, s_name='string'):
|
||||
|
||||
errors = []
|
||||
if n_fmts > 1:
|
||||
for i, fmt_parts in enumerate(fmts):
|
||||
for fmt_parts in fmts:
|
||||
fmt = fmt_parts['fmt']
|
||||
fmt_arg = fmt_parts['fmt_arg']
|
||||
width = fmt_parts['width']
|
||||
@ -543,7 +543,7 @@ def create_po(pot_file, po_file, mo_file):
|
||||
#
|
||||
# It is demanding the rhs of plural= only contains the identifer 'n'
|
||||
|
||||
for k,v in po.metadata.items():
|
||||
for k in po.metadata:
|
||||
if k.lower() == 'plural-forms':
|
||||
po.metadata[k] = 'nplurals=2; plural=(n != 1)'
|
||||
break
|
||||
|
@ -23,7 +23,6 @@
|
||||
def pytest_generate_tests(metafunc):
|
||||
"""Generates Declarative tests"""
|
||||
if 'declarative_test_definition' in metafunc.fixturenames:
|
||||
name = metafunc.cls.__name__
|
||||
tests = []
|
||||
descriptions = []
|
||||
for i, test in enumerate(metafunc.cls.tests):
|
||||
|
@ -141,6 +141,6 @@ def test_multiline_description():
|
||||
assert '\n\n' in unicode(api.Command.trust_add.doc).strip()
|
||||
|
||||
with CLITestContext(exception=SystemExit) as help_ctx:
|
||||
return_value = api.Backend.cli.run(['trust-add', '-h'])
|
||||
api.Backend.cli.run(['trust-add', '-h'])
|
||||
|
||||
assert unicode(api.Command.trust_add.doc).strip() in help_ctx.stdout
|
||||
|
@ -114,7 +114,7 @@ class test_ipagetkeytab(cmdline_test):
|
||||
self.keytabname)
|
||||
assert expected in result.error_output, (
|
||||
'Success message not in output:\n%s' % result.error_output)
|
||||
except ipautil.CalledProcessError as e:
|
||||
except ipautil.CalledProcessError:
|
||||
assert (False)
|
||||
|
||||
def test_3_use(self):
|
||||
|
@ -279,7 +279,7 @@ def domain_from_env(env, config, index, domain_type):
|
||||
env_suffix = '_env%s' % index
|
||||
|
||||
master_env = '%s%s' % (master_role, env_suffix)
|
||||
hostname, dot, domain_name = env[master_env].partition('.')
|
||||
hostname, _dot, domain_name = env[master_env].partition('.')
|
||||
domain = Domain(config, domain_name, domain_type)
|
||||
|
||||
for role in _roles_from_env(domain, env, env_suffix):
|
||||
|
@ -420,7 +420,7 @@ class TestComplexConfig(CheckConfig):
|
||||
def check_config(self, conf):
|
||||
assert len(conf.domains) == 3
|
||||
main_dom = conf.domains[0]
|
||||
(client1, client2, extra, extram1, extram2, master,
|
||||
(client1, client2, extra, extram1, extram2, _master,
|
||||
replica1, replica2) = sorted(main_dom.hosts, key=lambda h: h.role)
|
||||
assert main_dom.name == 'ipadomain.test'
|
||||
assert main_dom.type == 'IPA'
|
||||
|
@ -188,9 +188,8 @@ class TestTopologyOptions(IntegrationTest):
|
||||
returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas)
|
||||
assert returncode != 0, error1
|
||||
assert error.count(text) == 1, error2 % error
|
||||
newseg, err = tasks.create_segment(self.master,
|
||||
self.master,
|
||||
self.replicas[1])
|
||||
_newseg, err = tasks.create_segment(
|
||||
self.master, self.master, self.replicas[1])
|
||||
assert err == "", err
|
||||
returncode, error = tasks.destroy_segment(self.master, "%s-to-%s" % replicas)
|
||||
assert returncode == 0, error
|
||||
|
@ -189,7 +189,7 @@ class test_Executioner(ClassChecker):
|
||||
"""
|
||||
Test the `ipalib.backend.Executioner.execute` method.
|
||||
"""
|
||||
(api, home) = create_test_api(in_server=True)
|
||||
api, _home = create_test_api(in_server=True)
|
||||
|
||||
class echo(Command):
|
||||
takes_args = ('arg1', 'arg2+')
|
||||
|
@ -263,9 +263,9 @@ class test_NameSpace(ClassChecker):
|
||||
Test the `ipalib.base.NameSpace.__len__` method.
|
||||
"""
|
||||
for count in (5, 18, 127):
|
||||
(o, members) = self.new(count)
|
||||
o, _members = self.new(count)
|
||||
assert len(o) == count
|
||||
(o, members) = self.new(count, sort=False)
|
||||
o, _members = self.new(count, sort=False)
|
||||
assert len(o) == count
|
||||
|
||||
def test_iter(self):
|
||||
@ -353,7 +353,7 @@ class test_NameSpace(ClassChecker):
|
||||
"""
|
||||
for cnt in (0, 1, 2):
|
||||
for sort in (True, False):
|
||||
(o, members) = self.new(cnt, sort=sort)
|
||||
o, _members = self.new(cnt, sort=sort)
|
||||
if cnt == 1:
|
||||
assert repr(o) == \
|
||||
'NameSpace(<%d member>, sort=%r)' % (cnt, sort)
|
||||
|
@ -577,7 +577,7 @@ class test_Env(ClassChecker):
|
||||
Test the `ipalib.config.Env._finalize` method.
|
||||
"""
|
||||
# Check that calls cascade up the chain:
|
||||
(o, home) = self.new(in_tree=True)
|
||||
o, _home = self.new(in_tree=True)
|
||||
assert o._isdone('_bootstrap') is False
|
||||
assert o._isdone('_finalize_core') is False
|
||||
assert o._isdone('_finalize') is False
|
||||
@ -591,7 +591,7 @@ class test_Env(ClassChecker):
|
||||
assert str(e) == 'Env._finalize() already called'
|
||||
|
||||
# Check that _finalize() calls __lock__()
|
||||
(o, home) = self.new(in_tree=True)
|
||||
o, _home = self.new(in_tree=True)
|
||||
assert o.__islocked__() is False
|
||||
o._finalize()
|
||||
assert o.__islocked__() is True
|
||||
@ -599,7 +599,7 @@ class test_Env(ClassChecker):
|
||||
assert str(e) == 'Env.__lock__() already called'
|
||||
|
||||
# Check that **lastchance works
|
||||
(o, home) = self.finalize_core(None)
|
||||
o, _home = self.finalize_core(None)
|
||||
key = 'just_one_more_key'
|
||||
value = u'with one more value'
|
||||
lastchance = {key: value}
|
||||
|
@ -38,7 +38,7 @@ class CrudChecker(ClassChecker):
|
||||
"""
|
||||
Return a finalized `ipalib.plugable.API` instance.
|
||||
"""
|
||||
(api, home) = get_api()
|
||||
api, _home = get_api()
|
||||
class user(frontend.Object):
|
||||
takes_params = (
|
||||
'givenname',
|
||||
|
@ -243,7 +243,6 @@ class test_PublicError(PublicExceptionTester):
|
||||
def test_init(self):
|
||||
message = u'The translated, interpolated message'
|
||||
format = 'key=%(key1)r and key2=%(key2)r'
|
||||
uformat = u'Translated key=%(key1)r and key2=%(key2)r'
|
||||
val1 = u'Value 1'
|
||||
val2 = u'Value 2'
|
||||
kw = dict(key1=val1, key2=val2)
|
||||
@ -303,7 +302,6 @@ class test_PublicError(PublicExceptionTester):
|
||||
class subclass(self.klass):
|
||||
format = '%(true)r %(text)r %(number)r'
|
||||
|
||||
uformat = u'Translated %(true)r %(text)r %(number)r'
|
||||
kw = dict(true=True, text=u'Hello!', number=18)
|
||||
|
||||
# Test with format=str, message=None
|
||||
|
@ -103,14 +103,12 @@ def test_Registry():
|
||||
pass
|
||||
class Base2(object):
|
||||
pass
|
||||
class Base3(object):
|
||||
pass
|
||||
|
||||
|
||||
class plugin1(Base1):
|
||||
pass
|
||||
class plugin2(Base2):
|
||||
pass
|
||||
class plugin3(Base3):
|
||||
pass
|
||||
|
||||
# Test creation of Registry:
|
||||
r = plugable.Registry()
|
||||
@ -250,7 +248,7 @@ class test_API(ClassChecker):
|
||||
"""
|
||||
Test the `ipalib.plugable.API.bootstrap` method.
|
||||
"""
|
||||
(o, home) = create_test_api()
|
||||
o, _home = create_test_api()
|
||||
assert o.env._isdone('_bootstrap') is False
|
||||
assert o.env._isdone('_finalize_core') is False
|
||||
assert o.isdone('bootstrap') is False
|
||||
@ -266,7 +264,7 @@ class test_API(ClassChecker):
|
||||
"""
|
||||
Test the `ipalib.plugable.API.load_plugins` method.
|
||||
"""
|
||||
(o, home) = create_test_api()
|
||||
o, _home = create_test_api()
|
||||
assert o.isdone('bootstrap') is False
|
||||
assert o.isdone('load_plugins') is False
|
||||
o.load_plugins()
|
||||
|
@ -55,20 +55,20 @@ class test_x509(object):
|
||||
"""
|
||||
|
||||
# Load a good cert
|
||||
cert = x509.load_certificate(goodcert)
|
||||
x509.load_certificate(goodcert)
|
||||
|
||||
# Load a good cert with headers
|
||||
newcert = '-----BEGIN CERTIFICATE-----' + goodcert + '-----END CERTIFICATE-----'
|
||||
cert = x509.load_certificate(newcert)
|
||||
x509.load_certificate(newcert)
|
||||
|
||||
# Load a good cert with bad headers
|
||||
newcert = '-----BEGIN CERTIFICATE-----' + goodcert
|
||||
with pytest.raises((TypeError, ValueError)):
|
||||
cert = x509.load_certificate(newcert)
|
||||
x509.load_certificate(newcert)
|
||||
|
||||
# Load a bad cert
|
||||
with pytest.raises(NSPRError):
|
||||
cert = x509.load_certificate(badcert)
|
||||
x509.load_certificate(badcert)
|
||||
|
||||
def test_1_load_der_cert(self):
|
||||
"""
|
||||
@ -78,7 +78,7 @@ class test_x509(object):
|
||||
der = base64.b64decode(goodcert)
|
||||
|
||||
# Load a good cert
|
||||
cert = x509.load_certificate(der, x509.DER)
|
||||
x509.load_certificate(der, x509.DER)
|
||||
|
||||
def test_2_get_subject(self):
|
||||
"""
|
||||
|
@ -279,7 +279,7 @@ class TestInvalidAttributes(unittest.TestCase):
|
||||
# Invalid Max-Age
|
||||
s = 'color=blue; Max-Age=over-the-hill'
|
||||
with self.assertRaises(ValueError):
|
||||
cookies = Cookie.parse(s)
|
||||
Cookie.parse(s)
|
||||
|
||||
cookie = Cookie('color', 'blue')
|
||||
with self.assertRaises(ValueError):
|
||||
@ -288,7 +288,7 @@ class TestInvalidAttributes(unittest.TestCase):
|
||||
# Invalid Expires
|
||||
s = 'color=blue; Expires=Sun, 06 Xxx 1994 08:49:37 GMT'
|
||||
with self.assertRaises(ValueError):
|
||||
cookies = Cookie.parse(s)
|
||||
Cookie.parse(s)
|
||||
|
||||
cookie = Cookie('color', 'blue')
|
||||
with self.assertRaises(ValueError):
|
||||
|
@ -933,7 +933,7 @@ class TestDN(unittest.TestCase):
|
||||
dn3[1.0] # pylint: disable=pointless-statement
|
||||
|
||||
def test_assignments(self):
|
||||
dn = dn2 = DN('t=0,t=1,t=2,t=3,t=4,t=5,t=6,t=7,t=8,t=9')
|
||||
dn = DN('t=0,t=1,t=2,t=3,t=4,t=5,t=6,t=7,t=8,t=9')
|
||||
with self.assertRaises(TypeError):
|
||||
dn[0] = RDN('t=a')
|
||||
with self.assertRaises(TypeError):
|
||||
|
@ -183,7 +183,6 @@ class TestCIDict(object):
|
||||
self.cidict.keys(), self.cidict.values()))
|
||||
|
||||
def test_iter(self):
|
||||
items = []
|
||||
assert list(self.cidict) == list(self.cidict.keys())
|
||||
assert sorted(self.cidict) == sorted(['Key1', 'key2', 'KEY3'])
|
||||
|
||||
|
@ -111,7 +111,7 @@ class test_keyring(object):
|
||||
"""
|
||||
Read a non-existent key
|
||||
"""
|
||||
result = kernel_keyring.read_key(TEST_KEY)
|
||||
kernel_keyring.read_key(TEST_KEY)
|
||||
|
||||
def test_06(self):
|
||||
"""
|
||||
|
@ -102,7 +102,7 @@ class test_otptoken_import(object):
|
||||
def test_figure8(self):
|
||||
nss.nss_init_nodb()
|
||||
try:
|
||||
doc = PSKCDocument(os.path.join(basename, "pskc-figure8.xml"))
|
||||
PSKCDocument(os.path.join(basename, "pskc-figure8.xml"))
|
||||
except NotImplementedError: # X.509 is not supported.
|
||||
pass
|
||||
else:
|
||||
@ -113,7 +113,7 @@ class test_otptoken_import(object):
|
||||
def test_invalid(self):
|
||||
nss.nss_init_nodb()
|
||||
try:
|
||||
doc = PSKCDocument(os.path.join(basename, "pskc-invalid.xml"))
|
||||
PSKCDocument(os.path.join(basename, "pskc-invalid.xml"))
|
||||
except ValueError: # File is invalid.
|
||||
pass
|
||||
else:
|
||||
|
@ -111,7 +111,7 @@ class test_update(object):
|
||||
csr = self.read_file("test3.csr")
|
||||
|
||||
try:
|
||||
request = pkcs10.load_certificate_request(csr)
|
||||
pkcs10.load_certificate_request(csr)
|
||||
except NSPRError as nsprerr:
|
||||
# (SEC_ERROR_BAD_DER) security library: improperly formatted DER-encoded message.
|
||||
assert(nsprerr. errno== -8183)
|
||||
@ -122,6 +122,6 @@ class test_update(object):
|
||||
"""
|
||||
csr = self.read_file("test4.csr")
|
||||
try:
|
||||
request = pkcs10.load_certificate_request(csr)
|
||||
pkcs10.load_certificate_request(csr)
|
||||
except (TypeError, binascii.Error) as typeerr:
|
||||
assert(str(typeerr) == 'Incorrect padding')
|
||||
|
@ -134,7 +134,6 @@ class test_host(host_tasks):
|
||||
self.init_app()
|
||||
# ENHANCEMENT: generate csr dynamically
|
||||
csr = self.load_file(csr_path)
|
||||
realm = self.config.get('ipa_realm')
|
||||
cert_widget_sel = "div.certificate-widget"
|
||||
|
||||
self.add_record(ENTITY, self.data)
|
||||
@ -229,7 +228,6 @@ class test_host(host_tasks):
|
||||
|
||||
self.init_app()
|
||||
cert = self.load_file(cert_path)
|
||||
realm = self.config.get('ipa_realm')
|
||||
self.add_record(ENTITY, self.data)
|
||||
|
||||
self.navigate_to_record(self.pkey)
|
||||
|
@ -106,7 +106,6 @@ class test_idviews(UI_driver):
|
||||
|
||||
self.navigate_to_record(idview.PKEY)
|
||||
self.switch_to_facet(idview.HOST_FACET)
|
||||
parent_entity = 'idview'
|
||||
|
||||
# apply to host
|
||||
self.add_associations(
|
||||
|
@ -59,9 +59,6 @@ class test_range(range_tasks):
|
||||
|
||||
pkey_local = 'itest-local'
|
||||
pkey_ad = 'itest-ad'
|
||||
pkey_posix = 'itest-ad-posix'
|
||||
pkey_winsync = 'itest-ad-winsync'
|
||||
pkey_trust = 'itest-ipa-trust'
|
||||
column = 'iparangetype'
|
||||
|
||||
add = self.get_add_data(pkey_local)
|
||||
|
@ -93,8 +93,6 @@ class test_service(sevice_tasks):
|
||||
data = self.prep_data()
|
||||
pkey = data.get('pkey')
|
||||
csr = self.load_file(csr_path)
|
||||
host = self.config.get('ipa_server')
|
||||
realm = self.config.get('ipa_realm')
|
||||
cert_widget_sel = "div.certificate-widget"
|
||||
|
||||
self.add_record(ENTITY, data)
|
||||
@ -190,7 +188,6 @@ class test_service(sevice_tasks):
|
||||
data = self.prep_data()
|
||||
pkey = data.get('pkey')
|
||||
cert = self.load_file(cert_path)
|
||||
realm = self.config.get('ipa_realm')
|
||||
cert_widget_sel = "div.certificate-widget"
|
||||
|
||||
self.add_record(ENTITY, data)
|
||||
|
@ -190,7 +190,6 @@ class test_user(user_tasks):
|
||||
self.init_app()
|
||||
# ENHANCEMENT: generate csr dynamically
|
||||
csr = self.load_file(csr_path)
|
||||
realm = self.config.get('ipa_realm')
|
||||
cert_widget_sel = "div.certificate-widget"
|
||||
|
||||
self.add_record(user.ENTITY, user.DATA)
|
||||
|
@ -306,7 +306,7 @@ class UI_driver(object):
|
||||
"""
|
||||
runner = self
|
||||
|
||||
for i in range(n):
|
||||
for _i in range(n):
|
||||
self.wait(implicit)
|
||||
WebDriverWait(self.driver, self.request_timeout).until_not(lambda d: runner.has_active_request())
|
||||
self.wait()
|
||||
@ -1499,7 +1499,7 @@ class UI_driver(object):
|
||||
|
||||
# add values
|
||||
for t in tables:
|
||||
table, keys, exts = get_t_vals(t)
|
||||
table, keys, _exts = get_t_vals(t)
|
||||
# add one by one to test for #3711
|
||||
for key in keys:
|
||||
self.add_table_associations(table, [key])
|
||||
@ -1517,7 +1517,7 @@ class UI_driver(object):
|
||||
p = self.get_form()
|
||||
# now tables in categories should be empty, check it
|
||||
for t in tables:
|
||||
table, keys, exts = get_t_vals(t)
|
||||
table, keys, _exts = get_t_vals(t)
|
||||
if table in no_categories:
|
||||
# clear the rest
|
||||
self.delete_record(keys, None, p, table)
|
||||
@ -1534,7 +1534,7 @@ class UI_driver(object):
|
||||
self.assert_rule_tables_enabled(t_list, True)
|
||||
|
||||
for t in tables:
|
||||
table, keys, exts = get_t_vals(t)
|
||||
table, keys, _exts = get_t_vals(t)
|
||||
# add multiple at once and test table delete button
|
||||
self.add_table_associations(table, keys, delete=True)
|
||||
|
||||
@ -1678,7 +1678,7 @@ class UI_driver(object):
|
||||
"""
|
||||
if not parent:
|
||||
parent = self.get_form()
|
||||
el = self.find(selector, By.CSS_SELECTOR, parent, strict=True)
|
||||
self.find(selector, By.CSS_SELECTOR, parent, strict=True)
|
||||
dis = self.find(selector+"[disabled]", By.CSS_SELECTOR, parent)
|
||||
if negative:
|
||||
assert dis is None, "Element is disabled: %s" % selector
|
||||
|
@ -90,13 +90,13 @@ class CertManipCmdTestBase(XMLRPC_test):
|
||||
# list of certificates to add to entry
|
||||
cls.certs = [
|
||||
get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal)
|
||||
for i in range(3)
|
||||
for _i in range(3)
|
||||
]
|
||||
|
||||
# list of certificates for testing of removal of non-existent certs
|
||||
cls.nonexistent_certs = [
|
||||
get_testcert(DN(('CN', cls.entity_subject)), cls.entity_principal)
|
||||
for j in range(2)
|
||||
for _j in range(2)
|
||||
]
|
||||
|
||||
# cert subset to remove from entry
|
||||
|
@ -184,7 +184,8 @@ class test_automount(AutomountTest):
|
||||
"""
|
||||
Test adding a duplicate key using `xmlrpc.automountkey_add` method.
|
||||
"""
|
||||
res = api.Command['automountkey_add'](self.locname, self.mapname, **self.key_kw)
|
||||
api.Command['automountkey_add'](
|
||||
self.locname, self.mapname, **self.key_kw)
|
||||
|
||||
def test_5_automountmap_show(self):
|
||||
"""
|
||||
@ -368,7 +369,8 @@ class test_automount_direct(AutomountTest):
|
||||
"""
|
||||
Test adding a duplicate direct map.
|
||||
"""
|
||||
res = api.Command['automountmap_add_indirect'](self.locname, self.mapname, **self.direct_kw)['result']
|
||||
api.Command['automountmap_add_indirect'](
|
||||
self.locname, self.mapname, **self.direct_kw)
|
||||
|
||||
def test_2a_automountmap_tofiles(self):
|
||||
"""Test the `automountmap_tofiles` command"""
|
||||
|
@ -53,7 +53,8 @@ def test_exc_wrapper():
|
||||
# Test with one callback first
|
||||
|
||||
@test_callback.register_exc_callback
|
||||
def handle_exception(self, keys, options, e, call_func, *args, **kwargs):
|
||||
def handle_exception( # pylint: disable=unused-variable
|
||||
self, keys, options, e, call_func, *args, **kwargs):
|
||||
assert args == (1, 2)
|
||||
assert kwargs == dict(a=1, b=2)
|
||||
handled_exceptions.append(type(e))
|
||||
@ -150,7 +151,8 @@ def test_exc_callback_registration():
|
||||
pass
|
||||
|
||||
@callbacktest_subclass.register_exc_callback
|
||||
def exc_callback(self, keys, options, exc, call_func, *args, **kwargs):
|
||||
def exc_callback( # pylint: disable=unused-variable
|
||||
self, keys, options, exc, call_func, *args, **kwargs):
|
||||
"""Subclass's private exception callback"""
|
||||
messages.append('Subclass registered callback')
|
||||
raise exc
|
||||
@ -163,7 +165,8 @@ def test_exc_callback_registration():
|
||||
|
||||
|
||||
@callbacktest_base.register_exc_callback
|
||||
def exc_callback_2(self, keys, options, exc, call_func, *args, **kwargs):
|
||||
def exc_callback_2( # pylint: disable=unused-variable
|
||||
self, keys, options, exc, call_func, *args, **kwargs):
|
||||
"""Callback on super class; doesn't affect the subclass"""
|
||||
messages.append('Superclass registered callback')
|
||||
raise exc
|
||||
|
@ -141,11 +141,11 @@ class test_cert(XMLRPC_test):
|
||||
This should fail because the service principal doesn't exist
|
||||
"""
|
||||
# First create the host that will use this policy
|
||||
res = api.Command['host_add'](self.host_fqdn, force= True)['result']
|
||||
assert 'result' in api.Command['host_add'](self.host_fqdn, force=True)
|
||||
|
||||
csr = unicode(self.generateCSR(str(self.subject)))
|
||||
with assert_raises(errors.NotFound):
|
||||
res = api.Command['cert_request'](csr, principal=self.service_princ)
|
||||
api.Command['cert_request'](csr, principal=self.service_princ)
|
||||
|
||||
def test_0002_cert_add(self):
|
||||
"""
|
||||
@ -267,7 +267,7 @@ class test_cert_find(XMLRPC_test):
|
||||
"""
|
||||
Search for the OCSP certificate.
|
||||
"""
|
||||
res = api.Command['cert_find'](subject=u'OCSP Subsystem')
|
||||
api.Command['cert_find'](subject=u'OCSP Subsystem')
|
||||
|
||||
def test_0004_find_this_host(self):
|
||||
"""
|
||||
@ -458,7 +458,7 @@ class test_cert_find(XMLRPC_test):
|
||||
"""
|
||||
Search with a negative sizelimit
|
||||
"""
|
||||
res = api.Command['cert_find'](sizelimit=-100)
|
||||
api.Command['cert_find'](sizelimit=-100)
|
||||
|
||||
def test_0029_search_for_notfound(self):
|
||||
"""
|
||||
@ -479,4 +479,4 @@ class test_cert_find(XMLRPC_test):
|
||||
"""
|
||||
Search using invalid date format
|
||||
"""
|
||||
res = api.Command['cert_find'](issuedon_from=u'xyz')
|
||||
api.Command['cert_find'](issuedon_from=u'xyz')
|
||||
|
@ -268,7 +268,7 @@ class test_hbac(XMLRPC_test):
|
||||
"""
|
||||
Test deprecated command hbacrule_add_sourcehost.
|
||||
"""
|
||||
ret = api.Command['hbacrule_add_sourcehost'](
|
||||
api.Command['hbacrule_add_sourcehost'](
|
||||
self.rule_name, host=self.test_host, hostgroup=self.test_hostgroup
|
||||
)
|
||||
|
||||
@ -307,7 +307,7 @@ class test_hbac(XMLRPC_test):
|
||||
"""
|
||||
Test deprecated command hbacrule_remove_sourcehost.
|
||||
"""
|
||||
ret = api.Command['hbacrule_remove_sourcehost'](
|
||||
api.Command['hbacrule_remove_sourcehost'](
|
||||
self.rule_name, host=self.test_host, hostgroup=self.test_hostgroup
|
||||
)
|
||||
|
||||
@ -316,7 +316,7 @@ class test_hbac(XMLRPC_test):
|
||||
"""
|
||||
Test adding the same external host using `xmlrpc.hbacrule_add_host`.
|
||||
"""
|
||||
ret = api.Command['hbacrule_mod'](
|
||||
api.Command['hbacrule_mod'](
|
||||
self.rule_name, setattr=self.test_invalid_sourcehost
|
||||
)
|
||||
|
||||
|
@ -91,20 +91,20 @@ class test_hbactest(XMLRPC_test):
|
||||
self.rule_names[i], accessruletype=self.rule_type, description=self.rule_descs[i],
|
||||
)
|
||||
|
||||
ret = api.Command['hbacrule_add_user'](
|
||||
api.Command['hbacrule_add_user'](
|
||||
self.rule_names[i], user=self.test_user, group=self.test_group
|
||||
)
|
||||
|
||||
ret = api.Command['hbacrule_add_host'](
|
||||
api.Command['hbacrule_add_host'](
|
||||
self.rule_names[i], host=self.test_host, hostgroup=self.test_hostgroup
|
||||
)
|
||||
|
||||
ret = api.Command['hbacrule_add_service'](
|
||||
api.Command['hbacrule_add_service'](
|
||||
self.rule_names[i], hbacsvc=self.test_service
|
||||
)
|
||||
|
||||
if i & 1:
|
||||
ret = api.Command['hbacrule_disable'](self.rule_names[i])
|
||||
api.Command['hbacrule_disable'](self.rule_names[i])
|
||||
|
||||
def test_a_hbactest_check_rules_detail(self):
|
||||
"""
|
||||
|
@ -619,9 +619,9 @@ class TestHostDNS(XMLRPC_test):
|
||||
try:
|
||||
ipv6only_host.create(force=False)
|
||||
finally:
|
||||
command = ipv6only_host.run_command('dnsrecord_del', dnszone,
|
||||
ipv6only_host.shortname,
|
||||
aaaarecord=aaaarec)
|
||||
ipv6only_host.run_command(
|
||||
'dnsrecord_del', dnszone, ipv6only_host.shortname,
|
||||
aaaarecord=aaaarec)
|
||||
|
||||
def test_add_ipv4only_host(self, dns_setup, ipv4only_host):
|
||||
ipv4only_host.run_command('dnsrecord_add', dnszone,
|
||||
@ -629,9 +629,9 @@ class TestHostDNS(XMLRPC_test):
|
||||
try:
|
||||
ipv4only_host.create(force=False)
|
||||
finally:
|
||||
command = ipv4only_host.run_command('dnsrecord_del', dnszone,
|
||||
ipv4only_host.shortname,
|
||||
arecord=arec)
|
||||
ipv4only_host.run_command(
|
||||
'dnsrecord_del', dnszone, ipv4only_host.shortname,
|
||||
arecord=arec)
|
||||
|
||||
def test_add_ipv46both_host(self, dns_setup, ipv46both_host):
|
||||
ipv46both_host.run_command('dnsrecord_add', dnszone,
|
||||
@ -640,10 +640,9 @@ class TestHostDNS(XMLRPC_test):
|
||||
try:
|
||||
ipv46both_host.create(force=False)
|
||||
finally:
|
||||
command = ipv46both_host.run_command('dnsrecord_del', dnszone,
|
||||
ipv46both_host.shortname,
|
||||
arecord=arec2,
|
||||
aaaarecord=aaaarec2)
|
||||
ipv46both_host.run_command(
|
||||
'dnsrecord_del', dnszone, ipv46both_host.shortname,
|
||||
arecord=arec2, aaaarecord=aaaarec2)
|
||||
|
||||
def test_add_ipv4_host_from_ip(self, dns_setup, ipv4_fromip_host):
|
||||
ipv4_fromip_host.ensure_missing()
|
||||
|
@ -138,7 +138,7 @@ def lineinfo(level):
|
||||
# Including this info in the test name makes it possible
|
||||
# to locate failing tests.
|
||||
frame = inspect.currentframe()
|
||||
for i in range(level):
|
||||
for _i in range(level):
|
||||
frame = frame.f_back
|
||||
lineno = frame.f_lineno
|
||||
filename = os.path.basename(frame.f_code.co_filename)
|
||||
@ -3455,9 +3455,8 @@ class test_managed_permissions(Declarative):
|
||||
ldap = ldap2(api)
|
||||
ldap.connect()
|
||||
|
||||
result = api.Command.permission_add(permission1, type=u'user',
|
||||
ipapermright=u'write',
|
||||
attrs=[u'cn'])
|
||||
api.Command.permission_add(
|
||||
permission1, type=u'user', ipapermright=u'write', attrs=[u'cn'])
|
||||
|
||||
# TODO: This hack relies on the permission internals.
|
||||
# Change as necessary.
|
||||
@ -3468,8 +3467,7 @@ class test_managed_permissions(Declarative):
|
||||
ldap.update_entry(entry)
|
||||
|
||||
# Update the ACI via the API
|
||||
result = api.Command.permission_mod(permission1,
|
||||
attrs=[u'l', u'o', u'cn'])
|
||||
api.Command.permission_mod(permission1, attrs=[u'l', u'o', u'cn'])
|
||||
|
||||
# Set the permission type to MANAGED
|
||||
entry = ldap.get_entry(permission1_dn)
|
||||
|
@ -163,7 +163,8 @@ class test_pwpolicy(XMLRPC_test):
|
||||
Test adding password policy to a managed group.
|
||||
"""
|
||||
try:
|
||||
entry = api.Command['pwpolicy_add'](self.user, krbminpwdlife=50, cospriority=2)['result']
|
||||
api.Command['pwpolicy_add'](
|
||||
self.user, krbminpwdlife=50, cospriority=2)
|
||||
except errors.ManagedPolicyError:
|
||||
pass
|
||||
else:
|
||||
|
@ -93,10 +93,6 @@ def makecert(reqdir, subject, principal):
|
||||
# Generate NSS cert database to store the private key for our CSR
|
||||
run_certutil(reqdir, ["-N", "-f", pwname])
|
||||
|
||||
res = api.Command['config_show']()
|
||||
subject_base = res['result']['ipacertificatesubjectbase'][0]
|
||||
|
||||
cert = None
|
||||
csr = unicode(generate_csr(reqdir, pwname, str(subject)))
|
||||
|
||||
res = api.Command['cert_request'](csr, principal=principal, add=True)
|
||||
|
@ -110,7 +110,7 @@ class AutomemberTracker(Tracker):
|
||||
try:
|
||||
self.attrs[u'group'] =\
|
||||
self.attrs[u'group'] + [options[u'group']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'group'] = [options[u'group']]
|
||||
# search for hosts in the target automember and
|
||||
# add them as memberindirect hosts
|
||||
@ -118,7 +118,7 @@ class AutomemberTracker(Tracker):
|
||||
try:
|
||||
self.attrs[u'hostgroup'] =\
|
||||
self.attrs[u'hostgroup'] + [options[u'hostgroup']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'hostgroup'] = [options[u'hostgroup']]
|
||||
|
||||
command = self.make_add_member_command(options)
|
||||
@ -135,12 +135,12 @@ class AutomemberTracker(Tracker):
|
||||
try:
|
||||
if not self.attrs[u'member_host']:
|
||||
del self.attrs[u'member_host']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
if not self.attrs[u'member_automember']:
|
||||
del self.attrs[u'member_automember']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
command = self.make_remove_member_command(options)
|
||||
|
@ -117,13 +117,13 @@ class GroupTracker(Tracker):
|
||||
try:
|
||||
self.attrs[u'member_user'] =\
|
||||
self.attrs[u'member_user'] + [options[u'user']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'member_user'] = [options[u'user']]
|
||||
elif u'group' in options:
|
||||
try:
|
||||
self.attrs[u'member_group'] =\
|
||||
self.attrs[u'member_group'] + [options[u'group']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'member_group'] = [options[u'group']]
|
||||
|
||||
command = self.make_add_member_command(options)
|
||||
@ -140,12 +140,12 @@ class GroupTracker(Tracker):
|
||||
try:
|
||||
if not self.attrs[u'member_user']:
|
||||
del self.attrs[u'member_user']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
if not self.attrs[u'member_group']:
|
||||
del self.attrs[u'member_group']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
command = self.make_remove_member_command(options)
|
||||
|
@ -91,7 +91,7 @@ class HostGroupTracker(Tracker):
|
||||
try:
|
||||
self.attrs[u'member_host'] =\
|
||||
self.attrs[u'member_host'] + [options[u'host']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'member_host'] = [options[u'host']]
|
||||
# search for hosts in the target hostgroup and
|
||||
# add them as memberindirect hosts
|
||||
@ -99,7 +99,7 @@ class HostGroupTracker(Tracker):
|
||||
try:
|
||||
self.attrs[u'member_hostgroup'] =\
|
||||
self.attrs[u'member_hostgroup'] + [options[u'hostgroup']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'member_hostgroup'] = [options[u'hostgroup']]
|
||||
|
||||
command = self.make_add_member_command(options)
|
||||
@ -116,12 +116,12 @@ class HostGroupTracker(Tracker):
|
||||
try:
|
||||
if not self.attrs[u'member_host']:
|
||||
del self.attrs[u'member_host']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
try:
|
||||
if not self.attrs[u'member_hostgroup']:
|
||||
del self.attrs[u'member_hostgroup']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
command = self.make_remove_member_command(options)
|
||||
|
@ -88,7 +88,7 @@ class SudoCmdGroupTracker(Tracker):
|
||||
try:
|
||||
self.attrs[u'member_sudocmd'] =\
|
||||
self.attrs[u'member_sudocmd'] + [options[u'sudocmd']]
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
self.attrs[u'member_sudocmd'] = [options[u'sudocmd']]
|
||||
|
||||
command = self.make_add_member_command(options)
|
||||
@ -102,7 +102,7 @@ class SudoCmdGroupTracker(Tracker):
|
||||
try:
|
||||
if not self.attrs[u'member_sudocmd']:
|
||||
del self.attrs[u'member_sudocmd']
|
||||
except KeyError as ex:
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
command = self.make_remove_member_command(options)
|
||||
|
@ -165,7 +165,7 @@ class UserTracker(KerberosAliasMixin, Tracker):
|
||||
(self.kwargs[key].split('@'))[0].lower(),
|
||||
(self.kwargs[key].split('@'))[1]
|
||||
)]
|
||||
except IndexError as ex:
|
||||
except IndexError:
|
||||
# we can provide just principal part
|
||||
self.attrs[key] = [u'%s@%s' % (
|
||||
(self.kwargs[key].lower(),
|
||||
|
@ -604,7 +604,7 @@ class DummyClass(object):
|
||||
def __init__(self, *calls):
|
||||
self.__calls = calls
|
||||
self.__i = 0
|
||||
for (name, args, kw, result) in calls:
|
||||
for (name, _args, _kw, _result) in calls:
|
||||
method = DummyMethod(self.__process, name)
|
||||
setattr(self, name, method)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user