=== modified file 'mandos-ctl' --- mandos-ctl 2019-03-07 20:28:17 +0000 +++ mandos-ctl 2019-03-07 20:37:15 +0000 @@ -1169,17 +1169,30 @@ self.assert_command_from_args(["--verbose"], PrintTableCmd, verbose=True) + def test_print_table_verbose_short(self): + self.assert_command_from_args(["-v"], PrintTableCmd, + verbose=True) + def test_enable(self): self.assert_command_from_args(["--enable", "foo"], EnableCmd) + def test_enable_short(self): + self.assert_command_from_args(["-e", "foo"], EnableCmd) + def test_disable(self): self.assert_command_from_args(["--disable", "foo"], DisableCmd) + def test_disable_short(self): + self.assert_command_from_args(["-d", "foo"], DisableCmd) + def test_bump_timeout(self): self.assert_command_from_args(["--bump-timeout", "foo"], BumpTimeoutCmd) + def test_bump_timeout_short(self): + self.assert_command_from_args(["-b", "foo"], BumpTimeoutCmd) + def test_start_checker(self): self.assert_command_from_args(["--start-checker", "foo"], StartCheckerCmd) @@ -1192,6 +1205,9 @@ self.assert_command_from_args(["--remove", "foo"], RemoveCmd) + def test_remove_short(self): + self.assert_command_from_args(["-r", "foo"], RemoveCmd) + def test_checker(self): self.assert_command_from_args(["--checker", ":", "foo"], SetCheckerCmd, value_to_set=":") @@ -1200,11 +1216,20 @@ self.assert_command_from_args(["--checker", "", "foo"], SetCheckerCmd, value_to_set="") + def test_checker_short(self): + self.assert_command_from_args(["-c", ":", "foo"], + SetCheckerCmd, value_to_set=":") + def test_timeout(self): self.assert_command_from_args(["--timeout", "PT5M", "foo"], SetTimeoutCmd, value_to_set=300000) + def test_timeout_short(self): + self.assert_command_from_args(["-t", "PT5M", "foo"], + SetTimeoutCmd, + value_to_set=300000) + def test_extended_timeout(self): self.assert_command_from_args(["--extended-timeout", "PT15M", "foo"], @@ -1216,6 +1241,11 @@ SetIntervalCmd, value_to_set=120000) + def test_interval_short(self): + self.assert_command_from_args(["-i", "PT2M", "foo"], + SetIntervalCmd, + value_to_set=120000) + def test_approve_by_default(self): self.assert_command_from_args(["--approve-by-default", "foo"], ApproveByDefaultCmd) @@ -1239,6 +1269,11 @@ "foo"], SetHostCmd, value_to_set="foo.example.org") + def test_host_short(self): + self.assert_command_from_args(["-H", "foo.example.org", + "foo"], SetHostCmd, + value_to_set="foo.example.org") + def test_secret_devnull(self): self.assert_command_from_args(["--secret", os.path.devnull, "foo"], SetSecretCmd, @@ -1253,13 +1288,32 @@ "foo"], SetSecretCmd, value_to_set=value) + def test_secret_devnull_short(self): + self.assert_command_from_args(["-s", os.path.devnull, "foo"], + SetSecretCmd, value_to_set=b"") + + def test_secret_tempfile_short(self): + with tempfile.NamedTemporaryFile(mode="r+b") as f: + value = b"secret\0xyzzy\nbar" + f.write(value) + f.seek(0) + self.assert_command_from_args(["-s", f.name, "foo"], + SetSecretCmd, + value_to_set=value) + def test_approve(self): self.assert_command_from_args(["--approve", "foo"], ApproveCmd) + def test_approve_short(self): + self.assert_command_from_args(["-A", "foo"], ApproveCmd) + def test_deny(self): self.assert_command_from_args(["--deny", "foo"], DenyCmd) + def test_deny_short(self): + self.assert_command_from_args(["-D", "foo"], DenyCmd) + def test_dump_json(self): self.assert_command_from_args(["--dump-json"], DumpJSONCmd) @@ -1267,6 +1321,9 @@ self.assert_command_from_args(["--is-enabled", "foo"], IsEnabledCmd) + def test_is_enabled_short(self): + self.assert_command_from_args(["-V", "foo"], IsEnabledCmd) + def should_only_run_tests():