Commit Graph

656 Commits

Author SHA1 Message Date
Thomas Woerner
c1d7ed1df6 Merge pull request #1335 from rjeffman/ipagroup_fix_1
ipagroup: Fix management of AD objects
2025-02-03 13:43:35 +01:00
Thomas Woerner
f27b0e3011 Merge pull request #1334 from rjeffman/update_c10s_image
Update c10s image
2025-01-31 16:03:32 +01:00
Rafael Guterres Jeffman
91c4b83311 Configure yamllint to be compatible with ansible-lint
Current version of ansible-list pre-commit hook required changes in the
ansible-freeipa yamllint configuration and these changes triggered
issues in the current playbooks on roles and tests.

This patch adds the required changes to yaml lint configuration and
fixes the affected playbooks.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-01-31 11:32:59 -03:00
Rafael Guterres Jeffman
6925503a10 ipagroup: Fix management of AD objects
When using AD objects, a user expects to use the more human readable
form, like "user@ad.domain", but this impose some dificulties on
evaluating which object is being referenced as AD has several forms to
refer to the same object.

Each object is AD is identified uniquely by its SID, and this is the
identifier that IPA stores in its database. When managing AD objects,
IPA finds its SID and works with that value.

ansible-freeipa tried to process these objects using the human readable
values, and it cause idempontence error when ensuring the values were
present or modified, and, at least in some cases, prevented the objects
to be made absent, as the object list created didn't match the SID to
the value used as module parameter.

By using SID to process the AD objects in ipagroup, the addition or
removal of members works and idempotence of these members is ensured.

The only issue with thils approach is that it only works no server
nodes. In client nodes, the conversion to SID is not available and the
same issues that existed before will still be present.

Tests were updated to reflect these changes, a new test, specific to
idempotence issues of AD objects was added:

   tests/group/test_group_ad_users.yml

Resolves: https://issues.redhat.com/browse/RHEL-70023
2025-01-31 10:29:48 -03:00
Rafael Guterres Jeffman
f5f454915c tests/idoverrideuser: Fix client context test when running on client
When running test_idoverrideuser_client_context.yml on a client host, it
tried to run a task that does not have the required fields and fails
the test.

Signed-off-by: Rafael Guterres Jeffman <rjeffman@redhat.com>
2025-01-29 00:56:56 -03:00
Rafael Guterres Jeffman
8581b79eba tests: Improve FreeIPA facts
This patch improves tests/env_freeipa_facts.yml by ensuring
ipaserver_realm is set, making AD server availability discoverable, and
allowing playbooks to run with 'gather_facts: false' by gathering
minimal facts.
2025-01-29 00:41:38 -03:00
Thomas Woerner
81906edec6 Merge pull request #1322 from rjeffman/rhel70023
ipagroup: Correctly handle externalmember in member actions
2024-12-12 12:02:37 +01:00
Thomas Woerner
5071653db3 Merge pull request #1321 from rjeffman/rhel-68439
ipasudorule: Evaluate all members related to hosts and users
2024-12-12 11:27:01 +01:00
Rafael Guterres Jeffman
df4ec30a51 ipasudorule: Evaluate all members related to hosts and users
When handling users and hosts is ipasudorule we were missing nome entry
attributes returned from FreeIPA, which would cause the add/del lists to
be incorrectly generated.

By adding the proper lists, both attributes are handled correctly.

A new test to verify the fix is added:

    tests/sudorule/test_sudorule_user_host_external.yml

Fixes https://issues.redhat.com/browse/RHEL-68439
2024-12-11 10:56:11 -03:00
Rafael Guterres Jeffman
431dc8667a ipagroup: Correctly handle externalmember in member actions
When creating the lists of external members, the attribute
'ipaexternalmember' also needs to be added to the list of external
members that are part of the group object for external groups.

A test to verify the correct behavior was added and the test suite for
group external members have been cleaned up with 'yes' values changed to
'true' and the use of module_defaults.
2024-12-10 08:25:49 -03:00
Rafael Guterres Jeffman
bc16ccaef7 ipacert: Revoking with removeFromCRL should be handled as cert release
When a revoked certificate with reason 6 (certificateHold) is revoked
with reason 8 (removeFromCRL), the effect is that the certificate is
valid again, as it is the same procedure as 'state: release'.

This is, at least, the behavior with IPA CLI comands, which is
implemented by this patch.

A new test is added to verify this behavior:

    tests/cert/test_cert_remove_hold_with_removeFromCRL.yml
2024-12-05 15:42:58 -03:00
Rafael Guterres Jeffman
6c94fe9bd5 tests/sudorule: Don't become or gather_facts and use only true/false
Unless there's a real need to use privileged access or to gather Ansible
facts upfront, we should always set "become: false" and
"gather_facts: false". In the case that only a few Ansible facts are
required, 'ansible.builtin.setup' with 'gather_subset' should be used.

As the YAML 1.2 standard dictates, boolean values should only use 'true'
or 'false' values.

This patch fixes these issues in the 'sudorule' test suite.
2024-11-18 11:59:51 -03:00
Rafael Guterres Jeffman
4fa0621156 ipasudorule: Add support for batch mode and multiple sudorules
Currently, ipasudorule must add or modify a single sudorule at a time,
incurring in more load in the server if there are many rules to be
processed.

This patch adds suport for adding multiple sudorules in one playbook
task by using the parameter 'sudorules' and defining a list of sudorules
configurations to be ensured.

As multiple sudorules will be processed, the patch also enables batch
mode processing of sudorules, trying to reduce the load on the server.

Test 'tests/sudorule/test_sudorule_client_context.yml' was modified to
include tasks with 'sudorules' to be executed both on the server or on
the client context.

New tests were added to the sudorule test suite:

    tests/sudorule/test_sudorules.yml
    tests/sudorule/test_sudorules_member_case_insensitive.yml
2024-11-18 11:59:21 -03:00
Rafael Guterres Jeffman
08a2ba1592 Merge pull request #1281 from t-woerner/multi_user_test_generate_test_data
tests/user/test_users_present_*: Use new generate_test_data.yml
2024-11-04 14:19:19 -03:00
Rafael Guterres Jeffman
2b28626012 Merge pull request #1275 from t-woerner/drop_superfluous_test_services_absent
test_services_absent is also part of test_services_present, not needed
2024-11-04 14:06:58 -03:00
Rafael Guterres Jeffman
77c34aeca2 upstream ci: Move Azure scripts to infra directory
Move Azure scripts to infra directory, as only roles and modules test
playbooks should exist in the tests directory.
2024-10-31 11:06:41 -03:00
Rafael Guterres Jeffman
5b33cb5e80 Remove molecule dependencies
For some time now, we had some issues with molecule when building test
images for ansible-freeipa, and replaced the image creation with custom
build scripts that use commom container tools (like Dockerfiles and the
build command).

As there's no more tasks that require the use of molecule, this patch
removes the last bits used by it, and fixes documentation and lint
scripts and configuration.
2024-10-31 11:06:41 -03:00
Rafael Guterres Jeffman
57bc35df80 ipacert: Fix ipacert tests
It seems that in recent versions, a minimum of 2048 bits for RSA keys
are required to request a certificate. This seems to be enforced by
crypto policies.

By adjusting the key size all ipacert tests pass.
2024-10-30 08:19:53 -03:00
Thomas Woerner
2b10256575 test_services_absent is also part of test_services_present, not needed
This test is not needed as it is already part of test_services_present.
2024-10-11 15:51:39 +02:00
Thomas Woerner
907650c746 tests/user/test_users_present_*: Use new generate_test_data.yml
The new generate_test_data.yml is creating the test data with
ansible.builtin.shell and is not calling shell scripts any more. The
generation in the yml file and also the set_fact calls make sure that
the test data is used.
2024-10-11 15:51:14 +02:00
Thomas Woerner
02ba890eb4 tests/utils.py: Shorten run_playbook for smaller traceback with assert
Most of the content has been moved to the new function _run_playbook to
reduce the traceback output in the case of a test failure.
2024-08-02 17:21:58 +02:00
Rafael Guterres Jeffman
8515c9a48b upstream ci: Remove 'molecule' from tests.
This patch removes 'molecule' as a dependency for tests, by using the
scripts under `utils` to setup the environment.

By not using molecule, we have more flexibility on using either docker
or podman as the container engine, and makes it easy to reproduce the
environment on different distros, allowing for a more consistent error
reproduction off Azure.
2024-08-02 17:21:58 +02:00
Rafael Guterres Jeffman
7aa9483b2c tests: Allow to set Python interpreter to be used by Ansible
On some systems it is required or desired to run Ansible with a specific
Python interpreter. This patch allows the selection of the Python binary
to use for the pytest playbook tests by setting the environment variable
IPA_PYTHON_PATH. Set it the the full path of the Python interpreter.
2024-08-02 17:21:47 +02:00
f-trivino
0c6a7c8a14 Merge pull request #1273 from t-woerner/new_image_build_with_podman
New image builder without molecule using podman
2024-07-31 17:09:21 +02:00
Rafael Guterres Jeffman
480c83f504 fixup! New image builder without molecule using podman 2024-07-31 16:10:02 +02:00
Rafael Guterres Jeffman
928ed30b8b ustream ci: Use infra scripts to build testing images
As we do not use molecule features, using a Dockerfile and the
ansible-freeipa deployment roles is enough to create the container
testing images.

This patch removes the usage of molecule in favor of the custom
ansible-freeipa image building script, which allow us to have a similar
process for creating images both on the ustream CI, or on a developer's
environment.

Also, CentOS 7 is removed from the build script, as it in not possible
to run CentOS 7 containers with current versions of systemd.
2024-07-31 16:10:02 +02:00
Thomas Woerner
7ac0ec6bd4 tests/azure/templates/build_container.yml: Use new image builder
The new infra/image/build.sh script is used instead of molecule.
2024-07-31 16:10:02 +02:00
Rafael Guterres Jeffman
0002d4c7f7 Merge pull request #1274 from t-woerner/fix_multi_user_tests
Fix multi user tests
2024-07-22 11:40:10 -03:00
Thomas Woerner
a95c222ed6 Fix multi user tests
The tests test_users_present.yml and test_users_absent.yml has been
merged into test_users_present_absent.yml to fix the independent test
order execution.

The test test_users_present_slice.yml has been renamed to
test_users_present_absent_slice.yml.

Both tests are cleaning up possible exiting entries before running the tests
and are verifying the present and absent task result.
2024-07-22 16:29:19 +02:00
Rafael Guterres Jeffman
d9a20e16c1 Merge pull request #1272 from t-woerner/add_missing_cleanup_for_test_services_present
tests/service/test_services_present.yml: Add missing cleanup
2024-07-22 11:26:45 -03:00
Thomas Woerner
e71602be6e tests/service/test_services_present.yml: Add missing cleanup
The cleanup of the test services and hosts have been missing, which
could lead to a test failure.
2024-07-19 17:08:20 +02:00
Thomas Woerner
3dfa026eda Truncate stdout and stderr in upstream test log
Truncate stdout and stderr in the way that it hopefully shows all
important information. At least 15 lines of stdout (Ansible tasks) and
remaining from stderr to fill up to maxlen size.

The test log mostly only showed lines from stderr as the log was a
concatenation of stdout and stderr and only the last 2500 chars of this
have been used. This was hiding the test result from stdout and failures
have not beeen visible.
2024-07-17 10:54:30 +02:00
Thomas Woerner
7b6bc32fa0 tests/utils.py: Fix missing whitespace around arithmetic operator (E226) 2024-07-01 11:31:13 +02:00
Rafael Guterres Jeffman
719d1cd056 Merge pull request #1263 from t-woerner/tests_sanity_setuptools
tests/sanity/sanity.sh: Install setuptools with pip
2024-06-28 12:29:42 -03:00
Thomas Woerner
e867373fc0 tests/sanity/sanity.sh: Install setuptools with pip
setuptools might not be installed before importing and using
galaxy_importer. This could result in a backtrace by disabling
ANSIBLE_TEST_LOCAL_IMAGE in galaxy-importer.cfg to run latest tests.
2024-06-28 17:08:16 +02:00
Thomas Woerner
173acf282b permission: Fix idempotency issues for DN parameters
The parameters

- subtree (ipapermlocation)
- target (ipapermtarget)
- targetto (ipapermtargetto)
- targetfrom (ipapermtargetfrom)

have not been idempotent as the result returned from permission_show was
a DN and not a string.

The find_permission function has been exetended to convert the values
for these parameters to strings.

Fixes: #1257
2024-06-26 14:57:28 +02:00
Thomas Woerner
b92da82661 Fix ca-less test to use X.509 v3 certificates
The generated certificates have been X.509 v1. This is not supported any
more. Only X.509 v3 is supported.

A new certificates/extensions.conf file has been added to make v3
certificates.

The existing certificates/pkinit/extensions.conf has been renamed to
certificates/pkinit-extensions.conf with additional changes. For example
"[kdc_cert]" had to be removed for v3.

The extensions config files are using environment variables, which are
set by the generate-certificates.sh script before calling openssl.

The script generate-certificates.sh has been reworked for a simpler
structure, also new options have been added: "ca" and "cleanup".
2024-03-05 11:17:17 +01:00
Thomas Woerner
a3a6919416 Merge pull request #760 from rjeffman/ipadelegation_case_insensitive
ipadelegation: Fix idempotence issues due to capitalization.
2024-02-12 15:33:30 +01:00
Rafael Guterres Jeffman
e9c6e93608 ipadelegation: Fix idempotence issues due to capitalization.
This patch force processing of permission, attribute and group
attributes in lower case, to match behavior of IPA CLI, transforming
all of them into lowercase characters.

The new behavior fixes idempotence issues when mixing different
capitalization in different tasks for the same attribute.

A new test playbook is avaiable at:

    tests/delegation/test_delegation_member_case_insensitive.yml
2024-02-12 11:10:21 -03:00
Rafael Guterres Jeffman
7b7d9c9957 ipagroup: Fix idempotence issues due to capitalization
Some attributes for ipagroup objects are stored using lower case letters
and should be converted upon retrieving parameter data.

This patch adds the missing conversion and provides a new test playbook:

    tests/group/test_group_case_insensitive.yml
2024-02-12 09:11:12 -03:00
Rafael Guterres Jeffman
c0c3394d8d Merge pull request #1211 from t-woerner/disable_config_tests_for_pac_type_without_MS-PAC
Disable config tests for pac type without ms pac
2024-02-12 09:09:06 -03:00
Thomas Woerner
11205102af Merge pull request #1202 from rjeffman/ipahostgroup_idempotence_issues
ipahostgroup: Fix idempotence issues due to capitalization
2024-02-12 11:45:05 +01:00
Rafael Guterres Jeffman
22401d18d6 ipahostgroup: Fix idempotence issues due to capitalization
ipahostgroup parameters 'host', 'hostgroup', 'membermanager_user' and
'membermanager_group' must be compared in a case insensitive manner
and stored as lower case strings.

This patch fixes the comparison and storage of this parameters, and
change the handling of members to use the same structure as in newer
modules.

Two new tests files were added:

    tests/hostgroup/test_hostgroup_case_insensitive.yml
    tests/hostgroup/test_hostgroup_membermanager_case_insensitive.yml
2024-02-09 21:19:58 -03:00
Thomas Woerner
9b5a54c4fa Merge pull request #1203 from rjeffman/ipahbacrule_fix_idempotence_issues
ipahbacrule: Fix handling of hbacsvcgroup in members
2024-02-09 19:49:28 +01:00
Thomas Woerner
9920a76777 config: Disable config tests due to pac type requirement MS-PAC
The config tests are currently setting the pac type to empty or without
MS-PAC type. This results in failed authorization for IPA API.

An issue has been opened for FreeIPA to address this:
https://pagure.io/freeipa/issue/9527
2024-02-09 14:43:46 +01:00
Rafael Guterres Jeffman
b87b346a0a ipahbacrule: Fix handling of hbacsvcgroup in members
FreeIPA provides a default hbacsvcgroup named "Sudo", with capital 'S',
that is different from every other hbacsvcgroup, which are all
represented by lower case letters.

As data from IPA API was not modified, this causes an idempotence error
when using different capitalization with the 'hbacsvcgroup' parameter.

This patch fixes the issue by using the CaseInsensitive comparator to
create the hbacsvcgroup list.

Tests were update to make sure a regression is not included in the
future.
2024-02-06 16:29:04 -03:00
Rafael Guterres Jeffman
1fde1764af ipasudorule: Allow setting groups for runasuser.
On IPA CLI sudorule-add/del-runasuser accept 'group' as a parameter,
and this option was missing in ansible-freeipa ipasudorule module.

This patch adds a new parameter 'runasuser_group' to allow setting
Groups of RunAs Users, as allowed by CLI and WebUI.

New example playboks can be found at:

    playbooks/sudorule/ensure-sudorule-runasusesr-group-is-absent.yml
    playbooks/sudorule/ensure-sudorule-runasusesr-group-is-present.yml
2024-01-23 12:04:02 -03:00
Thomas Woerner
4321478cf0 Merge pull request #1178 from rjeffman/ipagroup_rename
ipagroup: Add support for renaming groups
2023-12-21 20:47:47 +01:00
Rafael Guterres Jeffman
1ecdbd3a49 ipagroup: Add support for renaming groups
FreeIPA suports renaming groupobjects with the CLI parameter "rename",
and this parameter was missing in ansible-freeipa ipagroup module.

This patch adds support for a new state 'renamed' and the 'rename'
parameter.

Tests were updated to cope with the changes.
2023-12-20 11:29:22 -03:00
Thomas Woerner
47a1d50c84 Fixes for ansible-lint 6.22.1
- Replace outdated noqa 503 with noqa no-handler
- Drop outdated and not needed noqa 505 for include_vars
- Drop outdated noqa deprecated-command-syntax for
  ansible.builtin.shell using cmd tag

These warnings have been reported by utils/lint_check.sh using
ansible-lint 6.22.1.
2023-12-20 14:38:24 +01:00