Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/67903.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed if arguments are passed to the key delete all, -D, it will throw an error
6 changes: 6 additions & 0 deletions salt/cli/key.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import salt.utils.parsers
from salt.exceptions import SaltInvocationError
from salt.utils.verify import check_user


Expand All @@ -14,6 +15,11 @@ def run(self):
import salt.key

self.parse_args()
if self.options.delete_all:
if self.args:
raise SaltInvocationError(
"Delete all takes no arguments. Use -d to delete specified keys"
)

key = salt.key.KeyCLI(self.config)
if check_user(self.config["user"]):
Expand Down
9 changes: 9 additions & 0 deletions tests/pytests/integration/cli/test_salt_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ def test_remove_key(salt_master, salt_key_cli):
os.unlink(key)


def test_remove_all_keys_with_arg(salt_key_cli):
"""
test salt-key -D usage with args
"""
# Remove Key
ret = salt_key_cli.run("-D", "junk")
assert "Delete all takes no arguments" in ret.stderr


@pytest.mark.skip_if_not_root
@pytest.mark.destructive_test
@pytest.mark.skip_on_windows(reason="PAM is not supported on Windows")
Expand Down
Loading