Commit Graph

202 Commits

Author SHA1 Message Date
Petr Viktorin
099cf98307 Refactor ipautil.run
The ipautil.run function now returns an object with returncode and
output are accessible as attributes.

The stdout and stderr of all commands are logged (unless skip_output is given).

The stdout/stderr contents must be explicitly requested with a keyword
argument, otherwise they are None.
This is because in Python 3, the output needs to be decoded, and that can
fail if it's not decodable (human-readable) text.

The raw (bytes) output is always available from the result object,
as is "leniently" decoded output suitable for logging.

All calls are changed to reflect this.

A use of Popen in cainstance is changed to ipautil.run.

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-12-14 10:54:23 +01:00
Lenka Doudova
a66a2c5160 Adding descriptive IDs to stageuser tests
Adding descriptive IDs to parametrized stageuser test for better identification of test cases.

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-12-11 12:34:17 +01:00
Milan Kubík
17f9ca154b Separated Tracker implementations into standalone package
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>
2015-12-02 17:12:24 +01:00
Martin Babinsky
8909506a88 update idrange tests to reflect disabled modification of local ID ranges
Fix for https://fedorahosted.org/freeipa/ticket/4826 temporarily disallowed
modification of local ID ranges via API calls The corresponding XMLRPC tests
were updated to reflect this change.

Reviewed-By: Milan Kubik <mkubik@redhat.com>
2015-11-23 12:45:03 +01:00
Martin Basti
b0faf30eac Tests: DNS various exceptions can be raised in test
Test 'Try to add SRV record to zone %r both via parts and a raw value'
can raise various exceptions which are all valid. Due to internal
representation IPA may raise exception for any of target, port,
priority, weight part.

This commit handles all of them.

Reviewed-By: Petr Spacek <pspacek@redhat.com>
2015-11-13 14:01:46 +01:00
Martin Basti
c08d4523b2 Tests: DNS replace 192.0.2.0/24 with 198.18.0.0/15 range
192.0.2.0/24 is IANA reserved address that should not be used. netaddr
module check implemented for this address and IPA reject this address as
invalid.
198.18.0.0/15 is IANA reserved address for benchmark testing purpose, so
we can safely use this network.

http://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml

Reviewed-By: Petr Spacek <pspacek@redhat.com>
2015-11-13 14:01:46 +01:00
Milan Kubik
0a64e9bd70 Applied tier0 and tier1 marks on unit tests and xmlrpc tests
Web UI tests were marked as tier1 tests.

The tier system is intended to be used together with CI system
to make sure the more complicated tests are being run only
when all of the basic functionality is working.

The system is using pytest's marker system. E.g. an invocation of
all tier1 tests with listing will look like:

    $ py.test -v -m tier1 ipatests

or in case of out of tree tests:

    $ ipa-run-tests -m tier1

Reviewed-By: Ales 'alich' Marecek <amarecek@redhat.com>
2015-11-09 11:49:17 +01:00
Abhijeet Kasurde
c60cec4fa7 Added user friendly error message for dnszone enable and disable
Added try-except block in dns plugin in order to provide user
friendly message to end user.

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

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-29 13:41:41 +01:00
Milan Kubík
5ab0fcabf3 ipatests: CA ACL and cert profile functional test
https://fedorahosted.org/freeipa/ticket/57

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-27 09:57:48 +01:00
Milan Kubík
8d64485b2e ipatests: CA ACL - added config templates
https://fedorahosted.org/freeipa/ticket/57

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-27 09:57:48 +01:00
Milan Kubík
897c9c9c43 tests: add test to check the default ACL
Also includes basic ACL manipulation and adding
and removing members to/from the acl.

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

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-27 09:57:48 +01:00
Milan Kubík
36f7074683 ipatests: Add initial CAACLTracker implementation
The patch implements the tracker for CA ACL feature.
The basic CRUD checkers has been implemented. The methods
for adding and removing the association of the resources
with the ACL do not have the check methods. These will be provided
as a separate test suite.

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

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-27 09:57:48 +01:00
Milan Kubík
30f0a034e1 ipatests: add fuzzy instances for CA ACL DN and RDN
https://fedorahosted.org/freeipa/ticket/57

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-27 09:57:48 +01:00
Martin Babinsky
af1f6721e1 fix class teardown in user plugin tests
https://fedorahosted.org/freeipa/ticket/5368

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-22 13:15:43 +02:00
Tomas Babej
eaeb40328c tests: Add tests for idoverride object integrity
As far as IPA objects are concerned, ID overrides are supposed
to be removed when the respective user/group is removed.

Adds a couple of tests to ensure this behaviour is covered.

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

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-10-14 16:11:25 +02:00
Martin Basti
16261adc58 Replace tab with space in test_user_plugin.py
Mixing tabs and spaces is not allowed in python3

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-10-14 10:14:51 +02:00
Petr Viktorin
905d81f500 ipalib.aci: Port to Python 3
- Don't encode under Python 3, where shlex would choke on bytes
- Sort the attrs dictionary in export_to_string, so the tests are
  deterministic. (The iteration order of dicts was always unspecified,
  but was always the same in practice under CPython 2.)

Reviewed-By: Tomas Babej <tbabej@redhat.com>
2015-10-13 14:16:32 +02:00
Tomas Babej
12840e0bfa tests: Amend result assertions in realmdomains tests
* Nonexistent domains have to be added/deleted with force
* Warning messages are emitted
* Some error messages have been altered

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

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-10-12 13:34:20 +02:00
Petr Viktorin
e3c05fcb73 Remove uses of the types module
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>
2015-10-07 10:27:20 +02:00
Robert Kuska
01da4a8de3 Replace StandardError with Exception
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>
2015-09-30 10:51:36 +02:00
Jan Cholasta
33aba6f35e Use byte literals where appropriate
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
2015-09-17 11:08:43 +02:00
Jan Cholasta
23507e6124 Alias "unicode" to "str" under Python 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>
2015-09-17 11:08:43 +02:00
Milan Kubík
1550b5ab50 ipatests: Add basic tests for certificate profile plugin
Reviewed-By: Lenka Doudova <ldoudova@redhat.com>
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
2015-09-16 18:51:56 +02:00
Milan Kubík
a4aace730c ipatests: Add Certprofile tracker class implementation
https://fedorahosted.org/freeipa/ticket/57

Reviewed-By: Lenka Doudova <ldoudova@redhat.com>
Reviewed-By: Fraser Tweedale <ftweedal@redhat.com>
2015-09-16 18:51:56 +02:00
Abhijeet Kasurde
1b70521e6b Updated number of legacy permission in ipatests
Since IPA 4.2 has an additional permission
"Request Certificate ignoring CA ACLs", the number of legacy
permission in testcase is updated from 8 to 9.

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

Signed off-by: Abhijeet Kasurde <akasurde@redhat.com>

Reviewed-By: Tomas Babej <tbabej@redhat.com>
2015-09-16 12:58:03 +02:00
Martin Basti
9ffe7f4998 FIX vault tests
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-09-09 14:27:56 +02:00
Petr Viktorin
5178e9a597 Modernize use of range()
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>
2015-09-01 11:42:01 +02:00
Petr Viktorin
8de13bd7dd Use the print function
In Python 3, `print` is no longer a statement. Call it as a function
everywhere, and include the future import to remove the statement
in Python 2 code as well.

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-09-01 11:42:01 +02:00
Petr Viktorin
ace63f4ea5 Replace uses of map()
In Python 2, map() returns a list; in Python 3 it returns an iterator.

Replace all uses by list comprehensions, generators, or for loops,
as required.

Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-09-01 11:42:01 +02:00
Petr Viktorin
3bf91eab25 Use Python3-compatible dict method names
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>
2015-09-01 11:42:01 +02:00
Petr Viktorin
dd16cc98b0 Use six.string_types instead of "basestring"
Reviewed-By: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-09-01 11:42:01 +02:00
Lenka Doudova
a78e751209 Fix user tracker to reflect new user-del message
Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-08-27 12:24:23 +02:00
Petr Vobornik
9b0a01930b vault: fix vault tests after default type change
https://fedorahosted.org/freeipa/ticket/5251

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-08-26 14:01:41 +02:00
Michael Simacek
aad73fad60 Port from python-krbV to python-gssapi
python-krbV library is deprecated and doesn't work with python 3. Replacing all
it's usages with python-gssapi.

- Removed Backend.krb and KRB5_CCache classes
  They were wrappers around krbV classes that cannot really work without them
- Added few utility functions for querying GSSAPI credentials
  in krb_utils module. They provide replacements for KRB5_CCache.
- Merged two kinit_keytab functions
- Changed ldap plugin connection defaults to match ipaldap
- Unified getting default realm
  Using api.env.realm instead of krbV call

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Reviewed-By: Robbie Harwood <rharwood@redhat.com>
Reviewed-By: Simo Sorce <ssorce@redhat.com>
2015-08-26 09:41:36 +02:00
Endi S. Dewata
e46d9236d1 Added support for changing vault encryption.
The vault-mod command has been modified to support changing vault
encryption attributes (i.e. type, password, public/private keys)
in addition to normal attributes (i.e. description). Changing the
encryption requires retrieving the stored secret with the old
attributes and rearchiving it with the new attributes.

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

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-08-25 19:11:53 +02:00
Lenka Doudova
a14c4b5001 Automated test for stageuser plugin
Ticket: https://fedorahosted.org/freeipa/ticket/3813
Test plan: http://www.freeipa.org/page/V4/User_Life-Cycle_Management/Test_Plan

Reviewed-By: Martin Basti <mbasti@redhat.com>
Reviewed-By: Thierry Bordaz <tbordaz@redhat.com>
2015-08-25 13:19:06 +02:00
Petr Viktorin
5435a8a32a Use absolute imports
In Python 3, implicit relative imports will not be supported.
Use fully-qualified imports everywhere.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
2015-08-12 18:17:23 +02:00
Petr Viktorin
27dabb4528 Modernize 'except' clauses
The 'as' syntax works from Python 2 on, and Python 3 will
drop the "comma" syntax.

Reviewed-By: Tomas Babej <tbabej@redhat.com>
2015-08-12 18:17:23 +02:00
Martin Babinsky
555229e33e test suite for user/host/service certificate management API commands
These tests excercise various scenarios when using new class of API commands
to add or remove certificates to user/service/host entries.

Part of http://www.freeipa.org/page/V4/User_Certificates

Reviewed-By: Milan Kubík <mkubik@redhat.com>
2015-08-03 14:40:12 +02:00
Milan Kubík
3f90aa0c18 tests: Allow Tracker.dn be an instance of Fuzzy
Some of the IPA LDAP entries are using ipaUniqueID as
the "primary key". To match this UUID based attribute
in assert_deepequal, an instance of Fuzzy class must
be used. This change adds the possibility to assign
the Fuzzy object as the DN for the tracked entry.

The user may need to override the rdn and name
properties for the class using the Fuzzy DN.

Reviewed-By: Lenka Doudova <ldoudova@redhat.com>
2015-07-31 15:50:05 +02:00
Petr Viktorin
b8c46f2a32 Modernize number literals
Use Python-3 compatible syntax, without breaking compatibility with py 2.7

- Octals literals start with 0o to prevent confusion
- The "L" at the end of large int literals is not required as they use
  long on Python 2 automatically.
- Using 'int' instead of 'long' for small numbers is OK in all cases except
  strict type checking checking, e.g. type(0).

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

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-07-31 15:22:19 +02:00
Tomas Babej
106e904337 tests: test_cert: Services can have multiple certificates
Old certificates of the services are no longer removed and revoked
after new ones have been issued.

Check that both old and new certificates are present.

Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-07-22 11:14:23 +02:00
Tomas Babej
8eb26e9230 tests: vault_plugin: Skip tests if KRA not available
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-07-22 11:13:06 +02:00
Tomas Babej
5f8fd8a8e3 tests: realmdomains_plugin: Add explanatory comment
The realmdomains_mod command will fail if the testing environment
is configured improperly and the IPA domain's NS/SOA records are
not resolvable. This can easily happen if the machine's DNS server
is not configured to the IPA server.

Leave a explanatory note in the class.

Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-07-22 11:10:49 +02:00
Tomas Babej
12395a94f3 tests: service_plugin: Make sure the cert is decoded from base64
Reviewed-By: Martin Babinsky <mbabinsk@redhat.com>
2015-07-22 11:09:59 +02:00
Tomas Babej
705603a396 tests: user_plugin: Add preserved flag when --all is used
Reviewed-By: Martin Basti <mbasti@redhat.com>
2015-07-21 18:59:40 +02:00
Martin Basti
c6c84faecf Py3: replace tab with space
python3 does not allow to mix spaces and tabs

Reviewed-By: Christian Heimes <cheimes@redhat.com>
2015-07-17 17:19:51 +02:00
Yuri Chornoivan
75fde43491 Fix minor typos
<ame> -> <name>
overriden -> overridden
ablity -> ability
enties -> entries
the the -> the

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

Reviewed-By: Petr Vobornik <pvoborni@redhat.com>
Reviewed-By: Christian Heimes <cheimes@redhat.com>
2015-07-17 14:33:30 +02:00
Endi S. Dewata
bf6df3df9b Added vault access control.
New LDAP ACIs have been added to allow vault owners to manage the
vaults and to allow members to access the vaults. New CLIs have
been added to manage the owner and member list. The LDAP schema
has been updated as well.

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

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-07-08 06:30:23 +00:00
Endi S. Dewata
475ade4bec Added ipaVaultPublicKey attribute.
A new attribute ipaVaultPublicKey has been added to replace the
existing ipaPublicKey used to store the vault public key.

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

Reviewed-By: Jan Cholasta <jcholast@redhat.com>
2015-07-07 07:44:56 +00:00