Skip to content

Commit

Permalink
don't fail when removing a content credential from a repository
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Jul 26, 2023
1 parent 7e36b39 commit 8ff176d
Show file tree
Hide file tree
Showing 24 changed files with 1,680 additions and 995 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/bz2224122-repo-org-scope.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- repository - don't fail when removing a content credential from a repository (https://bugzilla.redhat.com/show_bug.cgi?id=2224122)
2 changes: 2 additions & 0 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,8 @@ def lookup_entity(self, key, params=None):
return result

def _lookup_entity(self, identifier, entity_spec, params=None):
if identifier is NoEntity:
return NoEntity
resource_type = entity_spec['resource_type']
failsafe = entity_spec.get('failsafe', False)
thin = entity_spec.get('thin', True)
Expand Down
78 changes: 39 additions & 39 deletions tests/test_playbooks/fixtures/repository-0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ interactions:
uri: https://foreman.example.org/api/status
response:
body:
string: '{"result":"ok","status":200,"version":"3.3.0","api_version":2}'
string: '{"result":"ok","status":200,"version":"3.7.0","api_version":2}'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '62'
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'';
Expand All @@ -33,13 +35,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.3.0
- 3.7.0
Keep-Alive:
- timeout=15, max=100
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down Expand Up @@ -68,17 +68,18 @@ interactions:
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\":\"2022-09-14 11:27:41 UTC\",\"updated_at\"\
:\"2022-09-14 11:27:43 UTC\",\"id\":6,\"name\":\"Test Organization\",\"title\"\
:\"Test Organization\",\"description\":\"A test organization\"}]\n}\n"
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-06-23
11:37:20 UTC\",\"updated_at\":\"2023-06-23 11:37:22 UTC\",\"id\":3,\"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'';
Expand All @@ -92,13 +93,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.3.0
- 3.7.0
Keep-Alive:
- timeout=15, max=99
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand All @@ -124,20 +123,23 @@ interactions:
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://foreman.example.org/katello/api/organizations/6/products?search=name%3D%22Test+Product%22&per_page=4294967296
uri: https://foreman.example.org/katello/api/organizations/3/products?search=name%3D%22Test+Product%22&per_page=4294967296
response:
body:
string: '{"total":1,"subtotal":1,"selectable":1,"page":1,"per_page":"4294967296","error":null,"search":"name=\"Test
Product\"","sort":{"by":"name","order":"asc"},"results":[{"id":21,"cp_id":"160566138145","name":"Test
Product","label":"Test_Product","description":"A happy little test product","provider_id":9,"sync_plan_id":null,"sync_summary":{},"gpg_key_id":null,"ssl_ca_cert_id":null,"ssl_client_cert_id":null,"ssl_client_key_id":null,"sync_state":null,"last_sync":null,"last_sync_words":null,"organization_id":6,"organization":{"name":"Test
Organization","label":"Test_Organization","id":6},"sync_plan":null,"repository_count":0}]}
Product\"","sort":{"by":"name","order":"asc"},"results":[{"id":1,"cp_id":"830157316014","name":"Test
Product","label":"Test_Product","description":"A happy little test product","provider_id":3,"sync_plan_id":null,"sync_summary":{},"gpg_key_id":null,"ssl_ca_cert_id":null,"ssl_client_cert_id":null,"ssl_client_key_id":null,"sync_state":null,"last_sync":"2023-06-23
11:37:27 UTC","last_sync_words":"about 1 month","organization_id":3,"organization":{"name":"Test
Organization","label":"Test_Organization","id":3},"sync_plan":null,"repository_count":1}]}
'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '659'
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'';
Expand All @@ -149,15 +151,13 @@ interactions:
Foreman_current_location:
- ; ANY
Foreman_current_organization:
- 6; Test Organization
- 3; Test Organization
Foreman_version:
- 3.3.0
- 3.7.0
Keep-Alive:
- timeout=15, max=98
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand All @@ -183,18 +183,20 @@ interactions:
User-Agent:
- apypie (https://github.com/Apipie/apypie)
method: GET
uri: https://foreman.example.org/katello/api/products/21/repositories?search=name%3D%22Test+Repository%22&per_page=4294967296
uri: https://foreman.example.org/katello/api/products/1/repositories?search=name%3D%22Test+Repository%22&per_page=4294967296
response:
body:
string: '{"total":0,"subtotal":0,"selectable":0,"page":1,"per_page":"4294967296","error":null,"search":"name=\"Test
Repository\"","sort":{"by":"name","order":"asc"},"results":[]}
string: '{"total":1,"subtotal":0,"selectable":0,"page":1,"per_page":"4294967296","error":null,"search":"name=\"Test
Repository\"","sort":{"by":"name","order":"asc"},"results":[],"org_repository_count":1}
'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '195'
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'';
Expand All @@ -208,13 +210,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.3.0
- 3.7.0
Keep-Alive:
- timeout=15, max=97
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand All @@ -230,7 +230,7 @@ interactions:
message: OK
- request:
body: '{"name": "Test Repository", "label": "just_a_test_repo", "product_id":
21, "content_type": "yum", "url": "https://repos.fedorapeople.org/pulp/pulp/demo_repos/zoo/",
1, "content_type": "yum", "url": "https://repos.fedorapeople.org/pulp/pulp/demo_repos/zoo/",
"mirroring_policy": "additive"}'
headers:
Accept:
Expand All @@ -240,7 +240,7 @@ interactions:
Connection:
- keep-alive
Content-Length:
- '196'
- '195'
Content-Type:
- application/json
User-Agent:
Expand All @@ -249,20 +249,22 @@ interactions:
uri: https://foreman.example.org/katello/api/repositories
response:
body:
string: ' {"relative_path":"Test_Organization/Library/custom/Test_Product/just_a_test_repo","promoted":false,"content_view_version_id":21,"library_instance_id":null,"last_contents_changed":"2022-09-14
11:27:48 UTC","organization_id":6,"organization":{"name":"Test Organization","label":"Test_Organization","id":6},"created_at":"2022-09-14
11:27:47 UTC","updated_at":"2022-09-14 11:27:48 UTC","backend_identifier":"9fc32a80-a890-4913-b134-068ffaaef538","container_repository_name":null,"full_path":"https://centos8-stream-katello-4-5.tanso.example.com/pulp/content/Test_Organization/Library/custom/Test_Product/just_a_test_repo/","version_href":"/pulp/api/v3/repositories/rpm/rpm/e00a11c1-2b5c-4141-99e5-5bab7e580892/versions/0/","remote_href":"/pulp/api/v3/remotes/rpm/rpm/62d4611d-4ae6-4c27-b6a2-60b92fed52f8/","publication_href":null,"content_counts":{"rpm":0,"erratum":0,"package_group":0,"srpm":0,"module_stream":0},"mirroring_policy":"additive","id":24,"name":"Test
Repository","label":"just_a_test_repo","description":null,"content_view_versions":[],"last_sync":null,"content_view":{"id":10,"name":"Default
Organization View"},"content_view_version":{"id":21,"name":"Default Organization
View 1.0","content_view_id":10},"kt_environment":{"id":5,"name":"Library"},"content_type":"yum","url":"https://repos.fedorapeople.org/pulp/pulp/demo_repos/zoo/","arch":"noarch","os_versions":[],"content_id":"1663154868357","generic_remote_options":null,"major":null,"minor":null,"product":{"id":21,"cp_id":"160566138145","name":"Test
Product","orphaned":false,"redhat":false,"sync_plan":null},"content_label":"Test_Organization_Test_Product_just_a_test_repo","last_sync_words":null,"environment":{"id":5,"registry_unauthenticated_pull":false},"docker_upstream_name":null,"docker_tags_whitelist":null,"include_tags":null,"exclude_tags":null,"verify_ssl_on_sync":true,"unprotected":true,"checksum_type":null,"download_policy":"immediate","ansible_collection_requirements":null,"ansible_collection_auth_url":null,"ansible_collection_auth_token":null,"gpg_key_id":null,"ssl_ca_cert_id":null,"ssl_client_cert_id":null,"ssl_client_key_id":null,"upstream_username":null,"deb_releases":null,"deb_components":null,"deb_architectures":null,"http_proxy_policy":"global_default_http_proxy","http_proxy_id":null,"http_proxy_name":null,"retain_package_versions_count":null,"ignorable_content":null,"http_proxy":{"id":null,"name":null,"policy":"global_default_http_proxy"},"ssl_ca_cert":{"id":null,"name":null},"ssl_client_cert":{"id":null,"name":null},"ssl_client_key":{"id":null,"name":null},"gpg_key":{"id":null,"name":null},"permissions":{"deletable":true,"deletable_across_cv":true},"upstream_password_exists":false,"upstream_auth_exists":false,"content_view_environments":[]}
string: ' {"relative_path":"Test_Organization/Library/custom/Test_Product/just_a_test_repo","promoted":false,"content_view_version_id":2,"library_instance_id":null,"last_contents_changed":"2023-07-26
13:04:09 UTC","organization_id":3,"organization":{"name":"Test Organization","label":"Test_Organization","id":3},"created_at":"2023-07-26
13:04:08 UTC","updated_at":"2023-07-26 13:04:10 UTC","backend_identifier":"d834ed96-f974-43a7-891c-9efcb358fe0b","container_repository_name":null,"full_path":"https://centos8-stream-katello-4-9.tanso.example.com/pulp/content/Test_Organization/Library/custom/Test_Product/just_a_test_repo/","version_href":"/pulp/api/v3/repositories/rpm/rpm/45e870d8-eaaa-4b5b-a486-a0579ea295a9/versions/0/","remote_href":"/pulp/api/v3/remotes/rpm/rpm/ebfd859f-5ad8-423b-9875-daccce87ee33/","publication_href":null,"content_counts":{"rpm":0,"erratum":0,"package_group":0,"srpm":0,"module_stream":0},"mirroring_policy":"additive","id":7,"name":"Test
Repository","label":"just_a_test_repo","description":null,"content_view_versions":[],"last_sync":null,"content_view":{"id":2,"name":"Default
Organization View"},"content_view_version":{"id":2,"name":"Default Organization
View 1.0","content_view_id":2},"kt_environment":{"id":2,"name":"Library"},"content_type":"yum","url":"https://repos.fedorapeople.org/pulp/pulp/demo_repos/zoo/","arch":"noarch","os_versions":[],"content_id":"1690376649234","generic_remote_options":null,"major":null,"minor":null,"product":{"id":1,"cp_id":"830157316014","name":"Test
Product","orphaned":false,"redhat":false,"sync_plan":null},"content_label":"Test_Organization_Test_Product_just_a_test_repo","last_sync_words":null,"environment":{"id":2,"registry_unauthenticated_pull":false},"docker_upstream_name":null,"docker_tags_whitelist":null,"include_tags":null,"exclude_tags":null,"verify_ssl_on_sync":true,"unprotected":true,"checksum_type":null,"download_policy":"immediate","ansible_collection_requirements":null,"ansible_collection_auth_url":null,"ansible_collection_auth_token":null,"gpg_key_id":null,"ssl_ca_cert_id":null,"ssl_client_cert_id":null,"ssl_client_key_id":null,"upstream_username":null,"deb_releases":null,"deb_components":null,"deb_architectures":null,"http_proxy_policy":"global_default_http_proxy","http_proxy_id":null,"http_proxy_name":null,"retain_package_versions_count":null,"metadata_expire":null,"ignorable_content":null,"http_proxy":{"id":null,"name":null,"policy":"global_default_http_proxy"},"ssl_ca_cert":{"id":null,"name":null},"ssl_client_cert":{"id":null,"name":null},"ssl_client_key":{"id":null,"name":null},"gpg_key":{"id":null,"name":null},"permissions":{"deletable":true,"deletable_across_cv":true},"upstream_password_exists":false,"upstream_auth_exists":false,"content_view_environments":[]}
'
headers:
Cache-Control:
- max-age=0, private, must-revalidate
Connection:
- Keep-Alive
Content-Length:
- '2770'
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'';
Expand All @@ -276,13 +278,11 @@ interactions:
Foreman_current_organization:
- ; ANY
Foreman_version:
- 3.3.0
- 3.7.0
Keep-Alive:
- timeout=15, max=96
Strict-Transport-Security:
- max-age=631139040; includeSubdomains
Transfer-Encoding:
- chunked
X-Content-Type-Options:
- nosniff
X-Download-Options:
Expand Down
Loading

0 comments on commit 8ff176d

Please sign in to comment.