community.general/tests/integration/targets/java_cert/tasks/main.yml
patchback[bot] 138740127a
Some checks failed
EOL CI / EOL Sanity (Ⓐ2.15) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py2.7) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.10) (push) Has been cancelled
EOL CI / EOL Units (Ⓐ2.15+py3.5) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+alpine3+py:azp/posix/3/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/1/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/2/) (push) Has been cancelled
EOL CI / EOL I (Ⓐ2.15+fedora37+py:azp/posix/3/) (push) Has been cancelled
import-galaxy / Test to import built collection artifact with Galaxy importer (push) Has been cancelled
Verify REUSE / check (push) Has been cancelled
[PR #9970/42a161ab backport][stable-10] param pkcs12_alias and cert_alias to be optional in java_cert module (#10001)
param pkcs12_alias and cert_alias to be optional in java_cert module  (#9970)

* changed pkcs12_alias and cert_alias to be optional when importing pkcs12 certificate in keystore

* Add changelog fragment

* Update changelogs/fragments/9970-pkcs12_alias_cert_alias_optional.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/9970-pkcs12_alias_cert_alias_optional.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit 42a161abf5)

Co-authored-by: Emanuele Bernardi <e.berna@gmail.com>
2025-04-16 21:14:31 +02:00

130 lines
4.3 KiB
YAML

---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- when: has_java_keytool
block:
- name: prep pkcs12 file
ansible.builtin.copy:
src: "{{ test_pkcs12_path }}"
dest: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
- name: import pkcs12
community.general.java_cert:
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
pkcs12_password: changeit
pkcs12_alias: default
cert_alias: default
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
keystore_pass: changeme_keystore
keystore_create: true
state: present
register: result_success
- name: verify success
ansible.builtin.assert:
that:
- result_success is successful
- name: import pkcs12 without alias params
community.general.java_cert:
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
pkcs12_password: changeit
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
keystore_pass: changeme_keystore
keystore_create: true
state: present
register: result_success_excl_aliases
- name: verify success
ansible.builtin.assert:
that:
- result_success_excl_aliases is successful
- name: import pkcs12 with wrong password
community.general.java_cert:
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
pkcs12_password: wrong_pass
pkcs12_alias: default
cert_alias: default_new
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
keystore_pass: changeme_keystore
keystore_create: true
state: present
ignore_errors: true
register: result_wrong_pass
- name: verify fail with wrong import password
ansible.builtin.assert:
that:
- result_wrong_pass is failed
- name: test fail on mutually exclusive params
community.general.java_cert:
cert_path: ca.crt
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
cert_alias: default
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
keystore_pass: changeme_keystore
keystore_create: true
state: present
ignore_errors: true
register: result_excl_params
- name: verify failed exclusive params
ansible.builtin.assert:
that:
- result_excl_params is failed
- name: test fail on missing required params
community.general.java_cert:
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
keystore_pass: changeme_keystore
state: absent
ignore_errors: true
register: result_missing_required_param
- name: verify failed missing required params
ansible.builtin.assert:
that:
- result_missing_required_param is failed
- name: delete object based on cert_alias parameter
community.general.java_cert:
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
keystore_pass: changeme_keystore
cert_alias: default
state: absent
ignore_errors: true
register: result_alias_deleted
- name: verify object successfully deleted
ansible.builtin.assert:
that:
- result_alias_deleted is successful
- name: include extended test suite
import_tasks: state_change.yml
- name: cleanup environment
ansible.builtin.file:
path: "{{ item }}"
state: absent
loop:
- "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}"
- "{{ remote_tmp_dir }}/{{ test_keystore_path }}"
- "{{ test_keystore2_path }}"
- "{{ test_cert_path }}"
- "{{ test_key_path }}"
- "{{ test_csr_path }}"
- "{{ test_cert2_path }}"
- "{{ test_key2_path }}"
- "{{ test_csr2_path }}"
- "{{ test_pkcs_path }}"
- "{{ test_pkcs2_path }}"