Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix creating modulemd filters #1614

Merged
merged 1 commit into from
May 31, 2023
Merged
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
2 changes: 2 additions & 0 deletions changelogs/fragments/1608-cv-filter-modulemd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- content_view_filter - don't fail when creating a modulemd filter (https://github.com/theforeman/foreman-ansible-modules/issues/1608, https://bugzilla.redhat.com/show_bug.cgi?id=2208557)
2 changes: 1 addition & 1 deletion plugins/modules/content_view_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def main():
foreman_spec=content_filter_spec,
)

if content_view_filter is not None:
if content_view_filter is not None and module.foreman_params['filter_type'] not in ['modulemd']:
cv_filter_scope = {'content_view_filter_id': content_view_filter['id']}
if 'errata_id' in module.foreman_params:
# should we try to find the errata the user is asking for? or just pass it blindly?
Expand Down
16 changes: 16 additions & 0 deletions tests/test_playbooks/content_view_filter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
repositories:
- name: "Test Repository"
product: "Test Product"
- include_tasks: tasks/content_view_filter_modulemd.yml
vars:
filter_state: absent

- hosts: tests
collections:
Expand Down Expand Up @@ -171,6 +174,19 @@
rule_state: absent
expected_change: true

- name: Test Content View Filter modulemd
block:
- include_tasks: tasks/content_view_filter_modulemd.yml
vars:
expected_change: true
- include_tasks: tasks/content_view_filter_modulemd.yml
vars:
expected_change: false
- include_tasks: tasks/content_view_filter_modulemd.yml
vars:
filter_state: absent
expected_change: true

- hosts: localhost
collections:
- theforeman.foreman
Expand Down
300 changes: 300 additions & 0 deletions tests/test_playbooks/fixtures/content_view_filter-28.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,300 @@
interactions:
- request:
body: null
headers:
Accept:
- application/json;version=2
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://foreman.example.org/api/status
response:
body:
string: '{"result":"ok","status":200,"version":"3.7.0-develop","api_version":2}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '70'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.7.0-develop
Keep-Alive:
- timeout=15, max=100
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
X-Content-Type-Options:
- nosniff
X-Download-Options:
- noopen
X-Frame-Options:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json;version=2
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://foreman.example.org/katello/api/organizations?search=name%3D%22Test+Organization%22&per_page=4294967296
response:
body:
string: "{\n \"total\": 2,\n \"subtotal\": 1,\n \"page\": 1,\n \"per_page\":
4294967296,\n \"search\": \"name=\\\"Test Organization\\\"\",\n \"sort\":
{\n \"by\": null,\n \"order\": null\n },\n \"results\": [{\"label\":\"Test_Organization\",\"created_at\":\"2023-05-31
10:12:33 UTC\",\"updated_at\":\"2023-05-31 10:12:37 UTC\",\"id\":4,\"name\":\"Test
Organization\",\"title\":\"Test Organization\",\"description\":\"A test organization\"}]\n}\n"
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '388'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.7.0-develop
Keep-Alive:
- timeout=15, max=99
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
X-Content-Type-Options:
- nosniff
X-Download-Options:
- noopen
X-Frame-Options:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json;version=2
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://foreman.example.org/katello/api/organizations/4/content_views?search=name%3D%22Test+Content+View%22&per_page=4294967296
response:
body:
string: '{"total":2,"subtotal":1,"selectable":1,"page":1,"per_page":"4294967296","error":null,"search":"name=\"Test
Content View\"","sort":{"by":"name","order":"asc"},"results":[{"composite":false,"component_ids":[],"default":false,"version_count":0,"latest_version":null,"latest_version_id":null,"auto_publish":false,"solve_dependencies":false,"import_only":false,"generated_for":"none","related_cv_count":0,"related_composite_cvs":[],"needs_publish":true,"filtered":false,"repository_ids":[4],"id":5,"name":"Test
Content View","label":"Test_Content_View","description":null,"organization_id":4,"organization":{"name":"Test
Organization","label":"Test_Organization","id":4},"created_at":"2023-05-31
10:12:52 UTC","updated_at":"2023-05-31 10:12:52 UTC","last_task":null,"latest_version_environments":[],"repositories":[{"id":4,"name":"Test
Repository","label":"Test_Repository","content_type":"yum"}],"versions":[],"components":[],"content_view_components":[],"activation_keys":[],"hosts":[],"next_version":"1.0","last_published":null,"environments":[]}]}

'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '1047'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- 4; Test Organization
Foreman_version:
- 3.7.0-develop
Keep-Alive:
- timeout=15, max=98
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
X-Content-Type-Options:
- nosniff
X-Download-Options:
- noopen
X-Frame-Options:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json;version=2
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://foreman.example.org/katello/api/content_views/5/filters?search=name%3D%22Test+Content+View+Filter+-+modulemd%22&per_page=4294967296
response:
body:
string: '{"total":0,"subtotal":0,"selectable":0,"page":1,"per_page":"4294967296","error":null,"search":"name=\"Test
Content View Filter - modulemd\"","sort":{"by":"name","order":"asc"},"results":[]}

'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '190'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.7.0-develop
Keep-Alive:
- timeout=15, max=97
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
X-Content-Type-Options:
- nosniff
X-Download-Options:
- noopen
X-Frame-Options:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-XSS-Protection:
- 1; mode=block
status:
code: 200
message: OK
- request:
body: '{"name": "Test Content View Filter - modulemd", "type": "modulemd", "inclusion":
false, "repository_ids": []}'
headers:
Accept:
- application/json;version=2
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '109'
Content-Type:
- application/json
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: POST
uri: https://foreman.example.org/katello/api/content_views/5/filters
response:
body:
string: ' {"inclusion":false,"original_module_streams":false,"id":3,"name":"Test
Content View Filter - modulemd","description":null,"created_at":"2023-05-31
10:12:54 UTC","updated_at":"2023-05-31 10:12:54 UTC","content_view":{"composite":false,"component_ids":[],"default":false,"version_count":0,"latest_version":null,"latest_version_id":null,"auto_publish":false,"solve_dependencies":false,"import_only":false,"generated_for":"none","related_cv_count":0,"related_composite_cvs":[],"needs_publish":true,"filtered":true,"repository_ids":[4],"id":5,"name":"Test
Content View","label":"Test_Content_View","description":null,"organization_id":4,"organization":{"name":"Test
Organization","label":"Test_Organization","id":4},"created_at":"2023-05-31
10:12:52 UTC","updated_at":"2023-05-31 10:12:52 UTC","last_task":null,"latest_version_environments":[],"repositories":[{"id":4,"name":"Test
Repository","label":"Test_Repository","content_type":"yum","product":{"id":3,"name":"Test
Product"},"content_counts":{"docker_manifest":0,"docker_tag":0,"rpm":0,"package":0,"package_group":0,"erratum":0,"module_stream":0}}],"versions":[],"components":[],"content_view_components":[],"activation_keys":[],"hosts":[],"next_version":"1.0","last_published":null,"environments":[]},"repositories":[],"type":"modulemd","rules":[]}

'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '1303'
Content-Security-Policy:
- 'default-src ''self''; child-src ''self''; connect-src ''self'' ws: wss:;
img-src ''self'' data:; script-src ''unsafe-eval'' ''unsafe-inline'' ''self'';
style-src ''unsafe-inline'' ''self'''
Content-Type:
- application/json; charset=utf-8
Foreman_api_version:
- '2'
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.7.0-develop
Keep-Alive:
- timeout=15, max=96
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
X-Content-Type-Options:
- nosniff
X-Download-Options:
- noopen
X-Frame-Options:
- sameorigin
X-Permitted-Cross-Domain-Policies:
- none
X-XSS-Protection:
- 1; mode=block
status:
code: 201
message: Created
version: 1
Loading