Ejemplo n.º 1
0
    def test_move_to_whitelist(self):
        request = {
            "client_name": "example.com",
            "sender": "*****@*****.**",
            "recipient": "*****@*****.**"
        }

        greylist.greylist_timeout = 1
        greylist.auto_whitelist_threshold = 1
        greylist.move_to_whitelist = True

        self.assertEqual(
            greylist.FAILED,
            greylist.process_request(request))

        time.sleep(1)

        self.assertEqual(
            greylist.PASSED,
            greylist.process_request(request))

        self.assertEqual(
            greylist.PASSED,
            greylist.process_request(request))

        self.assertSequenceEqual(
            [(0,)],
            list(greylist.get_db().cursor().execute(
                "SELECT COUNT(*) FROM greylist")))
Ejemplo n.º 2
0
 def setUp(self):
     greylist.get_db()
Ejemplo n.º 3
0
            prefix, _, graph_type = filename.partition("_")
            if prefix != "greylisting":
                logger.error("invalid filename: %s", filename)
                sys.exit(1)

        try:
            config_handler, data_handler = graph_types[graph_type]
        except KeyError as err:
            logger.error("unknown graph type: %s", err)
            sys.exit(1)

        if args.munin_command == "config":
            config_handler()
            sys.exit(0)

        dbconn = greylist.get_db()
        cursor = dbconn.cursor()
        data_handler(cursor)
        sys.exit(0)

    dbconn = greylist.get_db()
    cursor = dbconn.cursor()

    print("total_greylist {}".format(get_total("greylist", cursor)))
    print("active_greylist {}".format(get_active_greylist(cursor)))
    print("dead_greylist {}".format(get_dead_greylist(cursor)))
    print("total_whitelist {}".format(get_total("whitelist", cursor)))
    print("active_whitelist {}".format(get_active_whitelist(cursor)))
    print("pending_whitelist {}".format(get_pending_whitelist(cursor)))
    print("distinct_greylist_client_names {}".format(
        get_distinct_client_names(cursor)))