diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b64296be..45ba7d3e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,25 @@ OKD Collection Release Notes .. contents:: Topics +v5.0.0 +====== + +Release Summary +--------------- + +This release drops support for ansible-lint < 25.1.2 and removes deprecated openshift inventory plugin. + +Breaking Changes / Porting Guide +-------------------------------- + +- Remove openshift inventory plugin deprecated in 3.0.0 (https://github.com/openshift/community.okd/pull/252). + +Minor Changes +------------- + +- Bump version of ansible-lint to 25.1.2 (https://github.com/openshift/community.okd/pull/255). +- Bump version of ansible-lint to minimum 24.7.0 (https://github.com/openshift/community.okd/pull/240). + v4.0.2 ====== @@ -15,10 +34,15 @@ This patch updates the k8s dependency version to the 5.x range and modifies test v4.0.1 ====== -Bugfixes --------- +Release Summary +--------------- + +This is a bug fix release + +Minor Changes +------------- -- openshift_auth - fix issue where openshift_auth module sometimes does not delete the auth token (https://github.com/openshift/community.okd/pull/242) +- openshift_auth - fix issue where openshift_auth module sometimes does not delete the auth token. Based on stale PR (https://github.com/openshift/community.okd/pull/194). v4.0.0 ====== diff --git a/README.md b/README.md index a5812b93..ca2cd02d 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ You can also include it in a `requirements.yml` file and install it via `ansible --- collections: - name: community.okd - version: 4.0.2 + version: 5.0.0 ``` ### Installing the Kubernetes Python Library diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index ed607bf3..ed794f07 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -244,8 +244,8 @@ releases: 4.0.1: changes: minor_changes: - - openshift_auth - fix issue where openshift_auth module sometimes does not delete the auth - token. Based on stale PR (https://github.com/openshift/community.okd/pull/194). + - openshift_auth - fix issue where openshift_auth module sometimes does not + delete the auth token. Based on stale PR (https://github.com/openshift/community.okd/pull/194). release_summary: This is a bug fix release fragments: - 242-fix-failed-token-deletion.yml @@ -257,3 +257,17 @@ releases: fragments: - 4.0.2.yml release_date: '2025-05-28' + 5.0.0: + changes: + breaking_changes: + - Remove openshift inventory plugin deprecated in 3.0.0 (https://github.com/openshift/community.okd/pull/252). + minor_changes: + - Bump version of ansible-lint to 25.1.2 (https://github.com/openshift/community.okd/pull/255). + - Bump version of ansible-lint to minimum 24.7.0 (https://github.com/openshift/community.okd/pull/240). + release_summary: This release drops support for ansible-lint < 25.1.2 and removes deprecated openshift inventory plugin. + fragments: + - 240-bump-ansible-lint-version.yml + - 5.0.0.yml + - ansible-lint-update.yml + - readme_template_update.yml + release_date: '2025-06-10' diff --git a/changelogs/fragments/240-bump-ansible-lint-version.yml b/changelogs/fragments/240-bump-ansible-lint-version.yml deleted file mode 100644 index a29bad2a..00000000 --- a/changelogs/fragments/240-bump-ansible-lint-version.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - Bump version of ansible-lint to minimum 24.7.0 (https://github.com/openshift/community.okd/pull/240). diff --git a/changelogs/fragments/add_tests_prune_auth.yml b/changelogs/fragments/add_tests_prune_auth.yml new file mode 100644 index 00000000..27b773db --- /dev/null +++ b/changelogs/fragments/add_tests_prune_auth.yml @@ -0,0 +1,3 @@ +--- +test_fixes: + - Add unit tests for ``openshift_adm_prune_auth`` module_utils to ensure correct user pruning and API error handling. diff --git a/changelogs/fragments/ansible-lint-update.yml b/changelogs/fragments/ansible-lint-update.yml deleted file mode 100644 index f1956919..00000000 --- a/changelogs/fragments/ansible-lint-update.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -minor_changes: - - Bump version of ansible-lint to 25.1.2 (https://github.com/openshift/community.okd/pull/255). diff --git a/changelogs/fragments/readme_template_update.yml b/changelogs/fragments/readme_template_update.yml deleted file mode 100644 index 421756ad..00000000 --- a/changelogs/fragments/readme_template_update.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- -trivial: - - Update the README doc to match https://access.redhat.com/articles/7068606. diff --git a/tests/unit/plugins/module_utils/test_openshift_adm_prune_auth.py b/tests/unit/plugins/module_utils/test_openshift_adm_prune_auth.py new file mode 100644 index 00000000..3ec9797b --- /dev/null +++ b/tests/unit/plugins/module_utils/test_openshift_adm_prune_auth.py @@ -0,0 +1,81 @@ +from __future__ import (absolute_import, division, print_function) +__metaclass__ = type + +from unittest.mock import MagicMock, patch, PropertyMock +from ansible_collections.community.okd.plugins.module_utils.openshift_adm_prune_auth import OpenShiftAdmPruneAuth + +COMMON = 'ansible_collections.community.okd.plugins.module_utils.openshift_common.AnsibleOpenshiftModule' + + +class TestOpenShiftAdmPruneAuth: + + @patch(f'{COMMON}.kubernetes_facts', create=True) + @patch(f'{COMMON}.find_resource', create=True) + @patch(f'{COMMON}.__init__', return_value=None) + @patch(f'{COMMON}.params', new_callable=PropertyMock) + @patch(f'{COMMON}.check_mode', new_callable=PropertyMock) + def test_update_security_context_success(self, mock_check, mock_params, mock_init, mock_find, mock_facts): + mock_params.return_value = {'resource': 'users'} + mock_check.return_value = False + module = OpenShiftAdmPruneAuth() + + mock_facts.return_value = { + "api_found": True, + "resources": [ + { + "metadata": {"name": "restricted"}, + "users": ["alice", "bob"] + } + ] + } + + mock_res = MagicMock() + mock_find.return_value = mock_res + + candidates, changed = module.update_security_context(ref_names=["alice"], key="users") + + assert changed is True + assert "restricted" in candidates + + sent_data = mock_res.apply.call_args[0][0] + assert "alice" not in sent_data["users"] + assert "bob" in sent_data["users"] + + @patch(f'{COMMON}.kubernetes_facts', create=True) + @patch(f'{COMMON}.find_resource', create=True) + @patch(f'{COMMON}.__init__', return_value=None) + @patch(f'{COMMON}.params', new_callable=PropertyMock) + def test_update_security_context_no_change(self, mock_params, mock_init, mock_find, mock_facts): + mock_params.return_value = {'resource': 'users'} + module = OpenShiftAdmPruneAuth() + + mock_facts.return_value = { + "api_found": True, + "resources": [{"metadata": {"name": "any"}, "users": ["bob"]}] + } + + candidates, changed = module.update_security_context(ref_names=["alice"], key="users") + + assert changed is False + assert len(candidates) == 0 + assert mock_find.return_value.apply.called is False + + @patch(f'{COMMON}.kubernetes_facts', create=True) + @patch(f'{COMMON}.find_resource', create=True) + @patch(f'{COMMON}.__init__', return_value=None) + @patch(f'{COMMON}.params', new_callable=PropertyMock) + @patch(f'{COMMON}.fail_json') + def test_update_security_context_not_found(self, mock_fail, mock_params, mock_init, mock_find, mock_facts): + mock_params.return_value = {'resource': 'users'} + module = OpenShiftAdmPruneAuth() + + mock_facts.return_value = { + "api_found": False, + "resources": [], + "msg": "API not found" + } + + module.update_security_context(ref_names=["alice"], key="users") + + assert mock_fail.called + assert mock_fail.call_args[1]['msg'] == "API not found"