Skip to content
Closed
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
31 changes: 30 additions & 1 deletion tests/test_container_distributions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@
name: test_dist_repo
state: present

- name: Create test content guard
pulp.squeezer.x509_cert_guard:
pulp_url: "{{ pulp_url }}"
username: "{{ pulp_username }}"
password: "{{ pulp_password }}"
validate_certs: "{{ pulp_validate_certs }}"
name: test_dist_guard
ca_certificate: "{{ lookup('file', 'files/ca.pem') }}"
state: present
Comment on lines +20 to +28
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

To ensure the created content guard can be correctly referenced by its HREF in subsequent tasks, it is recommended to register the output of this task. This is particularly important because the container_distributions module (as seen in the context) does not currently appear to perform name-to-HREF resolution for the content_guard parameter.

    - name: Create test content guard
      pulp.squeezer.x509_cert_guard:
        pulp_url: "{{ pulp_url }}"
        username: "{{ pulp_username }}"
        password: "{{ pulp_password }}"
        validate_certs: "{{ pulp_validate_certs }}"
        name: test_dist_guard
        ca_certificate: "{{ lookup('file', 'files/ca.pem') }}"
        state: present
      register: guard_result


- name: Create test container distributions
stackhpc.pulp.container_distributions:
pulp_url: "{{ pulp_url }}"
Expand All @@ -33,17 +43,24 @@
repository: test_dist_repo
private: true
state: present
- name: test_dist_guarded
base_path: test_dist_guarded
repository: test_dist_repo
content_guard: test_dist_guard
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

The container_distributions module (as seen in the context) does not currently implement name-to-HREF resolution for the content_guard parameter, unlike the repository parameter which has explicit resolution logic (lines 189-204 of the module). Since the Pulp API typically expects a URI/HREF for the content guard field, passing the name test_dist_guard directly will likely cause the task to fail with a 400 Bad Request.

It is recommended to either update the module to support name resolution for content_guard or pass the HREF directly from the registered result of the guard creation task.

            content_guard: "{{ guard_result.x509_cert_guard.pulp_href }}"

Copy link
Copy Markdown
Member Author

@bbezak bbezak May 12, 2026

Choose a reason for hiding this comment

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

exactly why this test here ;)

state: present
register: create_result

- name: Verify distribution creation
assert:
that:
- create_result.distributions | length == 2
- create_result.distributions | length == 3
- create_result.distributions[0].name == "test_dist_1"
- create_result.distributions[0].distribution.base_path == "test_dist_1"
- create_result.distributions[0].changed == true
- create_result.distributions[1].name == "test_dist_2"
- create_result.distributions[1].distribution.private == true
- create_result.distributions[2].name == "test_dist_guarded"
- create_result.distributions[2].distribution.content_guard is search("/contentguards/")
Comment on lines +62 to +63
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

It is recommended to verify that the newly created distribution was actually marked as changed during the creation task.

          - create_result.distributions[2].name == "test_dist_guarded"
          - create_result.distributions[2].changed == true
          - create_result.distributions[2].distribution.content_guard is search("/contentguards/")


- name: Update container distributions
stackhpc.pulp.container_distributions:
Expand Down Expand Up @@ -93,13 +110,25 @@
state: absent
- name: test_dist_2
state: absent
- name: test_dist_guarded
state: absent
register: delete_result

- name: Verify distribution deletion
assert:
that:
- delete_result.distributions[0].changed == true
- delete_result.distributions[1].changed == true
- delete_result.distributions[2].changed == true

- name: Clean up test content guard
pulp.squeezer.x509_cert_guard:
pulp_url: "{{ pulp_url }}"
username: "{{ pulp_username }}"
password: "{{ pulp_password }}"
validate_certs: "{{ pulp_validate_certs }}"
name: test_dist_guard
state: absent

- name: Clean up test repository
pulp.squeezer.container_repository:
Expand Down
Loading