Commit Graph

89 Commits

Author SHA1 Message Date
Petr Viktorin
0b62700c8c Allow multi-line CSV parameters
Feed individual lines of input into the CSV parser, and include all lines
in the output.

https://fedorahosted.org/freeipa/ticket/2402
2012-03-28 22:01:24 -04:00
Jan Cholasta
a2299070c8 Change parameters to use only default_from for dynamic default values.
Replace all occurences of create_default with equivalent default_from
and remove create_default from the framework. This is needed for
proper parameter validation, as there is no way to tell which
parameters to validate prior to calling create_default, because
create_default does not provide information about which parameters are
used for generating the default value.
2012-03-28 14:04:31 +02:00
Petr Viktorin
dddebe2350 Only split CSV in the client, quote instead of escaping
Splitting on commas is not an idempotent operation:
'a,b\,c' -> ('a', 'b,c') -> ('a', 'b', 'c')

That means we can't do it when the call is forwarded, so this is only
done on the CLI. The UI already sends values as a tuple.

Replace escaping in the csv parser with quoting. Quoted strings can have
embedded commas instead of having to escape them. This prevents the csv
parser from eating all escape characters.

Also, document Param's csv arguments, and update tests.

https://fedorahosted.org/freeipa/ticket/2417
https://fedorahosted.org/freeipa/ticket/2227
2012-03-20 20:03:54 -04:00
Rob Crittenden
f18cfd7de8 Use a consistent parameter name in errors, defaulting to cli_name.
For general command-line errors we want to use the cli_name on output.
The exception is when using *attr, we want to return that attribute name
in the exception.

https://fedorahosted.org/freeipa/ticket/1418
2012-03-20 09:06:52 +01:00
Petr Viktorin
7cfc16ca58 Enforce that required attributes can't be set to None in CRUD Update
The `required` parameter attribute didn't distinguish between cases
where the parameter is not given and all, and where the parameter is
given but empty. The case of updating a required attribute couldn't
be validated properly, because when it is given but empty, validators
don't run.
This patch introduces a new flag, 'nonempty', that specifies the
parameter can be missing (if not required), but it can't be None.
This flag gets added automatically to required parameters in CRUD
Update.
2012-03-12 17:16:14 +01:00
Rob Crittenden
0099ccbea8 Only apply validation rules when adding and updating.
There may be cases, for whatever reason, that an otherwise illegal
entry gets created that doesn't match the criteria for a valid
user/host/group name. If this happens (i.e. migration) there is no way
to remove this using the IPA tools because we always applied the name
pattern. So you can't, for example, delete a user with an illegal name.

Primary keys are cloned with query=True in PKQuery which causes no
rules to be applied on mod/show/find. This reverts a change from commit
3a5e26a0 which applies class rules when query=True (for enforcing no
white space).

Replace rdnattr with rdn_is_primary_key. This was meant to tell us when
an RDN change was necessary to do a rename. There could be a disconnect
where the rdnattr wasn't the primary key and in that case we don't
need to do an RDN change, so use a boolean instead so that it is
clear that RDN == primary key.

Add a test to ensure that nowhitespace is actually enforced.

https://fedorahosted.org/freeipa/ticket/2115

Related: https://fedorahosted.org/freeipa/ticket/2089

Whitespace tickets:
https://fedorahosted.org/freeipa/ticket/1285
https://fedorahosted.org/freeipa/ticket/1286
https://fedorahosted.org/freeipa/ticket/1287
2012-02-29 18:00:45 -05:00
Jan Cholasta
ca3f304110 Base64-decode unicode values in Bytes parameters.
Fix wrong handling of strings in --setattr/--addattr/--delattr.

These changes make it possible to use Bytes in --setattr/--addattr/
--delattr without errors.

Fixes managing SSH keys on command-line

https://fedorahosted.org/freeipa/ticket/754
2012-02-13 22:21:50 -05:00
Martin Kosek
092dd8db12 Replace float with Decimal
Having float type as a base type for floating point parameters in
ipalib introduces several issues, e.g. problem with representation
or value comparison. Python language provides a Decimal type which
help overcome these issues.

This patch replaces a float type and Float parameter with a
decimal.Decimal type in Decimal parameter. A precision attribute
was added to Decimal parameter that can be used to limit a number
of decimal places in parameter representation. This approach fixes
a problem with API.txt validation where comparison of float values
may fail on different architectures due to float representation error.

In order to safely transfer the parameter value over RPC it is
being converted to string which is then converted back to
decimal.Decimal number on a server side.

https://fedorahosted.org/freeipa/ticket/2260
2012-01-20 08:13:44 +01:00
Martin Kosek
2188dae0c9 Improve CLI output for complex commands
Complex commands may have many options or non-standard output. This
patch adds 2 improvements to handle these commands better:
  1) Add "option_group" parameter attribute
     Make command help more readable by specifying an option group
     for the parameter. All parameters in the same option group are
     then placed to one named option group
  2) Allow nested entries in the output
     Current CLI output module cannot handle a list of nested entries
     (dictionaries) contained in an entry attribute. Make sure they
     are printed properly (with indentation)

https://fedorahosted.org/freeipa/ticket/2082
2012-01-12 09:43:13 +01:00
Martin Kosek
1f36ab1b78 Fix Parameter csv parsing
CSV values were not parsed in ipalib.parameters.normalize method
properly when passed as a list and not as a basestring.

Based on Jan Cholasta's contribution.
2012-01-12 09:43:10 +01:00
Jan Cholasta
135ccf89de Parse comma-separated lists of values in all parameter types. This can be enabled for a specific parameter by setting the "csv" option to True.
Remove "List" parameter type and replace all occurences of it with appropriate
multi-valued parameter ("Str" in most cases) with csv enabled.

Add new parameter type "Any", capable of holding values of any type. This is
needed by the "batch" command, as "Str" is not suitable type for the "methods"
parameter.

ticket 2007
2011-11-30 17:08:35 +01:00
Martin Kosek
2a3a4ae64a Fix LDAP object parameter encoding
Parameters in LDAP objects missed an information if they are real
LDAP attributes or not. Real LDAP attributes are written to
entry_attrs dictionary in plugin callbacks and are being encoded.
This causes issues when plugin callbacks does not expect that
the parameters values are already encoded for submission to LDAP.

This patch introduces a new flag "noattribute" used to mark that
a parameter is not an LDAP attribute and thus should not be encoded
or added to entry_attrs. Param documentation is improved to describe
the meaning of this and other Param flags or attributes.

https://fedorahosted.org/freeipa/ticket/2097
2011-11-15 13:17:44 +01:00
Martin Kosek
b5c049ae2e Allow custom server backend encoding
Server framework does not support encoding of native Python type
values stored in Param classes and sub-classes. When backend (LDAP)
value encoding differs from Python type value representation user
has to has to hard-code the encoders in his processing.

This patch introduces a method Param.encode which is used in server
context to encode native Python Param values. The new encode method
is used for Bool parameter to convert native Python bool type value
(True, False) to LDAP value ("TRUE", "FALSE").

https://fedorahosted.org/freeipa/ticket/2039
2011-11-09 15:31:19 +01:00
Rob Crittenden
bd227b3562 Require current password when using passwd to change your own password.
Add a new required parameter, current_password. In order to ask this
first I added a new parameter option, sortorder. The lower the value the
earlier it will be prompted for.

I also changed the way autofill works. It will attempt to get the default
and if it doesn't get anything will continue prompting interactively.

Since current_password is required I'm passing a magic value that
means changing someone else's password. We need to pass something
since current_password is required.

The python-ldap passwd command doesn't seem to use the old password at
all so I do a simple bind to validate it.

https://fedorahosted.org/freeipa/ticket/1808
2011-10-04 15:16:15 +02:00
Rob Crittenden
1936b8050e Add option to only prompt once for passwords, use in entitle_register
A Password param always prompted to confirm the entered password.
This doesn't make sense if you want to prompt for a password to another
system like we do with entitlements. This adds a new boolean option to
control the Password prompt parameter.

https://fedorahosted.org/freeipa/ticket/1695
2011-08-24 15:25:53 -04:00
Rob Crittenden
87821f2049 Revert use of 'can be at least' to 'must be at least' in minvalue validator
BZ https://bugzilla.redhat.com/show_bug.cgi?id=723969
2011-07-26 01:58:41 -04:00
Rob Crittenden
a49d294845 Don't check for leading/trailing spaces in a File parameter
https://fedorahosted.org/freeipa/ticket/1505
2011-07-25 09:10:27 +02:00
Rob Crittenden
e8c7eaf260 Set a default minimum value for class Int, handle long values better.
Allow a long to get as far as the min/max constraints where we can
compare it to min/max int values and reject with a proper error message.

https://fedorahosted.org/freeipa/ticket/1494
2011-07-19 20:32:00 -04:00
Martin Kosek
bc8be0a41e Improve long integer type validation
Passing a number of "long" type to IPA Int parameter invokes
user-unfriendly error message about incompatible types. This patch
improves Int parameter with user understandable message along with
maximum value he can pass.

https://fedorahosted.org/freeipa/ticket/1346
2011-07-18 16:02:07 +02:00
Alexander Bokovoy
b93e0b8bbf Convert nsaccountlock to always work as bool towards Python code
https://fedorahosted.org/freeipa/ticket/1259

Python code will see nsaccountlock as bool. JavaScript code will also see it as bool.

This allows native boolean operations with the lock field. Passes both CLI and WebUI tests.
2011-07-13 12:02:46 +02:00
Endi S. Dewata
b2c5b2b4b5 Fixed object_name and object_name_plural internationalization
The object_name, object_name_plural and messages that use these
attributes have been converted to support translation. The label
attribute in the Param class has been modified to accept unicode
string.

Ticket #1435
2011-07-12 16:33:08 -04:00
Rob Crittenden
3a5e26a01c Enforce class rules when query=True, continue to not run validators.
This started as a problem in allowing leading/trailing whitespaces
on primary keys. In nearly every command other than add query is True
so all rules were ignored on the primary key. This meant that to
enforce whitespace we would need to define a validator for each one.

I decided instead to set self.all_rules to just the class rules if
query == True. So the minimum set of validators will be executed
against each type but param-specific validators will only run on add.

https://fedorahosted.org/freeipa/ticket/1285
https://fedorahosted.org/freeipa/ticket/1286
https://fedorahosted.org/freeipa/ticket/1287
2011-07-11 18:43:32 -04:00
Alexander Bokovoy
716a25a784 Convert Bool to TRUE/FALSE when working with LDAP backend https://fedorahosted.org/freeipa/ticket/1259
According to RFC4517 the only valid values for a boolean in LDAP are TRUE or FALSE.
This commit adds support to recognize TRUE and FALSE as valid Bool constants when converting from LDAP attribute values
and enforces TRUE or FALSE string for account locking.
2011-06-27 23:03:23 -04:00
John Dennis
032b77ac23 Add backslash escape support for cvs reader 2011-06-22 01:20:27 -04:00
Adam Young
6f1b62fb1a JSON marshalling list
Lists are sometimes marshalled as arrays.  Before, we assumed they were CSV strings.
2011-06-10 14:37:54 -04:00
Jan Cholasta
5700920627 Fix uninitialized attributes. 2011-04-21 10:41:29 +02:00
Jan Cholasta
1ac3ed2c27 Fix lint false positives. 2011-04-13 15:58:45 +02:00
Pavel Zuna
f3de95ce99 Fix translatable strings in ipalib plugins.
Needed for xgettext/pygettext processing.
2011-03-01 10:31:40 -05:00
Pavel Zuna
6eb70ea8e2 Remove deprecated i18n code from ipalib/request and all references to it.
Ticket #903
2011-03-01 10:31:36 -05:00
Rob Crittenden
3ac3130fc9 Convert json strings to unicode when they are unmarshalled.
This patch removes some individual work-arounds of converting strings
to unicode, they only masked the problem. String values are not
passed to the validator or normalizers so things like adding the
realm automatically to services weren't happening.

ticket 941
2011-02-11 13:36:15 -05:00
Jakub Hrozek
ab2ca8022e Fix assorted bugs found by pylint 2011-01-25 14:01:36 -05:00
Rob Crittenden
886e417fd7 Set the default Int maxvalue to the maximum XML-RPC can handle.
Also handle marshalling errors thrown by xmlrpclib more gracefully.

ticket 770
2011-01-18 10:03:55 -05:00
Endi S. Dewata
00b3984e5a Support for str in StrEnum.
The StrEnum class has been modified to accept str value and convert
it into unicode. This is to fix encoding issue on F14.
2011-01-13 21:48:07 -05:00
Pavel Zuna
1af89d0daa Retype (when cloning) Flag parameters to Bool for search commands.
Flag parameters are always autofill by definition, causing unexpected
search results. This patch retypes them to Bool for search commands,
so that users have to/can enter the desired value manually.

Ticket #689
Ticket #701
2011-01-10 12:07:19 -05:00
Pavel Zuna
e5ccddf446 Fix webUI command parameters error on Fedora 14. 2010-12-22 11:00:10 -05:00
Pavel Zuna
1a7f5e0cc4 Fix reporting of errors when validating parameters.
Print the attribute CLI name instead of its 'real' name.
The real name is usually the name of the corresponding LDAP
attribute, which is confusing to the user.

This way we get:
Invalid 'login': blablabla
instead of:
Invalid 'uid': blablabla

Another example:
Invalid 'hostname': blablabla
instead of:
Invalid 'fqdn': blablabla

Ticket #435
2010-12-21 12:57:41 -05:00
Jakub Hrozek
7493d781df Change FreeIPA license to GPLv3+
The changes include:
 * Change license blobs in source files to mention GPLv3+ not GPLv2 only
 * Add GPLv3+ license text
 * Package COPYING not LICENSE as the license blobs (even the old ones)
   mention COPYING specifically, it is also more common, I think

 https://fedorahosted.org/freeipa/ticket/239
2010-12-20 17:19:53 -05:00
Jakub Hrozek
ffc6031ad7 Allow RDN changes from CLI
https://fedorahosted.org/freeipa/ticket/397
2010-12-20 11:27:46 -05:00
Rob Crittenden
6e2dd0fa5b Add new parameter type IA5Str and use this to enforce the right charset.
ticket 496
2010-12-07 16:37:42 -05:00
Rob Crittenden
6c393e53b0 This is the second half of a patch. Only the part that had to be
re-based got pushed for some reason.

Use better description for group names in help and always prompt for members

When running <foo>-[add|remove]-member completely interactively it didn't
prompt for managing membership, it just reported that 0 members were
handled which was rather confusing.

This will work via a shell if you want to echo too:

$ echo "" | ipa group-add-member g1

This returns 0 members because nothing is read for users or group members.

$ echo -e "g1\nadmin\n" | ipa group-add-member

This adds the user admin to the group g1. It adds it as a user because
user membership is prompted for first.

ticket 415
2010-12-02 16:29:26 -05:00
Rob Crittenden
72cf73b6b6 Output ACI's broken out into attributes rather than a single text field
Also add validation to the List parameter type.

ticket 357
2010-11-04 12:48:45 -04:00
Rob Crittenden
33802ab712 Use context to decide which name to return on RequirementsErrors
When a Requirement fails we throw an exception including the name of the
field that is missing. To make the command-line friendlier we have a
cli_name defined which may or may not match the LDAP attribute. This can
be confusing if you are using ipalib directly because the attribute name
missing may not match what is actually required (desc vs description is
a good example).

If you use the context 'cli' then it will throw exceptions using cli_name.
If you use any other context it will use the name of the attribute.

ticket 187
2010-10-28 16:06:06 -04:00
Pavel Zuna
1bb412239d Big webUI patch.
Quick summary:
- use jQuery UI and jQuery BBQ libraries
- code restructuring

The patch has so many changes they can't be listed here. Many parts
of the code have been rewritten from scrach.

See freeipa-devel mailing list:
webUI code restructuring [wall of text, diagrams, ... you've been warned!]
2010-09-07
2010-09-17 19:42:40 -04:00
Pavel Zuna
f15758dbea Improve serialization to JSON.
- Make it recursive.
- Make Param classes serializable.
- Take python native data types into account.
2010-08-12 09:06:22 -04:00
Rob Crittenden
2d7d047cbf Add optional error message to pattern validator
The pattern validator by default displays the pattern that is being
matched against. This isn't helpful, particularly for very hairy patterns.
This adds a new parameter, pattern_errmsg, that is displayed on errors
if set.

ticket #11
2010-08-06 15:32:37 -04:00
Rob Crittenden
4924270b45 Increase supported weeks per month from 4 to 6 in AccessTime() type 2010-06-03 09:25:25 -04:00
root
a3d1b17559 Add weekly periodic schedule to AccessTime param type.
Fix bug #588414
2010-05-04 13:39:42 -04:00
Rob Crittenden
3698dca8e3 Add test cases for AccessTime param and fix some problems in AccessTime 2010-05-03 14:07:34 -06:00
Jason Gerard DeRose
c350f84134 Finish deferred translation mechanism 2010-03-16 11:41:22 -06:00
Rob Crittenden
f7b512b826 When raising an error about a required attribute, use cli_name not name.
name is an LDAP attribute and may not be easily identifiable (e.g. sn).
2010-03-07 13:04:50 +01:00