Skip to content

Conversation

@adamruzicka
Copy link
Contributor

@adamruzicka adamruzicka commented Oct 7, 2025

A recent change in Foreman dropped the option to assign (and override) organizations and locations on filters as well as the unlimited and override fields from api responses.

Problem Statement

Some tests use no-longer-available code paths, some tests don't make sense anymore.

Solution

Change the tests that make sense to the new way (aka orgs/locs on roles only), drop the ones that aren't relevant anymore.

Related Issues

https://issues.redhat.com/browse/SAT-28731
theforeman/foreman#10370
theforeman/hammer-cli-foreman#645

Requires SatelliteQE/nailgun#1363 and SatelliteQE/airgun#2141

@adamruzicka adamruzicka added the No-CherryPick PR doesnt need CherryPick to previous branches label Oct 7, 2025
@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py tests/foreman/api/test_role.py tests/foreman/cli/test_contentview.py tests/foreman/cli/test_filter.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py

@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13077
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_contentview.py --external-logging
Test Result : === 13 failed, 73 passed, 11 deselected, 1686 warnings in 3806.15s (1:03:26) ===

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Oct 8, 2025
@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13068
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_contentview.py tests/foreman/api/test_role.py tests/foreman/cli/test_contentview.py tests/foreman/cli/test_filter.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py --external-logging
Test Result : == 30 failed, 320 passed, 18 deselected, 8055 warnings in 31392.21s (8:43:12) ==

@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k 'test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup'

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13087
Build Status: SUCCESS
PRT Comment: pytest tests/foreman/api/test_contentview.py  tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or  test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup --external-logging
Test Result : ========= 9 passed, 318 deselected, 180 warnings in 1625.77s (0:27:05) =========

@Satellite-QE Satellite-QE added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Oct 9, 2025
@Satellite-QE Satellite-QE removed the PRT-Passed Indicates that latest PRT run is passed for the PR label Oct 9, 2025
@adamruzicka adamruzicka marked this pull request as ready for review October 9, 2025 13:05
@adamruzicka adamruzicka requested review from a team as code owners October 9, 2025 13:05
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `tests/foreman/cli/test_filter.py:53` </location>
<code_context>
     assert set(filter_['permissions'].split(", ")) == set(module_perms)


-def test_positive_create_with_org(module_perms, function_role, target_sat):
-    """Create a filter and assign it some permissions.
-
</code_context>

<issue_to_address>
**suggestion (testing):** Test for creating a filter with organization assignment has been removed.

Consider adding a negative test to verify that the CLI correctly rejects organization assignments to filters, ensuring the new behavior is covered.

Suggested implementation:

```python
import pytest


```

```python
def test_negative_create_with_org(cli_runner, module_perms, function_role, target_sat):
    """
    Negative test: Attempt to create a filter with organization assignment.
    The CLI should reject this and return an error.
    """
    org_id = "test-org"
    filter_name = "test-filter-with-org"
    permissions = ",".join(module_perms)
    # Attempt to create filter with organization assignment
    result = cli_runner.invoke(
        [
            "filter", "create",
            "--name", filter_name,
            "--permissions", permissions,
            "--organization", org_id
        ]
    )
    # Assert that the CLI returns a non-zero exit code or error message
    assert result.exit_code != 0
    assert "organization assignment is not allowed" in result.output.lower()

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k 'test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup'
theforeman:
foreman: 10370

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13093
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup --external-logging
Test Result : ==== 7 failed, 2 passed, 318 deselected, 158 warnings in 1648.55s (0:27:28) ====

@Satellite-QE Satellite-QE added the PRT-Failed Indicates that latest PRT run is failed for the PR label Oct 9, 2025
@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k 'test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup'
airgun: 2141
nailgun: 1363
theforeman:
foreman: 10370
hammer-cli-foreman: 645

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13106
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup --external-logging
Test Result : ==== 1 failed, 8 passed, 318 deselected, 178 warnings in 1873.71s (0:31:13) ====

@adamruzicka
Copy link
Contributor Author

The ui test failure is unrelated to the changes introduced here and is being fixed elsewhere

target_sat.api.HostCollection(server_config=cfg).create()


def test_negative_non_readonly_user_actions(target_sat, content_view, function_role, module_org):
Copy link
Contributor

@pondrejk pondrejk Oct 15, 2025

Choose a reason for hiding this comment

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

@adamruzicka if you are removing the fixture use in the test body, there's no need to include it here, this way I think the function_role still gets created for no use. otoh you could consider creating a different fixture function_role_with_org for a bit of a code reuse. Not sure how much the function_role gets used outside the tests you are touching, if it doesn't, you could add the org in that fixture as well I suppose

@adamruzicka adamruzicka requested a review from a team as a code owner October 15, 2025 10:01
@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k 'test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup'
nailgun: 1363
theforeman:
foreman: 10370
hammer-cli-foreman: 645

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13181
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup --external-logging
Test Result : ==== 2 failed, 7 passed, 318 deselected, 179 warnings in 1975.29s (0:32:55) ====

A recent change in Foreman dropped the option to assign (and override)
organizations and locations on filters as well as the unlimited and override
fields from api responses.
@adamruzicka
Copy link
Contributor Author

trigger: test-robottelo
pytest: tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k 'test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup'
nailgun: 1363
theforeman:
foreman: 10370
hammer-cli-foreman: 645

@Satellite-QE
Copy link
Collaborator

PRT Result

Build Number: 13186
Build Status: UNSTABLE
PRT Comment: pytest tests/foreman/api/test_contentview.py tests/foreman/cli/test_contentview.py tests/foreman/ui/test_activationkey.py tests/foreman/ui/test_errata.py tests/foreman/ui/test_role.py -k test_negative_readonly_user_actions or test_negative_non_readonly_user_actions or test_negative_user_with_read_only_cv_permission or test_positive_access_non_admin_user or test_positive_list_permission or test_positive_delete_cloned_builtin or test_positive_create_filter or default_role_permission_with_filter_setup --external-logging
Test Result : ==== 1 failed, 8 passed, 318 deselected, 182 warnings in 1976.02s (0:32:56) ====

@adamruzicka
Copy link
Contributor Author

Guess theforeman/foreman#10717 hasn't landed in stream yet

Copy link
Contributor

@pnovotny pnovotny left a comment

Choose a reason for hiding this comment

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

LGTM

@pnovotny
Copy link
Contributor

The one failure in PRT in test_positive_create_filter doesn't look connected to this PR. The test actually fails at later stage than in the last test execution without the PR changes. Thus, the failure can handled separately.
Marking as PRT-Passed.

@pnovotny pnovotny added PRT-Passed Indicates that latest PRT run is passed for the PR and removed PRT-Failed Indicates that latest PRT run is failed for the PR labels Oct 16, 2025
@pnovotny pnovotny merged commit 73e9003 into SatelliteQE:master Oct 16, 2025
11 of 12 checks passed
@adamruzicka adamruzicka deleted the no-filter-override branch November 18, 2025 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

No-CherryPick PR doesnt need CherryPick to previous branches PRT-Passed Indicates that latest PRT run is passed for the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants