mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Only run __create_keys_dir
if we have a --gen-keys
argument
This commit is contained in:
parent
5266ffda0a
commit
88c0c5a33b
2 changed files with 13 additions and 5 deletions
|
@ -2649,7 +2649,7 @@ class SaltKeyOptionParser(
|
|||
default=".",
|
||||
help=(
|
||||
"Set the directory to save the generated keypair, only "
|
||||
"works with \"gen_keys_dir\" option. Default: '%default'."
|
||||
"works with \"--gen-keys\" option. Default: '%default'."
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -2767,10 +2767,11 @@ class SaltKeyOptionParser(
|
|||
|
||||
def process_gen_keys_dir(self):
|
||||
# Schedule __create_keys_dir() to run if there's a value for
|
||||
# --create-keys-dir
|
||||
self._mixin_after_parsed_funcs.append(
|
||||
self.__create_keys_dir
|
||||
) # pylint: disable=no-member
|
||||
# --gen-keys-dir
|
||||
if self.options.gen_keys:
|
||||
self._mixin_after_parsed_funcs.append(
|
||||
self.__create_keys_dir
|
||||
) # pylint: disable=no-member
|
||||
|
||||
def __create_keys_dir(self):
|
||||
if not os.path.isdir(self.config["gen_keys_dir"]):
|
||||
|
|
|
@ -292,6 +292,13 @@ def test_keys_generation(salt_key_cli, tmp_path):
|
|||
filename.chmod(0o700)
|
||||
|
||||
|
||||
def test_gen_keys_dir_without_gen_keys(salt_key_cli, tmp_path):
|
||||
gen_keys_path = tmp_path / "temp-gen-keys-path"
|
||||
ret = salt_key_cli.run("--gen-keys-dir", str(gen_keys_path))
|
||||
assert ret.returncode == 0
|
||||
assert not gen_keys_path.exists()
|
||||
|
||||
|
||||
def test_keys_generation_keysize_min(salt_key_cli, tmp_path):
|
||||
ret = salt_key_cli.run(
|
||||
"--gen-keys", "minibar", "--gen-keys-dir", str(tmp_path), "--keysize", "1024"
|
||||
|
|
Loading…
Add table
Reference in a new issue