summaryrefslogtreecommitdiffstats
path: root/ipalib/parameters.py
Commit message (Collapse)AuthorAgeFilesLines
* Generate same API.txt under Python 2 and 3Christian Heimes2018-02-151-3/+6
| | | | | | | | | Use Python 3's reprlib with customizations to create same API.txt under Python 2 and 3. Some plugins have been slightly altered to use stable sorting for dynamically created parameter lists. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* Fix pylint warnings inconsistent-return-statementsChristian Heimes2017-12-181-2/+33
| | | | | | | | | | Add consistent return to all functions and methods that are covered by tox -e pylint[23]. I haven't checked if return None is always a good idea or if we should rather raise an error. See: https://pagure.io/freeipa/issue/7326 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* Remove pkcs10 module contentsStanislav Laznicka2017-10-251-1/+1
| | | | | | | This removes pkcs10 module contents and adds a warning message about its future removal. https://pagure.io/freeipa/issue/7131
* parameters: introduce CertificateSigningRequestStanislav Laznicka2017-10-251-2/+59
| | | | | | | | | | Previously, CSRs were handled as a Str parameter which brought trouble to Python 3 because of its more strict type requirements. We introduce a CertificateSigningRequest parameter which allows to use python-cryptography x509.CertificateSigningRequest to represent CSRs in the framework. https://pagure.io/freeipa/issue/7131
* parameters: relax type checksStanislav Laznicka2017-10-251-3/+8
| | | | | | | | | | The type checks in ipalib.parameters were too strict. An object that inherits from a type should implement its public interface. This should allow us checking for types of objects whose class implementations are private to a module but they implement a certain public interface (which is typical for e.g. python-cryptography). https://pagure.io/freeipa/issue/7131
* parameters: convert Decimal.precision to intStanislav Laznicka2017-09-081-1/+1
| | | | | | | | | | | Explicitly convert Decimal.precision to int for unary `-` to make sure int is passed to it. Fixes pylint warning. https://pagure.io/freeipa/issue/6874 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* Create a Certificate parameterStanislav Laznicka2017-07-271-1/+41
| | | | | | | | | | | | | | | | | | | | | | | | | Up until now, Bytes parameter was used for certificate parameters throughout the framework. However, the Bytes parameter does nothing special for certificates, like validation, so this had to be done for each of the parameters which were supposed to represent a certificate. This commit introduces a special Certificate parameter which takes care of certificate validation so this does not have to be done separately. It also makes sure that the certificates represented by this parameter are always converted to DER format so that we can work with them in a unified manner throughout the framework. This commit also makes it possible to pass bytes directly during instantiation of the Certificate parameter and they are still represented correctly after their conversion in the _convert_scalar() method. https://pagure.io/freeipa/issue/4985 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* parameters: relax type checksStanislav Laznicka2017-07-271-9/+6
| | | | | | | | | | | | | | | | | | | Previously, the type check of the Param class did only allow the parameters to only have a value that's of a direct type. However, that's nonsensically restrictive. For example, if there's an interface implemented as an `ABCMeta` class then the check for type fails since the interface's type is `ABCMeta` instead of directly a `type`. Among others, this is the case for cryptography.x509.Certificate. Being a type is a transitive property of a Python object and we should respect that in our framework. https://pagure.io/freeipa/issue/4985 Reviewed-By: Fraser Tweedale <ftweedal@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Add --password-expiration to allow admin to force user password expirationGabe2017-03-311-6/+10
| | | | | | | - Allows an admin to easily force a user to expire their password forcing the user to change it immediately or at a specified time in the future Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Stable _is_null checkChristian Heimes2017-02-101-1/+7
| | | | | | | | | Avoid comparison of bytes with int in _is_null() check. b'' == 0 triggers a BytesWarning. Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* pylint: enable the import-error checkJan Cholasta2016-10-241-1/+3
| | | | | | | | | | Check for import errors with pylint to make sure new python package dependencies are not overlooked. https://fedorahosted.org/freeipa/ticket/6418 Reviewed-By: Petr Spacek <pspacek@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Pylint: fix the rest of unused local variablesMartin Basti2016-10-111-5/+1
| | | | Reviewed-By: Pavel Vomacka <pvomacka@redhat.com>
* Tests: Fix failing test_ipalib/test_parametersLenka Doudova2016-10-111-1/+1
| | | | | | | | | | | Parameters test fails because of KeyError caused by improper manipulation with kwargs in Param.__init__ method. During initialization, if kwargs['required'] or kwargs['multivalue'] is None, it is delete from dictionary and hence the missing key. Small change of the condition prevents this from happening. Partially fixes https://fedorahosted.org/freeipa/ticket/6292 Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
* Pylint: enable check for unused-variablesMartin Basti2016-09-271-0/+1
| | | | | | | | | | | | | | | Unused variables may: * make code less readable * create dead code * potentialy hide issues/errors Enabled check should prevent to leave unused variable in code Check is locally disabled for modules that fix is not clear or easy or have too many occurences of unused variables Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com> Reviewed-By: Stanislav Laznicka <slaznick@redhat.com>
* pylint: fix unneeded-notJan Barta2016-09-221-2/+2
| | | | | Reviewed-By: Tomas Krizek <tkrizek@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
* raise ValidationError when deprecated param is passed to commandMartin Babinsky2016-09-051-4/+3
| | | | | | https://fedorahosted.org/freeipa/ticket/6190 Reviewed-By: Lenka Doudova <ldoudova@redhat.com>
* parameters: move the `confirm` kwarg to ParamJan Cholasta2016-08-101-4/+2
| | | | | | | | | | | | | | | | | | | Whether a parameter is treated like password is determined by the `password` class attribute defined in the Param class. Whether the CLI will asks for confirmation of a password parameter depends on the value of the `confirm` kwarg of the Password class. Move the `confirm` kwarg from the Password class to the Param class, so that it can be used by any Param subclass which has the `password` class attribute set to True. This fixes confirmation of the --key option of otptoken-add, which is a Bytes subclass with `password` set to True. https://fedorahosted.org/freeipa/ticket/6174 Reviewed-By: Martin Basti <mbasti@redhat.com> Reviewed-By: David Kupka <dkupka@redhat.com>
* ipalib: introduce Principal parameterMartin Babinsky2016-07-011-0/+37
| | | | | | | | | | | This patch introduces a separate Principal parameter that allows the framework to syntactically validate incoming/outcoming principals by using a single shared codebase. https://fedorahosted.org/freeipa/ticket/3864 Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* batch, schema: use Dict instead of AnyJan Cholasta2016-06-151-0/+9
| | | | | | | | | Add new Dict parameter class and use it in the batch and command_defaults plugins. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* ipalib: replace DeprecatedParam with `deprecated` Param argumentJan Cholasta2016-06-031-16/+5
| | | | | | | | | | | | | | | Introduce new `deprecated` Param keywork argument. Setting it to True on a param has the same effect as using DeprecatedParam. This allows deprecating params while retaining their type information. Revert all DeprecatedParam params back to their original definition and set `deprecated` to True. Remove the now unused DeprecatedParam class. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* parameters: introduce no_convert keyword argumentJan Cholasta2016-06-031-2/+11
| | | | | | | | | | | | | When set to true, the argument causes params to not convert unicode values to the param type. This will allow thin client to properly handle params which can be converted from unicode to the param type only on the server, e.g. because of a normalizer. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* parameters: introduce cli_metavar keyword argumentJan Cholasta2016-06-031-0/+5
| | | | | | | | | | Add new Param keyword argument cli_metavar to specify the stand-in for CLI option arguments in command help text. Uppercase class name is used by default. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* ipalib: remove the unused `csv` argument of ParamJan Cholasta2016-05-251-6/+0
| | | | | | https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* makeapi: optimize API.txtJan Cholasta2016-05-251-36/+60
| | | | | | | | | | | | | | | | | | | | Change Param formatting to: * always use quantified names rather than the `required` and `multivalue` kwargs, * ignore kwargs with default value, * ignore kwargs related to validation, as validation is now strictly server-side, * ignore the `attribute` and `primary_key` kwargs, as they are relevant only on object params, * ignore the `include` and `exclude` kwargs, as makeapi takes into account only params available in the 'cli' context, * ignore the unused `csv` kwarg. Format optional Output arguments as kwargs. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* frontend: perform argument value validation only on serverJan Cholasta2016-05-251-1/+0
| | | | | | | | | | | | | | | | Do not validate values of command arguments on the client and let the server handle validation. This will make the client more lightweight by not having it to carry validation code and metadata with itself for the price of increasing network traffic in case the validation fails. Types of the arguments are still validated on both the client and the server. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* frontend: re-raise remote RequirementError using CLI name in CLIJan Cholasta2016-05-251-10/+3
| | | | | | https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* parameters: remove unused ConversionError and ValidationError argumentsJan Cholasta2016-05-251-54/+25
| | | | | | | | | | Do not set the `value`, `index` and `rule` arguments when raising ConversionError and ValidationError. The arguments are unused and are not specified consistently accross the framework and plugins. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka <dkupka@redhat.com>
* makeapi: use the same formatting for `int` and `long` valuesJan Cholasta2016-05-191-0/+2
| | | | | | | | | This prevents validation failures on architectures where integer is less than 32 bits. https://fedorahosted.org/freeipa/ticket/5894 Reviewed-By: Martin Basti <mbasti@redhat.com>
* Remove unused importsMartin Basti2015-12-231-3/+2
| | | | | | | This patch removes unused imports, alse pylint has been configured to check unused imports. Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Handle binascii.Error from base64.b64decode()Petr Viktorin2015-10-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In Python 3, the base64.b64decode function raises binascii.Error (a ValueError subclass) when it finds incorrect padding. In Python 2 it raises TypeError. Callers should usually handle ValueError; unless they are specifically concerned with handling base64 padding issues). In some cases, callers should handle ValueError: - ipalib.pkcs10 (get_friendlyname, load_certificate_request): callers should handle ValueError - ipalib.x509 (load_certificate*, get_*): callers should handle ValueError In other cases ValueError is handled: - ipalib.parameters - ipapython.ssh - ipalib.rpc (json_decode_binary - callers already expect ValueError) - ipaserver.install.ldapupdate Elsewhere no error handling is done, because values come from trusted sources, or are pre-validated: - vault plugin - ipaserver.install.cainstance - ipaserver.install.certs - ipaserver.install.ipa_otptoken_import Reviewed-By: Tomas Babej <tbabej@redhat.com>
* ipalib.parameters: Require bytes for Bytes.patternPetr Viktorin2015-10-131-1/+4
| | | | Reviewed-By: Tomas Babej <tbabej@redhat.com>
* ipalib.parameters: Handle 0-prefixed octal format of intsPetr Viktorin2015-10-131-0/+3
| | | | | | | | | | In Python 2, numbers prfixed with '0' are parsed as octal, e.g. '020' -> 16. In Python 3, the prefix is '0o'. Handle the old syntax for IPA's parameter conversion to keep backwards compatibility. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Do not compare types that are not comparable in Python 3Petr Viktorin2015-10-131-3/+3
| | | | | | | | | | 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>
* Remove uses of the `types` modulePetr Viktorin2015-10-071-2/+2
| | | | | | | | | | | In Python 3, the types module no longer provide alternate names for built-in types, e.g. `types.StringType` can just be spelled `str`. NoneType is also removed; it needs to be replaced with type(None) Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Use six.moves.xmlrpc.client instead of xmlrpclibPetr Viktorin2015-10-071-1/+1
| | | | | | | | The module is renamed to xmlrpc.client in Python 3. Reviewed-By: David Kupka <dkupka@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com> Reviewed-By: Martin Basti <mbasti@redhat.com>
* Replace StandardError with ExceptionRobert Kuska2015-09-301-3/+3
| | | | | | | | StandardError was removed in Python3 and instead Exception should be used. Signed-off-by: Robert Kuska <rkuska@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Use bytes instead of str where appropriateJan Cholasta2015-09-171-4/+4
| | | | | | Under Python 2, "str" and "bytes" are synonyms. Reviewed-By: Petr Viktorin <pviktori@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>
* Modernize use of range()Petr Viktorin2015-09-011-3/+3
| | | | | | | | | | | | In Python 3, range() behaves like the old xrange(). The difference between range() and xrange() is usually not significant, especially if the whole result is iterated over. Convert xrange() usage to range() for small ranges. Use modern idioms in a few other uses of range(). Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Use six.integer_types instead of (long, int)Petr Viktorin2015-09-011-8/+8
| | | | | Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Replace filter() calls with list comprehensionsPetr Viktorin2015-09-011-3/+2
| | | | | | | | In Python 3, filter() returns an iterator. Use list comprehensions instead. 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-9/+10
| | | | | Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* fix missing information in object metadataPetr Vobornik2015-08-261-3/+14
| | | | | | | | | | | Missing 'required' values in takes_params causes Web UI to treat required fields as optional. Regression caused by ba0a1c6b33e2519a48754602413c8379fb1f0ff1 https://fedorahosted.org/freeipa/ticket/5258 Reviewed-By: Martin Basti <mbasti@redhat.com>
* Use absolute importsPetr Viktorin2015-08-121-10/+11
| | | | | | | In Python 3, implicit relative imports will not be supported. Use fully-qualified imports everywhere. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Modernize function and method attribute namesPetr Viktorin2015-08-121-1/+1
| | | | | | | | Python 3 uses double-underscored names for internal function attributes. In Python 2.7, these names exist as aliases to the old 'func_*' and 'im_*' names. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Modernize 'except' clausesPetr Viktorin2015-08-121-7/+7
| | | | | | | The 'as' syntax works from Python 2 on, and Python 3 will drop the "comma" syntax. Reviewed-By: Tomas Babej <tbabej@redhat.com>
* include more information in metadataPetr Vobornik2015-07-031-19/+6
| | | | | | | | | | | added to commands: doc, proper args, NO_CLI added to options: default_from, cli_name, cli_short_name and others https://fedorahosted.org/freeipa/ticket/3129 Reviewed-By: Martin Kosek <mkosek@redhat.com> Reviewed-By: Tomas Babej <tbabej@redhat.com>
* Throw zonemgr error message before installation proceedsMartin Basti2014-12-011-30/+5
| | | | | Ticket: https://fedorahosted.org/freeipa/ticket/4771 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
* Check normalization only for IDNA domainsMartin Basti2014-07-011-10/+15
| | | | | | | | | | Backward compability with older IPA versions which allow to use uppper case. Only IDNA domains will be checked. https://fedorahosted.org/freeipa/ticket/4382 Reviewed-By: Martin Kosek <mkosek@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
* DNSNameParam parameterMartin Basti2014-06-031-0/+69
| | | | | | | | | | New param type for domain names Part of ticket: IPA should allow internationalized domain names https://fedorahosted.org/freeipa/ticket/3169 Reviewed-By: Jan Cholasta <jcholast@redhat.com>