Exemplo n.º 1
0
 def test_none_string_to_dictionary(self):
     input_str = ''
     expected = {}
     self.assertEqual(expected, utils.str2dict(input_str))
     input_str = None
     expected = {}
     self.assertEqual(expected, utils.str2dict(input_str))
Exemplo n.º 2
0
 def test_str2dict_optional_keys(self):
     self.assertDictEqual({'key1': 'value1'},
                          utils.str2dict('key1=value1',
                                         optional_keys=['key1', 'key2']))
     self.assertDictEqual({'key1': 'value1', 'key2': 'value2'},
                          utils.str2dict('key1=value1,key2=value2',
                                         optional_keys=['key1', 'key2']))
     e = self.assertRaises(argparse.ArgumentTypeError,
                           utils.str2dict,
                           'key1=value1,key2=value2,key3=value3',
                           optional_keys=['key1', 'key2'])
     self.assertEqual("Invalid key(s) 'key3' specified. "
                      "Valid key(s): 'key1, key2'.",
                      str(e))
Exemplo n.º 3
0
 def test_str2dict_required_keys(self):
     self.assertDictEqual(
         {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'},
         utils.str2dict('key1=value1,key2=value2,key3=value3',
                        required_keys=['key1', 'key2'],
                        optional_keys=['key3']))
     self.assertDictEqual(
         {'key1': 'value1', 'key2': 'value2'},
         utils.str2dict('key1=value1,key2=value2',
                        required_keys=['key1', 'key2']))
     e = self.assertRaises(argparse.ArgumentTypeError,
                           utils.str2dict, 'key1=value1',
                           required_keys=['key1', 'key2'])
     self.assertEqual("Required key(s) 'key2' not specified.", str(e))
Exemplo n.º 4
0
    def args2body(self, parsed_args):
        _network_id = neutronV20.find_resourceid_by_name_or_id(self.get_client(), "network", parsed_args.network_id)
        body = {"port": {"admin_state_up": parsed_args.admin_state, "network_id": _network_id}}
        if parsed_args.mac_address:
            body["port"].update({"mac_address": parsed_args.mac_address})
        if parsed_args.device_id:
            body["port"].update({"device_id": parsed_args.device_id})
        if parsed_args.tenant_id:
            body["port"].update({"tenant_id": parsed_args.tenant_id})
        if parsed_args.name:
            body["port"].update({"name": parsed_args.name})
        ips = []
        if parsed_args.fixed_ip:
            for ip_spec in parsed_args.fixed_ip:
                ip_dict = utils.str2dict(ip_spec)
                if "subnet_id" in ip_dict:
                    subnet_name_id = ip_dict["subnet_id"]
                    _subnet_id = neutronV20.find_resourceid_by_name_or_id(self.get_client(), "subnet", subnet_name_id)
                    ip_dict["subnet_id"] = _subnet_id
                ips.append(ip_dict)
        if ips:
            body["port"].update({"fixed_ips": ips})

        self.args2body_secgroup(parsed_args, body["port"])
        self.args2body_extradhcpopt(parsed_args, body["port"])

        return body
Exemplo n.º 5
0
 def run(self, parsed_args):
     self.log.debug('run(%s)' % parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _router_id = neutronV20.find_resourceid_by_name_or_id(
         neutron_client, self.resource, parsed_args.router)
     _ext_net_id = neutronV20.find_resourceid_by_name_or_id(
         neutron_client, 'network', parsed_args.external_network)
     router_dict = {'network_id': _ext_net_id}
     if parsed_args.disable_snat:
         router_dict['enable_snat'] = False
     if parsed_args.fixed_ip:
         ips = []
         for ip_spec in parsed_args.fixed_ip:
             ip_dict = utils.str2dict(ip_spec)
             subnet_name_id = ip_dict.get('subnet_id')
             if subnet_name_id:
                 subnet_id = neutronV20.find_resourceid_by_name_or_id(
                     neutron_client, 'subnet', subnet_name_id)
                 ip_dict['subnet_id'] = subnet_id
             ips.append(ip_dict)
         router_dict['external_fixed_ips'] = ips
     neutron_client.add_gateway_router(_router_id, router_dict)
     print(_('Set gateway for router %s') % parsed_args.router,
           file=self.app.stdout)
Exemplo n.º 6
0
 def run(self, parsed_args):
     self.log.debug('run(%s)' % parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _router_id = neutronV20.find_resourceid_by_name_or_id(
         neutron_client, self.resource, parsed_args.router)
     _ext_net_id = neutronV20.find_resourceid_by_name_or_id(
         neutron_client, 'network', parsed_args.external_network)
     router_dict = {'network_id': _ext_net_id}
     if parsed_args.disable_snat:
         router_dict['enable_snat'] = False
     if parsed_args.fixed_ip:
         ips = []
         for ip_spec in parsed_args.fixed_ip:
             ip_dict = utils.str2dict(ip_spec)
             subnet_name_id = ip_dict.get('subnet_id')
             if subnet_name_id:
                 subnet_id = neutronV20.find_resourceid_by_name_or_id(
                     neutron_client, 'subnet', subnet_name_id)
                 ip_dict['subnet_id'] = subnet_id
             ips.append(ip_dict)
         router_dict['external_fixed_ips'] = ips
     neutron_client.add_gateway_router(_router_id, router_dict)
     print(_('Set gateway for router %s') % parsed_args.router,
           file=self.app.stdout)
Exemplo n.º 7
0
    def args2body_extradhcpopt(self, parsed_args, port):
        ops = []
        if parsed_args.extra_dhcp_opts:
            # the extra_dhcp_opt params (opt_name & opt_value)
            # must come in pairs, if there is a parm error
            # both must be thrown out.
            opt_ele = {}
            edo_err_msg = _("Invalid --extra-dhcp-opt option, can only be: "
                            "opt_name=<dhcp_option_name>,opt_value=<value>. "
                            "You can repeat this option.")
            for opt in parsed_args.extra_dhcp_opts:
                if opt.split('=')[0] in ['opt_value', 'opt_name']:
                    opt_ele.update(utils.str2dict(opt))
                    if (('opt_name' in opt_ele) and ('opt_value' in opt_ele)):
                        if opt_ele['opt_value'] == 'null':
                            opt_ele['opt_value'] = None
                        ops.append(opt_ele)
                        opt_ele = {}
                    else:
                        raise exceptions.CommandError(edo_err_msg)
                else:
                    raise exceptions.CommandError(edo_err_msg)

        if ops:
            port.update({'extra_dhcp_opts': ops})
Exemplo n.º 8
0
    def args2body(self, parsed_args):
        _network_id = neutronV20.find_resourceid_by_name_or_id(
            self.get_client(), 'network', parsed_args.network_id)
        body = {'port': {'admin_state_up': parsed_args.admin_state,
                         'network_id': _network_id, }, }
        if parsed_args.mac_address:
            body['port'].update({'mac_address': parsed_args.mac_address})
        if parsed_args.device_id:
            body['port'].update({'device_id': parsed_args.device_id})
        if parsed_args.tenant_id:
            body['port'].update({'tenant_id': parsed_args.tenant_id})
        if parsed_args.name:
            body['port'].update({'name': parsed_args.name})
        ips = []
        if parsed_args.fixed_ip:
            for ip_spec in parsed_args.fixed_ip:
                ip_dict = utils.str2dict(ip_spec)
                if 'subnet_id' in ip_dict:
                    subnet_name_id = ip_dict['subnet_id']
                    _subnet_id = neutronV20.find_resourceid_by_name_or_id(
                        self.get_client(), 'subnet', subnet_name_id)
                    ip_dict['subnet_id'] = _subnet_id
                ips.append(ip_dict)
        if ips:
            body['port'].update({'fixed_ips': ips})

        self.args2body_secgroup(parsed_args, body['port'])
        self.args2body_extradhcpopt(parsed_args, body['port'])

        return body
Exemplo n.º 9
0
    def args2body_extradhcpopt(self, parsed_args, port):
        ops = []
        if parsed_args.extra_dhcp_opts:
            # the extra_dhcp_opt params (opt_name & opt_value)
            # must come in pairs, if there is a parm error
            # both must be thrown out.
            opt_ele = {}
            edo_err_msg = _(
                "Invalid --extra-dhcp-opt option, can only be: "
                "opt_name=<dhcp_option_name>,opt_value=<value>,"
                "ip_version={4,6}. "
                "You can repeat this option."
            )
            for opt in parsed_args.extra_dhcp_opts:
                opt_ele.update(utils.str2dict(opt))
                if "opt_name" in opt_ele and ("opt_value" in opt_ele or "ip_version" in opt_ele):
                    if opt_ele.get("opt_value") == "null":
                        opt_ele["opt_value"] = None
                    ops.append(opt_ele)
                    opt_ele = {}
                else:
                    raise exceptions.CommandError(edo_err_msg)

        if ops:
            port["extra_dhcp_opts"] = ops
Exemplo n.º 10
0
    def args2body(self, parsed_args):
        _network_id = neutronV20.find_resourceid_by_name_or_id(
            self.get_client(), 'network', parsed_args.network_id)
        body = {
            'port': {
                'admin_state_up': parsed_args.admin_state,
                'network_id': _network_id,
            },
        }
        if parsed_args.mac_address:
            body['port'].update({'mac_address': parsed_args.mac_address})
        if parsed_args.device_id:
            body['port'].update({'device_id': parsed_args.device_id})
        if parsed_args.tenant_id:
            body['port'].update({'tenant_id': parsed_args.tenant_id})
        if parsed_args.name:
            body['port'].update({'name': parsed_args.name})
        ips = []
        if parsed_args.fixed_ip:
            for ip_spec in parsed_args.fixed_ip:
                ip_dict = utils.str2dict(ip_spec)
                if 'subnet_id' in ip_dict:
                    subnet_name_id = ip_dict['subnet_id']
                    _subnet_id = neutronV20.find_resourceid_by_name_or_id(
                        self.get_client(), 'subnet', subnet_name_id)
                    ip_dict['subnet_id'] = _subnet_id
                ips.append(ip_dict)
        if ips:
            body['port'].update({'fixed_ips': ips})

        self.args2body_secgroup(parsed_args, body['port'])
        self.args2body_extradhcpopt(parsed_args, body['port'])

        return body
Exemplo n.º 11
0
    def args2body_extradhcpopt(self, parsed_args, port):
        ops = []
        if parsed_args.extra_dhcp_opts:
            # the extra_dhcp_opt params (opt_name & opt_value)
            # must come in pairs, if there is a parm error
            # both must be thrown out.
            opt_ele = {}
            edo_err_msg = _("Invalid --extra-dhcp-opt option, can only be: "
                            "opt_name=<dhcp_option_name>,opt_value=<value>. "
                            "You can repeat this option.")
            for opt in parsed_args.extra_dhcp_opts:
                if opt.split('=')[0] in ['opt_value', 'opt_name']:
                    opt_ele.update(utils.str2dict(opt))
                    if (('opt_name' in opt_ele) and
                        ('opt_value' in opt_ele)):
                        if opt_ele['opt_value'] == 'null':
                            opt_ele['opt_value'] = None
                        ops.append(opt_ele)
                        opt_ele = {}
                    else:
                        raise exceptions.CommandError(edo_err_msg)
                else:
                    raise exceptions.CommandError(edo_err_msg)

        if ops:
            port.update({'extra_dhcp_opts': ops})
Exemplo n.º 12
0
 def test_string_with_comma_value_to_dictionary(self):
     input_str = ('opt_name=classless-static-route,'
                  'opt_value=169.254.169.254/32,10.0.0.1')
     expected = {
         'opt_name': 'classless-static-route',
         'opt_value': '169.254.169.254/32,10.0.0.1'
     }
     self.assertEqual(expected, utils.str2dict(input_str))
Exemplo n.º 13
0
 def args2body(self, parsed_args):
     body = {'name': parsed_args.name}
     devices = []
     if parsed_args.device:
         for device in parsed_args.device:
             devices.append(utils.str2dict(device))
     if devices:
         body['devices'] = devices
     if parsed_args.tenant_id:
         body['tenant_id'] = parsed_args.tenant_id
     return {self.resource: body}
Exemplo n.º 14
0
 def args2body(self, parsed_args):
     body = {self.resource: {"name": parsed_args.name}}
     devices = []
     if parsed_args.device:
         for device in parsed_args.device:
             devices.append(utils.str2dict(device))
     if devices:
         body[self.resource].update({"devices": devices})
     if parsed_args.tenant_id:
         body[self.resource].update({"tenant_id": parsed_args.tenant_id})
     return body
 def args2body(self, parsed_args):
     body = {'name': parsed_args.name}
     devices = []
     if parsed_args.device:
         for device in parsed_args.device:
             devices.append(utils.str2dict(device))
     if devices:
         body['devices'] = devices
     if parsed_args.tenant_id:
         body['tenant_id'] = parsed_args.tenant_id
     return {self.resource: body}
Exemplo n.º 16
0
 def args2body(self, parsed_args):
     body = {self.resource: {'name': parsed_args.name}}
     devices = []
     if parsed_args.device:
         for device in parsed_args.device:
             devices.append(utils.str2dict(device))
     if devices:
         body[self.resource].update({'devices': devices})
     if parsed_args.tenant_id:
         body[self.resource].update({'tenant_id': parsed_args.tenant_id})
     return body
Exemplo n.º 17
0
 def args2body(self, parsed_args):
     if parsed_args.session_persistence:
         parsed_args.session_persistence = utils.str2dict(parsed_args.session_persistence)
     _listener_id = neutronV20.find_resourceid_by_name_or_id(self.get_client(), "listener", parsed_args.listener)
     body = {
         "admin_state_up": parsed_args.admin_state,
         "protocol": parsed_args.protocol,
         "lb_algorithm": parsed_args.lb_algorithm,
         "listener_id": _listener_id,
     }
     neutronV20.update_dict(parsed_args, body, ["description", "name", "session_persistence", "tenant_id"])
     return {self.resource: body}
Exemplo n.º 18
0
def _updatable_args2body(parsed_args, body, client):
    neutronV20.update_dict(parsed_args, body, ["device_id", "device_owner", "name"])
    ips = []
    if parsed_args.fixed_ip:
        for ip_spec in parsed_args.fixed_ip:
            ip_dict = utils.str2dict(ip_spec)
            if "subnet_id" in ip_dict:
                subnet_name_id = ip_dict["subnet_id"]
                _subnet_id = neutronV20.find_resourceid_by_name_or_id(client, "subnet", subnet_name_id)
                ip_dict["subnet_id"] = _subnet_id
            ips.append(ip_dict)
    if ips:
        body["fixed_ips"] = ips
Exemplo n.º 19
0
 def args2body(self, parsed_args):
     if parsed_args.session_persistence:
         parsed_args.session_persistence = utils.str2dict(
             parsed_args.session_persistence)
     _listener_id = neutronV20.find_resourceid_by_name_or_id(
         self.get_client(), 'listener', parsed_args.listener)
     body = {'admin_state_up': parsed_args.admin_state,
             'protocol': parsed_args.protocol,
             'lb_algorithm': parsed_args.lb_algorithm,
             'listener_id': _listener_id}
     neutronV20.update_dict(parsed_args, body,
                            ['description', 'name',
                             'session_persistence', 'tenant_id'])
     return {self.resource: body}
Exemplo n.º 20
0
def _updatable_args2body(parsed_args, body, client):
    neutronV20.update_dict(parsed_args, body,
                           ['device_id', 'device_owner', 'name'])
    ips = []
    if parsed_args.fixed_ip:
        for ip_spec in parsed_args.fixed_ip:
            ip_dict = utils.str2dict(ip_spec)
            if 'subnet_id' in ip_dict:
                subnet_name_id = ip_dict['subnet_id']
                _subnet_id = neutronV20.find_resourceid_by_name_or_id(
                    client, 'subnet', subnet_name_id)
                ip_dict['subnet_id'] = _subnet_id
            ips.append(ip_dict)
    if ips:
        body['fixed_ips'] = ips
Exemplo n.º 21
0
def _updatable_args2body(parsed_args, body, client):
    neutronV20.update_dict(parsed_args, body,
                           ['device_id', 'device_owner', 'name'])
    ips = []
    if parsed_args.fixed_ip:
        for ip_spec in parsed_args.fixed_ip:
            ip_dict = utils.str2dict(ip_spec)
            if 'subnet_id' in ip_dict:
                subnet_name_id = ip_dict['subnet_id']
                _subnet_id = neutronV20.find_resourceid_by_name_or_id(
                    client, 'subnet', subnet_name_id)
                ip_dict['subnet_id'] = _subnet_id
            ips.append(ip_dict)
    if ips:
        body['fixed_ips'] = ips
Exemplo n.º 22
0
 def args2body(self, parsed_args):
     if parsed_args.session_persistence:
         parsed_args.session_persistence = utils.str2dict(
             parsed_args.session_persistence)
     _listener_id = neutronV20.find_resourceid_by_name_or_id(
         self.get_client(), 'listener', parsed_args.listener)
     body = {
         'admin_state_up': parsed_args.admin_state,
         'protocol': parsed_args.protocol,
         'lb_algorithm': parsed_args.lb_algorithm,
         'listener_id': _listener_id
     }
     neutronV20.update_dict(
         parsed_args, body,
         ['description', 'name', 'session_persistence', 'tenant_id'])
     return {self.resource: body}
Exemplo n.º 23
0
def _updatable_args2body(parsed_args, body, client):
    if parsed_args.device_id:
        body['port'].update({'device_id': parsed_args.device_id})
    if parsed_args.device_owner:
        body['port'].update({'device_owner': parsed_args.device_owner})
    if parsed_args.name:
        body['port'].update({'name': parsed_args.name})
    ips = []
    if parsed_args.fixed_ip:
        for ip_spec in parsed_args.fixed_ip:
            ip_dict = utils.str2dict(ip_spec)
            if 'subnet_id' in ip_dict:
                subnet_name_id = ip_dict['subnet_id']
                _subnet_id = neutronV20.find_resourceid_by_name_or_id(
                    client, 'subnet', subnet_name_id)
                ip_dict['subnet_id'] = _subnet_id
            ips.append(ip_dict)
    if ips:
        body['port'].update({'fixed_ips': ips})
Exemplo n.º 24
0
def _updatable_args2body(parsed_args, body, client):
    if parsed_args.device_id:
        body['port'].update({'device_id': parsed_args.device_id})
    if parsed_args.device_owner:
        body['port'].update({'device_owner': parsed_args.device_owner})
    if parsed_args.name:
        body['port'].update({'name': parsed_args.name})
    ips = []
    if parsed_args.fixed_ip:
        for ip_spec in parsed_args.fixed_ip:
            ip_dict = utils.str2dict(ip_spec)
            if 'subnet_id' in ip_dict:
                subnet_name_id = ip_dict['subnet_id']
                _subnet_id = neutronV20.find_resourceid_by_name_or_id(
                    client, 'subnet', subnet_name_id)
                ip_dict['subnet_id'] = _subnet_id
            ips.append(ip_dict)
    if ips:
        body['port'].update({'fixed_ips': ips})
Exemplo n.º 25
0
 def run(self, parsed_args):
     self.log.debug("run(%s)" % parsed_args)
     neutron_client = self.get_client()
     neutron_client.format = parsed_args.request_format
     _router_id = neutronV20.find_resourceid_by_name_or_id(neutron_client, self.resource, parsed_args.router)
     _ext_net_id = neutronV20.find_resourceid_by_name_or_id(neutron_client, "network", parsed_args.external_network)
     router_dict = {"network_id": _ext_net_id}
     if parsed_args.disable_snat:
         router_dict["enable_snat"] = False
     if parsed_args.fixed_ip:
         ips = []
         for ip_spec in parsed_args.fixed_ip:
             ip_dict = utils.str2dict(ip_spec)
             subnet_name_id = ip_dict.get("subnet_id")
             if subnet_name_id:
                 subnet_id = neutronV20.find_resourceid_by_name_or_id(neutron_client, "subnet", subnet_name_id)
                 ip_dict["subnet_id"] = subnet_id
             ips.append(ip_dict)
         router_dict["external_fixed_ips"] = ips
     neutron_client.add_gateway_router(_router_id, router_dict)
     print(_("Set gateway for router %s") % parsed_args.router, file=self.app.stdout)
Exemplo n.º 26
0
 def test_validate_lifetime_dictionary_empty_value(self):
     input_str = utils.str2dict('units=seconds,value=')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 27
0
 def test_validate_dpd_dictionary_zero_timeout(self):
     input_str = utils.str2dict('action=hold,interval=30,timeout=0')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 28
0
 def test_validate_dpd_dictionary_empty_interval(self):
     input_str = utils.str2dict('action=hold,interval=,timeout=120')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 29
0
 def test_validate_dpd_dictionary_action_hold(self):
     input_str = utils.str2dict("action=hold,interval=30,timeout=120")
     self.assertIsNone(vpn_utils.validate_dpd_dict(input_str))
Exemplo n.º 30
0
 def test_validate_lifetime_dictionary_seconds(self):
     input_str = utils.str2dict("units=seconds,value=3600")
     self.assertIsNone(vpn_utils.validate_lifetime_dict(input_str))
Exemplo n.º 31
0
 def test_validate_lifetime_dictionary_unsupported_units(self):
     input_str = utils.str2dict('units=minutes,value=3600')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 32
0
 def test_validate_dpd_dictionary_action_disabled(self):
     input_str = utils.str2dict('action=disabled,interval=30,timeout=120')
     self.assertIsNone(vpn_utils.validate_dpd_dict(input_str))
Exemplo n.º 33
0
 def test_validate_lifetime_dictionary_invalid_empty_unit(self):
     input_str = utils.str2dict('units=,value=3600')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 34
0
 def test_validate_lifetime_dictionary_under_minimum_integer_value(self):
     input_str = utils.str2dict('units=seconds,value=59')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 35
0
 def test_validate_lifetime_dictionary_invalid_unit_key_value(self):
     input_str = utils.str2dict('units=seconds,val=3600')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 36
0
 def test_validate_lifetime_dictionary_unsupported_units(self):
     input_str = utils.str2dict('units=minutes,value=3600')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 37
0
 def test_validate_dpd_dictionary_action_disabled(self):
     input_str = utils.str2dict('action=disabled,interval=30,timeout=120')
     self.assertIsNone(vpn_utils.validate_dpd_dict(input_str))
Exemplo n.º 38
0
 def test_validate_dpd_dictionary_action_restart_by_peer(self):
     input_str = utils.str2dict(
         "action=restart-by-peer,interval=30,timeout=120"
     )
     self.assertIsNone(vpn_utils.validate_dpd_dict(input_str))
Exemplo n.º 39
0
 def test_validate_dpd_dictionary_action_hold(self):
     input_str = utils.str2dict("action=hold,interval=30,timeout=120")
     self.assertIsNone(vpn_utils.validate_dpd_dict(input_str))
Exemplo n.º 40
0
 def test_validate_lifetime_dictionary_under_minimum_integer_value(self):
     input_str = utils.str2dict('units=seconds,value=59')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 41
0
 def test_validate_lifetime_dictionary_empty_value(self):
     input_str = utils.str2dict('units=seconds,value=')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 42
0
 def test_validate_lifetime_dictionary_invalid_empty_unit(self):
     input_str = utils.str2dict('units=,value=3600')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 43
0
 def test_validate_dpd_dictionary_invalid_key_timeout(self):
     input_str = utils.str2dict('action=hold,interval=30,tiut=120')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 44
0
 def test_validate_lifetime_dictionary_invalid_unit_key_value(self):
     input_str = utils.str2dict('units=seconds,val=3600')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 45
0
 def test_validate_dpd_dictionary_unsupported_action(self):
     input_str = utils.str2dict('action=bye-bye,interval=30,timeout=120')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 46
0
 def test_validate_dpd_dictionary_action_restart_by_peer(self):
     input_str = utils.str2dict(
         "action=restart-by-peer,interval=30,timeout=120")
     self.assertIsNone(vpn_utils.validate_dpd_dict(input_str))
Exemplo n.º 47
0
 def test_validate_dpd_dictionary_empty_action(self):
     input_str = utils.str2dict('action=,interval=30,timeout=120')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 48
0
 def test_string_to_dictionary(self):
     input_str = 'key1=value1,key2=value2'
     expected = {'key1': 'value1', 'key2': 'value2'}
     self.assertEqual(expected, utils.str2dict(input_str))
Exemplo n.º 49
0
 def test_validate_dpd_dictionary_unsupported_action(self):
     input_str = utils.str2dict('action=bye-bye,interval=30,timeout=120')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 50
0
 def test_validate_dpd_dictionary_negative_timeout_value(self):
     input_str = utils.str2dict('action=hold,interval=30,timeout=-1')
     self._test_validate_lifetime_negative_test_case(input_str)
Exemplo n.º 51
0
 def test_validate_dpd_dictionary_invalid_key_action(self):
     input_str = utils.str2dict('act=hold,interval=30,timeout=120')
     self._test_validate_dpd_negative_test_case(input_str)
Exemplo n.º 52
0
 def test_validate_lifetime_dictionary_seconds(self):
     input_str = utils.str2dict("units=seconds,value=3600")
     self.assertIsNone(vpn_utils.validate_lifetime_dict(input_str))
Exemplo n.º 53
0
 def test_validate_dpd_dictionary_negative_timeout_value(self):
     input_str = utils.str2dict('action=hold,interval=30,timeout=-1')
     self._test_validate_lifetime_negative_test_case(input_str)