| 1 |
--- |
| 2 |
# Copyright (c) Ansible Project |
| 3 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 4 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
|
| 6 |
- ansible.builtin.debug: |
| 7 |
msg: "Executing tests with backend {{ select_crypto_backend }}" |
| 8 |
|
| 9 |
- name: ({{ select_crypto_backend }}) Get key 1 info |
| 10 |
community.crypto.openssl_publickey_info: |
| 11 |
path: '{{ remote_tmp_dir }}/publickey_1.pem' |
| 12 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 13 |
register: result |
| 14 |
|
| 15 |
- name: Check that RSA key info is ok |
| 16 |
ansible.builtin.assert: |
| 17 |
that: |
| 18 |
- "'fingerprints' in result" |
| 19 |
- "'type' in result" |
| 20 |
- "result.type == 'RSA'" |
| 21 |
- "'public_data' in result" |
| 22 |
- "2 ** (result.public_data.size - 1) < result.public_data.modulus < 2 ** result.public_data.size" |
| 23 |
- "result.public_data.exponent > 5" |
| 24 |
|
| 25 |
- name: ({{ select_crypto_backend }}) Read file |
| 26 |
ansible.builtin.slurp: |
| 27 |
src: '{{ remote_tmp_dir }}/publickey_1.pem' |
| 28 |
register: slurp |
| 29 |
|
| 30 |
- name: ({{ select_crypto_backend }}) Get key 1 info directly |
| 31 |
community.crypto.openssl_publickey_info: |
| 32 |
content: '{{ slurp.content | b64decode }}' |
| 33 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 34 |
register: result_direct |
| 35 |
|
| 36 |
- name: ({{ select_crypto_backend }}) Compare output of direct and loaded info |
| 37 |
ansible.builtin.assert: |
| 38 |
that: |
| 39 |
- >- |
| 40 |
(result | dict2items | rejectattr("key", "equalto", "warnings") | list | items2dict) |
| 41 |
== |
| 42 |
(result_direct | dict2items | rejectattr("key", "equalto", "warnings") | list | items2dict) |
| 43 |
|
| 44 |
- name: ({{ select_crypto_backend }}) Get key 2 info |
| 45 |
community.crypto.openssl_publickey_info: |
| 46 |
path: '{{ remote_tmp_dir }}/publickey_2.pem' |
| 47 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 48 |
register: result |
| 49 |
|
| 50 |
- name: Check that RSA key info is ok |
| 51 |
ansible.builtin.assert: |
| 52 |
that: |
| 53 |
- "'fingerprints' in result" |
| 54 |
- "'type' in result" |
| 55 |
- "result.type == 'RSA'" |
| 56 |
- "'public_data' in result" |
| 57 |
- "result.public_data.size == default_rsa_key_size" |
| 58 |
- "2 ** (result.public_data.size - 1) < result.public_data.modulus < 2 ** result.public_data.size" |
| 59 |
- "result.public_data.exponent > 5" |
| 60 |
|
| 61 |
- name: ({{ select_crypto_backend }}) Get key 3 info |
| 62 |
community.crypto.openssl_publickey_info: |
| 63 |
path: '{{ remote_tmp_dir }}/publickey_3.pem' |
| 64 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 65 |
register: result |
| 66 |
|
| 67 |
- name: Check that ECC key info is ok |
| 68 |
ansible.builtin.assert: |
| 69 |
that: |
| 70 |
- "'fingerprints' in result" |
| 71 |
- "'type' in result" |
| 72 |
- "result.type == 'ECC'" |
| 73 |
- "'public_data' in result" |
| 74 |
- "result.public_data.curve is string" |
| 75 |
- "result.public_data.x != 0" |
| 76 |
- "result.public_data.y != 0" |
| 77 |
- "result.public_data.exponent_size == (521 if (ansible_facts.distribution == 'CentOS' and ansible_facts.distribution_major_version == '6') else 256)" |
| 78 |
|
| 79 |
- name: ({{ select_crypto_backend }}) Get key 4 info |
| 80 |
community.crypto.openssl_publickey_info: |
| 81 |
path: '{{ remote_tmp_dir }}/publickey_4.pem' |
| 82 |
select_crypto_backend: '{{ select_crypto_backend }}' |
| 83 |
register: result |
| 84 |
|
| 85 |
- name: Check that DSA key info is ok |
| 86 |
ansible.builtin.assert: |
| 87 |
that: |
| 88 |
- "'fingerprints' in result" |
| 89 |
- "'type' in result" |
| 90 |
- "result.type == 'DSA'" |
| 91 |
- "'public_data' in result" |
| 92 |
- "result.public_data.p > 2" |
| 93 |
- "result.public_data.q > 2" |
| 94 |
- "result.public_data.g >= 2" |
| 95 |
- "result.public_data.y > 2" |