91 |
91 |
res = json.loads(response.content)
|
92 |
92 |
self.assertEqual(res['port']['name'], "test-name")
|
93 |
93 |
|
94 |
|
def test_update_port_sg_unfound(self):
|
95 |
|
sg1 = dbmf.SecurityGroupFactory()
|
96 |
|
nic = dbmf.NetworkInterfaceFactory(device_owner='vm')
|
97 |
|
nic.security_groups.add(sg1)
|
98 |
|
nic.save()
|
99 |
|
url = join_urls(PORTS_URL, str(nic.id))
|
100 |
|
request = {'port': {"security_groups": ["123"]}}
|
101 |
|
response = self.put(url, params=json.dumps(request),
|
102 |
|
user=nic.userid)
|
103 |
|
self.assertEqual(response.status_code, 404)
|
|
94 |
# def test_update_port_sg_unfound(self):
|
|
95 |
# sg1 = dbmf.SecurityGroupFactory()
|
|
96 |
# nic = dbmf.NetworkInterfaceFactory(device_owner='vm')
|
|
97 |
# nic.security_groups.add(sg1)
|
|
98 |
# nic.save()
|
|
99 |
# url = join_urls(PORTS_URL, str(nic.id))
|
|
100 |
# request = {'port': {"security_groups": ["123"]}}
|
|
101 |
# response = self.put(url, params=json.dumps(request),
|
|
102 |
# user=nic.userid)
|
|
103 |
# self.assertEqual(response.status_code, 404)
|
104 |
104 |
|
105 |
|
def test_update_port_sg(self):
|
106 |
|
sg1 = dbmf.SecurityGroupFactory()
|
107 |
|
sg2 = dbmf.SecurityGroupFactory()
|
108 |
|
sg3 = dbmf.SecurityGroupFactory()
|
109 |
|
nic = dbmf.NetworkInterfaceFactory(device_owner='vm')
|
110 |
|
nic.security_groups.add(sg1)
|
111 |
|
nic.save()
|
112 |
|
url = join_urls(PORTS_URL, str(nic.id))
|
113 |
|
request = {'port': {"security_groups": [str(sg2.id), str(sg3.id)]}}
|
114 |
|
response = self.put(url, params=json.dumps(request),
|
115 |
|
user=nic.userid)
|
116 |
|
res = json.loads(response.content)
|
117 |
|
self.assertEqual(res['port']['security_groups'],
|
118 |
|
[str(sg2.id), str(sg3.id)])
|
|
105 |
# def test_update_port_sg(self):
|
|
106 |
# sg1 = dbmf.SecurityGroupFactory()
|
|
107 |
# sg2 = dbmf.SecurityGroupFactory()
|
|
108 |
# sg3 = dbmf.SecurityGroupFactory()
|
|
109 |
# nic = dbmf.NetworkInterfaceFactory(device_owner='vm')
|
|
110 |
# nic.security_groups.add(sg1)
|
|
111 |
# nic.save()
|
|
112 |
# url = join_urls(PORTS_URL, str(nic.id))
|
|
113 |
# request = {'port': {"security_groups": [str(sg2.id), str(sg3.id)]}}
|
|
114 |
# response = self.put(url, params=json.dumps(request),
|
|
115 |
# user=nic.userid)
|
|
116 |
# res = json.loads(response.content)
|
|
117 |
# self.assertEqual(res['port']['security_groups'],
|
|
118 |
# [str(sg2.id), str(sg3.id)])
|
119 |
119 |
|
120 |
120 |
def test_create_port_no_network(self):
|
121 |
121 |
request = {
|