Add more update options to VPN objects
Change-Id: Ieb9da32b6f3b908dda7b4c5b99cb4ca2b79c9286
This commit is contained in:
parent
085766350e
commit
cc6a5cb498
@ -499,3 +499,23 @@ FAKE_LEP = {
|
|||||||
"trust_ca_ids": [],
|
"trust_ca_ids": [],
|
||||||
"trust_crl_ids": [],
|
"trust_crl_ids": [],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FAKE_VPN_SESS_ID = "33b2f8ce-4357-4780-8c7c-270094847395"
|
||||||
|
FAKE_VPN_SESS = {
|
||||||
|
"resource_type": "PolicyBasedIPSecVPNSession",
|
||||||
|
"description": "con1",
|
||||||
|
"id": FAKE_VPN_SESS_ID,
|
||||||
|
"display_name": "con1",
|
||||||
|
"ipsec_vpn_service_id": "f5bbbd92-0c57-412f-82e6-83c73298f2e9",
|
||||||
|
"peer_endpoint_id": "7a821e15-93b6-46f9-9d2a-db5a164ee6e3",
|
||||||
|
"local_endpoint_id": "e8a3c141-b866-4cb7-91a4-e556b7bd84d6",
|
||||||
|
"enabled": True,
|
||||||
|
"policy_rules": [{
|
||||||
|
"id": "1211",
|
||||||
|
"sources": [{"subnet": "10.0.6.0/24"}],
|
||||||
|
"logged": False,
|
||||||
|
"destinations": [{"subnet": "10.0.5.0/24"}],
|
||||||
|
"action": "PROTECT",
|
||||||
|
"enabled": True,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
@ -125,10 +125,15 @@ class TestIPSecDpdProfile(test_resources.BaseTestResource):
|
|||||||
def test_dpd_profile_update(self):
|
def test_dpd_profile_update(self):
|
||||||
fake_dpd = test_constants.FAKE_DPD.copy()
|
fake_dpd = test_constants.FAKE_DPD.copy()
|
||||||
new_timeout = 1000
|
new_timeout = 1000
|
||||||
|
new_name = 'dpd_profile_updated'
|
||||||
|
new_desc = 'desc updated'
|
||||||
uuid = test_constants.FAKE_DPD_ID
|
uuid = test_constants.FAKE_DPD_ID
|
||||||
mocked_resource = self.get_mocked_resource(response=fake_dpd)
|
mocked_resource = self.get_mocked_resource(response=fake_dpd)
|
||||||
mocked_resource.update(uuid, timeout=new_timeout)
|
mocked_resource.update(uuid, timeout=new_timeout, name=new_name,
|
||||||
|
description=new_desc)
|
||||||
fake_dpd['dpd_probe_interval'] = new_timeout
|
fake_dpd['dpd_probe_interval'] = new_timeout
|
||||||
|
fake_dpd['display_name'] = new_name
|
||||||
|
fake_dpd['description'] = new_desc
|
||||||
test_client.assert_json_call(
|
test_client.assert_json_call(
|
||||||
'put', mocked_resource,
|
'put', mocked_resource,
|
||||||
'https://1.2.3.4/api/v1/%s/%s' % (mocked_resource.uri_segment,
|
'https://1.2.3.4/api/v1/%s/%s' % (mocked_resource.uri_segment,
|
||||||
@ -262,7 +267,8 @@ class TestSession(test_resources.BaseTestResource):
|
|||||||
description = 'desc'
|
description = 'desc'
|
||||||
local_ep_id = 'uuid1'
|
local_ep_id = 'uuid1'
|
||||||
peer_ep_id = 'uuid2'
|
peer_ep_id = 'uuid2'
|
||||||
policy_rules = []
|
policy_rules = [mocked_resource.get_rule_obj(['1.1.1.0/24'],
|
||||||
|
['2.2.2.0/24'])]
|
||||||
mocked_resource.create(name, local_ep_id, peer_ep_id, policy_rules,
|
mocked_resource.create(name, local_ep_id, peer_ep_id, policy_rules,
|
||||||
description=description)
|
description=description)
|
||||||
test_client.assert_json_call(
|
test_client.assert_json_call(
|
||||||
@ -280,6 +286,27 @@ class TestSession(test_resources.BaseTestResource):
|
|||||||
headers=self.default_headers())
|
headers=self.default_headers())
|
||||||
|
|
||||||
# TODO(asarfaty): add tests for update & rules
|
# TODO(asarfaty): add tests for update & rules
|
||||||
|
def test_session_update(self):
|
||||||
|
fake_sess = test_constants.FAKE_VPN_SESS.copy()
|
||||||
|
mocked_resource = self.get_mocked_resource(response=fake_sess)
|
||||||
|
uuid = test_constants.FAKE_VPN_SESS_ID
|
||||||
|
new_name = 'session'
|
||||||
|
new_desc = 'desc'
|
||||||
|
cidr1 = '1.1.1.0/24'
|
||||||
|
cidr2 = '2.2.2.0/24'
|
||||||
|
policy_rules = [mocked_resource.get_rule_obj([cidr1], [cidr2])]
|
||||||
|
mocked_resource.update(uuid, name=new_name, description=new_desc,
|
||||||
|
policy_rules=policy_rules, enabled=False)
|
||||||
|
fake_sess['description'] = new_desc
|
||||||
|
fake_sess['display_name'] = new_name
|
||||||
|
fake_sess['policy_rules'] = policy_rules
|
||||||
|
fake_sess['enabled'] = False
|
||||||
|
test_client.assert_json_call(
|
||||||
|
'put', mocked_resource,
|
||||||
|
'https://1.2.3.4/api/v1/%s/%s' % (mocked_resource.uri_segment,
|
||||||
|
uuid),
|
||||||
|
data=jsonutils.dumps(fake_sess, sort_keys=True),
|
||||||
|
headers=self.default_headers())
|
||||||
|
|
||||||
|
|
||||||
class TestService(test_resources.BaseTestResource):
|
class TestService(test_resources.BaseTestResource):
|
||||||
|
@ -193,9 +193,7 @@ class IPSecDpdProfile(utils.NsxLibApiBase):
|
|||||||
def uri_segment(self):
|
def uri_segment(self):
|
||||||
return VPN_IPSEC_PATH + 'dpd-profiles'
|
return VPN_IPSEC_PATH + 'dpd-profiles'
|
||||||
|
|
||||||
def create(self, name, description=None,
|
def create(self, name, description=None, enabled=None, timeout=None,
|
||||||
enabled=None,
|
|
||||||
timeout=None,
|
|
||||||
tags=None):
|
tags=None):
|
||||||
|
|
||||||
# mandatory parameters
|
# mandatory parameters
|
||||||
@ -212,10 +210,14 @@ class IPSecDpdProfile(utils.NsxLibApiBase):
|
|||||||
body['tags'] = tags
|
body['tags'] = tags
|
||||||
return self.client.create(self.get_path(), body=body)
|
return self.client.create(self.get_path(), body=body)
|
||||||
|
|
||||||
def update(self, profile_id, enabled=None,
|
def update(self, profile_id, name=None, description=None, enabled=None,
|
||||||
timeout=None, tags=None):
|
timeout=None, tags=None):
|
||||||
|
|
||||||
body = self.get(profile_id)
|
body = self.get(profile_id)
|
||||||
|
if name:
|
||||||
|
body['display_name'] = name
|
||||||
|
if description:
|
||||||
|
body['description'] = description
|
||||||
if timeout:
|
if timeout:
|
||||||
body['dpd_probe_interval'] = timeout
|
body['dpd_probe_interval'] = timeout
|
||||||
if enabled is not None:
|
if enabled is not None:
|
||||||
@ -388,7 +390,7 @@ class Session(utils.NsxLibApiBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def update(self, uuid, name=None, description=None, policy_rules=None,
|
def update(self, uuid, name=None, description=None, policy_rules=None,
|
||||||
tags=None):
|
tags=None, enabled=None):
|
||||||
body = self.get(uuid)
|
body = self.get(uuid)
|
||||||
if description:
|
if description:
|
||||||
body['description'] = description
|
body['description'] = description
|
||||||
@ -398,6 +400,8 @@ class Session(utils.NsxLibApiBase):
|
|||||||
body['display_name'] = name
|
body['display_name'] = name
|
||||||
if policy_rules is not None:
|
if policy_rules is not None:
|
||||||
body['policy_rules'] = policy_rules
|
body['policy_rules'] = policy_rules
|
||||||
|
if enabled is not None:
|
||||||
|
body['enabled'] = enabled
|
||||||
return self.client.update(self.get_path(uuid), body=body)
|
return self.client.update(self.get_path(uuid), body=body)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user