Exemplo n.º 1
0
 def test_user_ruleset_user_no_pref(self):
     self.conf["allow_user_rules"] = True
     server = oa.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     with patch("oa.server.os.path.exists", return_value=False):
         result = server.get_user_ruleset(user="******")
     self.assertEqual(result, self.mainset)
Exemplo n.º 2
0
 def test_user_ruleset_user(self):
     self.conf["allow_user_rules"] = True
     server = oa.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     with patch("oa.server.os.path.exists", return_value=True):
         result = server.get_user_ruleset(user="******")
     parser = self.mock_parser.return_value
     self.assertEqual(result, parser.get_ruleset.return_value)
Exemplo n.º 3
0
    def test_user_ruleset_user_cached(self):
        self.conf["allow_user_rules"] = True
        server = oa.server.Server(("0.0.0.0", 783), "/dev/null",
                                   "/etc/spamassassin/")
        cached_result = Mock()
        server._user_rulesets["alex"] = cached_result

        result = server.get_user_ruleset(user="******")
        self.assertEqual(result, cached_result)
Exemplo n.º 4
0
 def test_user_ruleset_user_file_parsed(self):
     self.conf["allow_user_rules"] = True
     server = oa.server.Server(("0.0.0.0", 783), "/dev/null",
                               "/etc/spamassassin/")
     with patch("oa.server.os.path.exists", return_value=True):
         result = server.get_user_ruleset(user="******")
     parser = self.mock_parser.return_value
     parser.parse_file.assert_called_with(
         "/home/alex/.spamassassin/user_prefs")
Exemplo n.º 5
0
 def test_user_ruleset_user_not_allowed(self):
     server = oa.server.Server(("0.0.0.0", 783), "/dev/null",
                                "/etc/spamassassin/")
     result = server.get_user_ruleset(user="******")
     self.assertEqual(result, self.mainset)