Skip to content

Commit 4fdab26

Browse files
committed
[BUG] salt-key -D should error if arguments are given #67903
1 parent f906ca5 commit 4fdab26

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

salt/cli/key.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import salt.utils.parsers
2+
from salt.exceptions import SaltInvocationError
23
from salt.utils.verify import check_user
34

45

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

1617
self.parse_args()
18+
if self.options.__dict__["delete_all"]:
19+
if self.args:
20+
raise SaltInvocationError(
21+
"Delete all takes no arguments. Use -d to delete specified keys"
22+
)
1723

1824
key = salt.key.KeyCLI(self.config)
1925
if check_user(self.config["user"]):

tests/pytests/integration/cli/test_salt_key.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ def test_remove_key(salt_master, salt_key_cli):
7575
os.unlink(key)
7676

7777

78+
def test_remove_all_keys_with_arg(salt_key_cli):
79+
"""
80+
test salt-key -D usage with args
81+
"""
82+
# Remove Key
83+
ret = salt_key_cli.run("-D", 'minion_id')
84+
assert "Delete all takes no arguments" in ret.stderr
85+
86+
7887
@pytest.mark.skip_if_not_root
7988
@pytest.mark.destructive_test
8089
@pytest.mark.skip_on_windows(reason="PAM is not supported on Windows")

0 commit comments

Comments
 (0)