472
475
self.assertEquals(self.config.script_users,
473
476
"root, nobody, landscape")
478
def test_query_script_users_defined_on_command_line_with_unknown_user(self):
480
If several users are provided on the command line, we verify the users
481
and raise a ConfigurationError if any are unknown on this system.
483
pwnam_mock = self.mocker.replace("pwd.getpwnam")
485
self.mocker.result(None)
487
self.mocker.result(None)
488
pwnam_mock("landscape")
489
self.mocker.result(None)
490
pwnam_mock("unknown")
491
self.mocker.throw(KeyError())
494
self.config.load_command_line(
495
["--script-users", "root, nobody, landscape, unknown",
496
"--include-manager-plugins", "ScriptPlugin"])
497
self.assertRaises(ConfigurationError, self.script.query_script_plugin)
499
def test_query_script_users_defined_on_command_line_with_all_user(self):
501
We shouldn't accept all as a synonym for ALL
503
self.config.load_command_line(
504
["--script-users", "all",
505
"--include-manager-plugins", "ScriptPlugin"])
506
self.assertRaises(ConfigurationError, self.script.query_script_plugin)
508
def test_query_script_users_defined_on_command_line_with_ALL_user(self):
510
ALL is the special marker for all users.
512
self.config.load_command_line(
513
["--script-users", "ALL",
514
"--include-manager-plugins", "ScriptPlugin"])
515
self.script.query_script_plugin()
516
self.assertEquals(self.config.script_users,
519
def test_query_script_users_defined_on_command_line_with_ALL_and_extra_user(self):
521
If ALL and additional users are provided as the users on the command
522
line, this should raise an appropriate ConfigurationError.
524
self.config.load_command_line(
525
["--script-users", "ALL, kevin",
526
"--include-manager-plugins", "ScriptPlugin"])
527
self.assertRaises(ConfigurationError, self.script.query_script_plugin)
529
def test_invalid_user_entered_by_user(self):
531
If an invalid user is entered on the command line the user should be
532
informed and prompted again.
534
help_snippet = "Landscape has a feature which enables administrators"
536
script_mock = self.mocker.patch(self.script)
537
script_mock.show_help(self.get_matcher(help_snippet))
538
script_mock.prompt_yes_no("Enable script execution?", default=False)
539
self.mocker.result(True)
540
script_mock.show_help(
541
self.get_matcher("By default, scripts are restricted"))
542
script_mock.prompt_get_input("Script users: ", False)
543
self.mocker.result(u"nonexistent")
544
script_mock.show_help("Unknown system users: nonexistent")
545
script_mock.prompt_get_input("Script users: ", False)
546
self.mocker.result(u"root")
548
self.script.query_script_plugin()
549
self.assertEquals(self.config.script_users,
475
552
def test_tags_not_defined_on_command_line(self):
477
554
If tags are not provided, the user should be prompted for them.
689
766
account_name = account
769
def test_silent_script_users_with_all_user(self):
771
In silent mode, we shouldn't accept invalid users, it should raise a
774
sysvconfig_mock = self.mocker.patch(SysVConfig)
775
sysvconfig_mock.set_start_on_boot(True)
778
config = self.get_config(
779
["--script-users", "all",
780
"--include-manager-plugins", "ScriptPlugin",
784
self.assertRaises(ConfigurationError, setup, config)
692
786
def test_silent_setup_with_ping_url(self):
693
787
sysvconfig_mock = self.mocker.patch(SysVConfig)
694
788
sysvconfig_mock.set_start_on_boot(True)