Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
======

Expand All @@ -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
======
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
3 changes: 0 additions & 3 deletions changelogs/fragments/240-bump-ansible-lint-version.yml

This file was deleted.

3 changes: 3 additions & 0 deletions changelogs/fragments/add_tests_prune_auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
test_fixes:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_fixes isn't a valid section. Please see

- Add unit tests for ``openshift_adm_prune_auth`` module_utils to ensure correct user pruning and API error handling.
3 changes: 0 additions & 3 deletions changelogs/fragments/ansible-lint-update.yml

This file was deleted.

3 changes: 0 additions & 3 deletions changelogs/fragments/readme_template_update.yml

This file was deleted.

81 changes: 81 additions & 0 deletions tests/unit/plugins/module_utils/test_openshift_adm_prune_auth.py
Original file line number Diff line number Diff line change
@@ -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"