コード例 #1
0
    def test_get_service(self):
        def check_get_reply(self, service, reply):
            for (name, value) in service[1].items():
                self.assertEqual(getattr(reply, name), value)

        self.newSetUp()
        self.check_svc_num(len(self.services))
        self.assertEqual(-2, self.send_message(messages.KZorpGetServiceMessage("nonexistent"), assert_on_error=False))

        for service in self.services:
            self.send_message(messages.KZorpGetServiceMessage(service[1].get('name')), message_handler = partial(check_get_reply, self, service))
コード例 #2
0
    def test_add_deny_service(self):
        response = []
        m = messages.KZorpAddDenyServiceMessage("denyservice", False, 0, messages.KZ_SVC_DENY_METHOD_V4_DROP, messages.KZ_SVC_DENY_METHOD_V6_DROP)
        self.start_transaction()
        self.send_message(m)
        self.end_transaction()
        self.start_transaction()
        self.send_message(messages.KZorpGetServiceMessage("denyservice"), message_handler = response.append, dump = True)
        self.end_transaction()

        self.assertEqual(1, len(response))
コード例 #3
0
class KZorpTestCaseServiceDump(KZorpTestCaseDump):
    _dump_message = messages.KZorpGetServiceMessage(None)

    def __create_service_messages_that_do_not_fit_into_one_nelink_packet(self):
        service_name_format = 'service_%d'

        service_messages = []

        for service_num in range(self._get_netlink_packet_size()):
            service_name = service_name_format % (service_num, )

            add_service_message = messages.KZorpAddForwardServiceMessage(service_name, messages.KZF_SVC_TRANSPARENT)
            service_messages.append(add_service_message)

        return service_messages

    def test_several_service_with_subnets_do_not_fit_into_one_netlink_packet(self):
        self._check_objects(self.__create_service_messages_that_do_not_fit_into_one_nelink_packet())
コード例 #4
0
 def check_svc_num(self, num_svc):
     _dumped_zones = []
     self.send_message(messages.KZorpGetServiceMessage(None),
                       message_handler=_dumped_zones.append,
                       dump=True)
     self.assertEqual(num_svc, len(_dumped_zones))