community.crypto/tests/integration/targets
David Zaslavsky ce3299f106
Always generate a new key pair if the private key doesn't exist (#598)
* Always generate a new key pair if the private key doesn't exist (#597)

This commit updates `KeypairBackend._should_generate()` to first check
if the original private key named by the `path` argument exists, and
return True if it does not. This brings the code in line with
the documentation, which says that a new key will always be generated if
the key file doesn't already exist.

As an alternative to the approach implemented here, I also considered
only modifying the condition in the `fail` branch of the if statement,
but I thought that would not map as cleanly to the behavior specified in
the documentation, so doing it the way I did should make it easier to
check that the code is doing the right thing just by looking at it.
I also considered doing something to make the logic more similar to
`PrivateKeyBackend.needs_regeneration()` (the openssl version of this
functionality), because the two are supposed to be acting the same way,
but I thought that'd be going beyond the scope of just fixing this bug.
If it'd be useful to make both methods work the same way, someone can
refactor the code in a future commit.

* Test different regenerate values with nonexistent keys

This commit changes the test task that generates new keys to use each of
the different values for the `regenerate` argument, which will ensure
that the module is capable of generating a key when no previous key
exists regardless of the value of `regenerate`. Previously, the task
would always run with the `partial_idempotence` value, and that obscured
a bug (#597) that would occur when it was set to `fail`. The bug was
fixed in the previous commit.
2023-05-01 21:16:42 +02:00
..
acme_account Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
acme_account_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
acme_certificate Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
acme_certificate_revoke Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
acme_challenge_cert_helper Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
acme_inspect Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
certificate_complete_chain Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
crypto_info CI: balance groups (#548) 2022-12-21 08:12:53 +01:00
ecs_certificate More bools. (#580) 2023-03-06 23:04:27 +01:00
ecs_domain Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#491) 2022-07-21 07:27:26 +02:00
filter_openssl_csr_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
filter_openssl_privatekey_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
filter_openssl_publickey_info Add openssl_publickey_info filter. (#556) 2022-12-31 07:56:54 +01:00
filter_split_pem Add split_pem filter (#549) 2022-12-27 21:57:20 +01:00
filter_x509_certificate_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
filter_x509_crl_info x509_crl: prepare releasing the mode option for AnsibleModule's use (#596) 2023-04-29 20:54:24 +02:00
get_certificate Add asn1_base64 option. (#592) 2023-04-16 13:34:45 +02:00
luks_device CI: add extra VM group (#545) 2023-03-09 07:58:14 +01:00
openssh_cert CI: balance groups (#548) 2022-12-21 08:12:53 +01:00
openssh_keypair Always generate a new key pair if the private key doesn't exist (#598) 2023-05-01 21:16:42 +02:00
openssl_csr Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_csr_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_csr_pipe Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_dhparam Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_pkcs12 CI: improve CI matrix, split into two groups (#544) 2022-12-20 12:57:53 +01:00
openssl_privatekey Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_privatekey_convert CI: improve CI matrix, split into two groups (#544) 2022-12-20 12:57:53 +01:00
openssl_privatekey_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_privatekey_pipe CI: improve CI matrix, split into two groups (#544) 2022-12-20 12:57:53 +01:00
openssl_publickey Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
openssl_publickey_info Add filter module base, prepare adding filters (#553) 2022-12-30 20:44:13 +01:00
openssl_signature CI: improve CI matrix, split into two groups (#544) 2022-12-20 12:57:53 +01:00
prepare_http_tests Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#491) 2022-07-21 07:27:26 +02:00
prepare_jinja2_compat Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#491) 2022-07-21 07:27:26 +02:00
prepare_tests/tasks Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#491) 2022-07-21 07:27:26 +02:00
setup_acme Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
setup_bcrypt Improve CI (#539) 2022-12-11 19:55:47 +01:00
setup_openssl Add macOS 13.2 to CI (#581) 2023-03-09 06:42:33 +01:00
setup_pkg_mgr/tasks Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
setup_pyopenssl Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
setup_python_info Improve CI (#539) 2022-12-11 19:55:47 +01:00
setup_remote_constraints Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#491) 2022-07-21 07:27:26 +02:00
setup_remote_tmp_dir Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
setup_ssh_agent Fix ssh-agent tests (#493) 2022-07-22 13:54:15 +02:00
setup_ssh_keygen Move licenses to LICENSES/, use SPDX-License-Identifier, mention all licenses in galaxy.yml (#491) 2022-07-21 07:27:26 +02:00
x509_certificate Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
x509_certificate-acme Use curl instead of get_url on Python 2.6. (#585) 2023-03-22 21:11:26 +01:00
x509_certificate_info Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
x509_certificate_pipe Normalize bools in tests. (#577) 2023-02-15 22:23:36 +01:00
x509_crl x509_crl: prepare releasing the mode option for AnsibleModule's use (#596) 2023-04-29 20:54:24 +02:00