예제 #1
0
 def test_single_option_updated(self):
     """A single update should have change made and line updated."""
     opt, val = ("UsePAM", "no")
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, {opt: val})
     self.assertEqual([opt], result)
     self.check_line(lines[1], opt, val)
예제 #2
0
 def test_return_empty_if_no_changes(self):
     """If there are no changes, then return should be empty list."""
     updates = {"UsePAM": "yes"}
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, updates)
     self.assertEqual([], result)
     self.assertEqual(self.exlines, [str(line) for line in lines])
예제 #3
0
 def test_return_empty_if_no_changes(self):
     """If there are no changes, then return should be empty list."""
     updates = {"UsePAM": "yes"}
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, updates)
     self.assertEqual([], result)
     self.assertEqual(self.exlines, [str(l) for l in lines])
예제 #4
0
 def test_single_option_updated(self):
     """A single update should have change made and line updated."""
     opt, val = ("UsePAM", "no")
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, {opt: val})
     self.assertEqual([opt], result)
     self.check_line(lines[1], opt, val)
예제 #5
0
 def test_keycase_not_modified(self):
     """Original case of key should not be changed on update.
     This behavior is to keep original config as much intact as can be."""
     updates = {"usepam": "no"}
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, updates)
     self.assertEqual(["usepam"], result)
     self.assertEqual("UsePAM no", str(lines[1]))
 def test_multiple_updates_with_add(self):
     """Verify multiple updates some added some changed, some not."""
     updates = {"UsePAM": "no", "X11Forwarding": "no", "NewOpt": "newval",
                "AcceptEnv": "LANG ADD LC_*"}
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, updates)
     self.assertEqual(set(["UsePAM", "NewOpt", "AcceptEnv"]), set(result))
     self.check_line(lines[3], "AcceptEnv", updates["AcceptEnv"])
예제 #7
0
 def test_keycase_not_modified(self):
     """Original case of key should not be changed on update.
     This behavior is to keep original config as much intact as can be."""
     updates = {"usepam": "no"}
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, updates)
     self.assertEqual(["usepam"], result)
     self.assertEqual("UsePAM no", str(lines[1]))
예제 #8
0
 def test_multiple_updates_with_add(self):
     """Verify multiple updates some added some changed, some not."""
     updates = {"UsePAM": "no", "X11Forwarding": "no", "NewOpt": "newval",
                "AcceptEnv": "LANG ADD LC_*"}
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, updates)
     self.assertEqual(set(["UsePAM", "NewOpt", "AcceptEnv"]), set(result))
     self.check_line(lines[3], "AcceptEnv", updates["AcceptEnv"])
예제 #9
0
 def test_commented_out_not_updated_but_appended(self):
     """Implementation does not un-comment and update lines."""
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, {self.pwauth: "no"})
     self.assertEqual([self.pwauth], result)
     self.check_line(lines[-1], self.pwauth, "no")
예제 #10
0
 def test_new_option_added(self):
     """A single update of non-existing option."""
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, {'MyKey': 'MyVal'})
     self.assertEqual(['MyKey'], result)
     self.check_line(lines[-1], "MyKey", "MyVal")
예제 #11
0
 def test_commented_out_not_updated_but_appended(self):
     """Implementation does not un-comment and update lines."""
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, {self.pwauth: "no"})
     self.assertEqual([self.pwauth], result)
     self.check_line(lines[-1], self.pwauth, "no")
예제 #12
0
 def test_new_option_added(self):
     """A single update of non-existing option."""
     lines = ssh_util.parse_ssh_config_lines(list(self.exlines))
     result = ssh_util.update_ssh_config_lines(lines, {'MyKey': 'MyVal'})
     self.assertEqual(['MyKey'], result)
     self.check_line(lines[-1], "MyKey", "MyVal")