| 1 |
--- |
| 2 |
#################################################################### |
| 3 |
# WARNING: These are designed specifically for Ansible tests # |
| 4 |
# and should not be used as examples of how to write Ansible roles # |
| 5 |
#################################################################### |
| 6 |
|
| 7 |
# Copyright (c) Ansible Project |
| 8 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 9 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 10 |
|
| 11 |
- when: has_java_keytool |
| 12 |
block: |
| 13 |
- name: prep pkcs12 file |
| 14 |
ansible.builtin.copy: |
| 15 |
src: "{{ test_pkcs12_path }}" |
| 16 |
dest: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}" |
| 17 |
|
| 18 |
- name: import pkcs12 |
| 19 |
community.general.java_cert: |
| 20 |
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}" |
| 21 |
pkcs12_password: changeit |
| 22 |
pkcs12_alias: default |
| 23 |
cert_alias: default |
| 24 |
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 25 |
keystore_pass: changeme_keystore |
| 26 |
keystore_create: true |
| 27 |
state: present |
| 28 |
register: result_success |
| 29 |
|
| 30 |
- name: verify success |
| 31 |
ansible.builtin.assert: |
| 32 |
that: |
| 33 |
- result_success is successful |
| 34 |
|
| 35 |
- name: import pkcs12 without alias params |
| 36 |
community.general.java_cert: |
| 37 |
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}" |
| 38 |
pkcs12_password: changeit |
| 39 |
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 40 |
keystore_pass: changeme_keystore |
| 41 |
keystore_create: true |
| 42 |
state: present |
| 43 |
register: result_success_excl_aliases |
| 44 |
|
| 45 |
- name: verify success |
| 46 |
ansible.builtin.assert: |
| 47 |
that: |
| 48 |
- result_success_excl_aliases is successful |
| 49 |
|
| 50 |
- name: import pkcs12 with wrong password |
| 51 |
community.general.java_cert: |
| 52 |
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}" |
| 53 |
pkcs12_password: wrong_pass |
| 54 |
pkcs12_alias: default |
| 55 |
cert_alias: default_new |
| 56 |
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 57 |
keystore_pass: changeme_keystore |
| 58 |
keystore_create: true |
| 59 |
state: present |
| 60 |
ignore_errors: true |
| 61 |
register: result_wrong_pass |
| 62 |
|
| 63 |
- name: verify fail with wrong import password |
| 64 |
ansible.builtin.assert: |
| 65 |
that: |
| 66 |
- result_wrong_pass is failed |
| 67 |
|
| 68 |
- name: test fail on mutually exclusive params |
| 69 |
community.general.java_cert: |
| 70 |
cert_path: ca.crt |
| 71 |
pkcs12_path: "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}" |
| 72 |
cert_alias: default |
| 73 |
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 74 |
keystore_pass: changeme_keystore |
| 75 |
keystore_create: true |
| 76 |
state: present |
| 77 |
ignore_errors: true |
| 78 |
register: result_excl_params |
| 79 |
|
| 80 |
- name: verify failed exclusive params |
| 81 |
ansible.builtin.assert: |
| 82 |
that: |
| 83 |
- result_excl_params is failed |
| 84 |
|
| 85 |
- name: test fail on missing required params |
| 86 |
community.general.java_cert: |
| 87 |
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 88 |
keystore_pass: changeme_keystore |
| 89 |
state: absent |
| 90 |
ignore_errors: true |
| 91 |
register: result_missing_required_param |
| 92 |
|
| 93 |
- name: verify failed missing required params |
| 94 |
ansible.builtin.assert: |
| 95 |
that: |
| 96 |
- result_missing_required_param is failed |
| 97 |
|
| 98 |
- name: delete object based on cert_alias parameter |
| 99 |
community.general.java_cert: |
| 100 |
keystore_path: "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 101 |
keystore_pass: changeme_keystore |
| 102 |
cert_alias: default |
| 103 |
state: absent |
| 104 |
ignore_errors: true |
| 105 |
register: result_alias_deleted |
| 106 |
|
| 107 |
- name: verify object successfully deleted |
| 108 |
ansible.builtin.assert: |
| 109 |
that: |
| 110 |
- result_alias_deleted is successful |
| 111 |
|
| 112 |
- name: include extended test suite |
| 113 |
import_tasks: state_change.yml |
| 114 |
|
| 115 |
- name: cleanup environment |
| 116 |
ansible.builtin.file: |
| 117 |
path: "{{ item }}" |
| 118 |
state: absent |
| 119 |
loop: |
| 120 |
- "{{ remote_tmp_dir }}/{{ test_pkcs12_path }}" |
| 121 |
- "{{ remote_tmp_dir }}/{{ test_keystore_path }}" |
| 122 |
- "{{ test_keystore2_path }}" |
| 123 |
- "{{ test_cert_path }}" |
| 124 |
- "{{ test_key_path }}" |
| 125 |
- "{{ test_csr_path }}" |
| 126 |
- "{{ test_cert2_path }}" |
| 127 |
- "{{ test_key2_path }}" |
| 128 |
- "{{ test_csr2_path }}" |
| 129 |
- "{{ test_pkcs_path }}" |
| 130 |
- "{{ test_pkcs2_path }}" |