summaryrefslogtreecommitdiffstats
path: root/ipatests/util.py
Commit message (Collapse)AuthorAgeFilesLines
* Add options to run only ipaclient unittestsChristian Heimes2017-03-171-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A new option for ipa-run-tests makes the test runner ignore subdirectories or skips tests that depend on the ipaserver package or on a running framework for RPC integration tests. The new option enables testing of client-only builds. $ ipatests/ipa-run-tests --ipaclient-unittests ... platform linux2 -- Python 2.7.13, pytest-2.9.2, py-1.4.32, pluggy-0.3.1 rootdir: /home/heimes/redhat, inifile: tox.ini plugins: sourceorder-0.5, cov-2.3.0, betamax-0.7.1, multihost-1.1 collected 451 items test_util.py ........ util.py .. test_ipaclient/test_csrgen.py ..............ssss... test_ipalib/test_aci.py ................... test_ipalib/test_backend.py ........ test_ipalib/test_base.py ............... test_ipalib/test_capabilities.py . test_ipalib/test_cli.py ... test_ipalib/test_config.py ............... test_ipalib/test_crud.py ............... test_ipalib/test_errors.py ....... test_ipalib/test_frontend.py ........................................ test_ipalib/test_messages.py .... test_ipalib/test_output.py ... test_ipalib/test_parameters.py ............................................................. test_ipalib/test_plugable.py ........ test_ipalib/test_rpc.py ......ssssssss test_ipalib/test_text.py ............................. test_ipalib/test_x509.py ... test_ipapython/test_cookie.py ............ test_ipapython/test_dn.py ........................... test_ipapython/test_ipautil.py .................................................................. test_ipapython/test_ipavalidate.py .......... test_ipapython/test_kerberos.py .............. test_ipapython/test_keyring.py .......... test_ipapython/test_ssh.py ............................... test_pkcs10/test_pkcs10.py ..... https://fedorahosted.org/freeipa/ticket/6517 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Explicitly pass down ccache names for connectionsSimo Sorce2017-02-151-13/+18
| | | | | | | | | | | | Instead of relying on side effects (setting the KRB5CCNAME env var), explicitly pass the ccache name to be used if it is not the default ccache. This fixes some tests that sometimes fail to work properly due to the wrong ccache being used. https://fedorahosted.org/freeipa/ticket/6543 Signed-off-by: Simo Sorce <simo@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Catch ValueError raised by pytest.config.getoption()Christian Heimes2017-01-051-1/+1
| | | | | | pytest.config.getoption() can raise ValueError for unknown options, too. Reviewed-By: Milan Kubik <mkubik@redhat.com>
* Use env var IPA_CONFDIR to get confdirChristian Heimes2016-12-021-0/+6
| | | | | | | | | | | | | The environment variable IPA_CONFDIR overrides the default confdir path. The value of the environment variable must be an absolute path to an existing directory. The new variable makes it much simpler to use the 'ipa' command and ipalib with a local configuration directory. Some scripts (e.g. servers, installers, and upgrades) set the confdir explicitly and do not support the env var. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* ipautil: move kinit functions to ipalib.installJan Cholasta2016-11-291-3/+2
| | | | | | | | | | | kinit_password() depends on ipaplatform. Move kinit_password() as well as kinit_keytab() to a new ipalib.install.kinit module, as they are used only from installers. https://fedorahosted.org/freeipa/ticket/6474 Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* ipatests: Fix assert_deepequal outside of pytest processMilan Kubík2016-11-141-1/+6
| | | | | | https://fedorahosted.org/freeipa/ticket/6420 Reviewed-By: Martin Basti <mbasti@redhat.com>
* ipatests: provide context manager for keytab usage in RPC testsMilan Kubík2016-10-041-5/+67
| | | | | | https://fedorahosted.org/freeipa/ticket/6366 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Pretty-print structures in assert_deepequalStanislav Laznicka2016-09-301-7/+28
| | | | | | | | | | | By default, ipa-run-tests will now pretty-print structures compared in the assert_deepequal function. This behaviour can be turned off by the --no-pretty-print option. https://fedorahosted.org/freeipa/ticket/6212 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Petr Spacek <pspacek@redhat.com>
* Remove unused variables in testsMartin Basti2016-09-271-1/+1
| | | | | | | | 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>
* ipatests: Allow change_principal context manager to use canonicalizationMilan Kubík2016-07-291-2/+4
| | | | | | | | | | | | | The context manager has been extended to optionally request principal canonicalization and indicate that the enterprise principal is being used. This allows to change the user during the test to an user using the alias and to test behavior related to enterprise principals. https://fedorahosted.org/freeipa/ticket/6142 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* ipatests: Extend the MockLDAP utility classMilan Kubík2016-07-291-0/+10
| | | | | | | | | | | Added mod_entry method to allow modifying existing entries via the ldap connection. The commit also implements the context manager protocol for the class. https://fedorahosted.org/freeipa/ticket/6142 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Fix several small typosBen Lipton2016-07-261-1/+1
| | | | | Fixes: https://fedorahosted.org/freeipa/ticket/6085 Reviewed-By: Petr Spacek <pspacek@redhat.com>
* ipatests: fix for change_principal context managerMilan Kubík2016-04-211-9/+10
| | | | | | | | | | The context manager was leaving API object disconnected when an exception was raised inside of it. This led to resource leak in the tests. https://fedorahosted.org/freeipa/ticket/5733 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Separated Tracker implementations into standalone packageMilan Kubík2015-12-021-0/+6
| | | | | | | | | | The previous way of implementing trackers in the module with the test caused circular imports. The separate package resolves this issue. https://fedorahosted.org/freeipa/ticket/5467 Reviewed-By: Ales 'alich' Marecek <amarecek@redhat.com>
* ipatests: added unlock_principal_password and change_principalMilan Kubík2015-10-271-0/+40
| | | | | | | | | | | | | | | | The unlock_principal_password unlocks the (new) user by running ldappasswd as the user. change_principal is an context manager that changes identity for the supplied api object by disconnecting and reconnecting the rpcclient in and outside of requested kerberos context. This context manager allows to run tests that cannot be executed as an admin user which can for example override an CA ACL. https://fedorahosted.org/freeipa/ticket/57 Reviewed-By: Martin Basti <mbasti@redhat.com>
* ipatest.util: Port to Python 3Petr Viktorin2015-10-221-1/+1
| | | | | | | - Allow bytes or str in Fuzzy - test_util: Fix indices in lists whose elements are unorderable in py3 Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Rename caught exception for use outside the except: block.Petr Viktorin2015-10-131-5/+2
| | | | | | | | | | | | | | In Python 3, the variable with the currently handled exception is unset at the end of the except block. (This is done to break reference cycles, since exception instances now carry tracebacks, which contain all locals.) Fix this in baseldap's error handler. Use a simpler structure for the ipatests.raises utility that only uses the exception inside the except block. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Do not compare types that are not comparable in Python 3Petr Viktorin2015-10-131-2/+8
| | | | | | | | | | In Python 3, different types are generally not comparable (except for equality), and None can't be compared to None. Fix cases of these comparisons. In ipatest.util, give up on sorting lists if the sorting raises a TypeError. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Alias "unicode" to "str" under Python 3Jan Cholasta2015-09-171-0/+3
| | | | | | | | | The six way of doing this is to replace all occurences of "unicode" with "six.text_type". However, "unicode" is non-ambiguous and (arguably) easier to read. Also, using it makes the patches smaller, which should help with backporting. Reviewed-By: Petr Viktorin <pviktori@redhat.com>
* ipatests: Add basic tests for certificate profile pluginMilan Kubík2015-09-161-0/+10
| | | | | Reviewed-By: Lenka Doudova <ldoudova@redhat.com> Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
* Use Python3-compatible dict method namesPetr Viktorin2015-09-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | Python 2 has keys()/values()/items(), which return lists, iterkeys()/itervalues()/iteritems(), which return iterators, and viewkeys()/viewvalues()/viewitems() which return views. Python 3 has only keys()/values()/items(), which return views. To get iterators, one can use iter() or a for loop/comprehension; for lists there's the list() constructor. When iterating through the entire dict, without modifying the dict, the difference between Python 2's items() and iteritems() is negligible, especially on small dicts (the main overhead is extra memory, not CPU time). In the interest of simpler code, this patch changes many instances of iteritems() to items(), iterkeys() to keys() etc. In other cases, helpers like six.itervalues are used. Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Use six.string_types instead of "basestring"Petr Viktorin2015-09-011-6/+9
| | | | | Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Modernize 'except' clausesPetr Viktorin2015-08-121-1/+1
| | | | | | | The 'as' syntax works from Python 2 on, and Python 3 will drop the "comma" syntax. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* plugable: Load plugins only from modules imported by APIJan Cholasta2015-07-011-2/+2
| | | | | | | | Previously all plugin modules imported from anywhere were added to the API. https://fedorahosted.org/freeipa/ticket/3090 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Run pylint on testsPetr Viktorin2015-01-141-15/+2
| | | | | | | | | | | | | | | Drop support for pylint < 1.0 Enable ignoring unknown attributes on modules (both nose and pytest use advanced techniques, support for which only made it to pylint recently) Fix some bugs revealed by pylint Do minor refactoring or add pylint:disable directives where the linter complains. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* ipatests.util.ClassChecker: Raise AttributeError in get_subclsPetr Viktorin2014-11-211-1/+1
| | | | | | | | Pytest considers NotImplementedError on attribute access an error. https://fedorahosted.org/freeipa/ticket/4610 Reviewed-By: Tomas Babej <tbabej@redhat.com>
* tests: Use PEP8-compliant setup/teardown method namesPetr Viktorin2014-11-211-2/+2
| | | | | | | | | | | | The setUp/dearDown names are used in the unittest module, but there is no reason to use them in non-`unittest` test cases. Nose supports both styles (but mixing them can cause trouble when calling super()'s methods). Pytest only supports the new ones. https://fedorahosted.org/freeipa/ticket/4610 Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Require rid-base and secondary-rid-base in idrange-add after ipa-adtrust-installAna Krivokapic2013-06-241-6/+31
| | | | | | | | | | | | | Add a new API command 'adtrust_is_enabled', which can be used to determine whether ipa-adtrust-install has been run on the system. This new command is not visible in IPA CLI. Use this command in idrange_add to conditionally require rid-base and secondary-rid-base options. Add tests to cover the new functionality https://fedorahosted.org/freeipa/ticket/3634
* Make an ipa-tests packagePetr Viktorin2013-06-171-0/+637
Rename the 'tests' directory to 'ipa-tests', and create an ipa-tests RPM containing the test suite Part of the work for: https://fedorahosted.org/freeipa/ticket/3654