@@ -143,16 +143,65 @@ def test_api_put_update_pre_boot(test_microvm_with_api):
143
143
assert (response_json ['mem_size_mib' ] == str (microvm_config_json ['mem_size_mib' ]))
144
144
assert (response_json ['cpu_template' ] == str (microvm_config_json ['cpu_template' ]))
145
145
146
+ second_if_name = 'second_tap'
147
+ response = test_microvm .api_session .put (
148
+ test_microvm .net_cfg_url + '/2' ,
149
+ json = {
150
+ 'iface_id' : '2' ,
151
+ 'host_dev_name' : test_microvm .slot .make_tap (name = second_if_name ),
152
+ 'guest_mac' : '07:00:00:00:00:01' ,
153
+ 'state' : 'Attached'
154
+ }
155
+ )
156
+ """ Adding new network interfaces is allowed. """
157
+ assert (test_microvm .api_session .is_good_response (response .status_code ))
158
+
159
+ response = test_microvm .api_session .put (
160
+ test_microvm .net_cfg_url + '/2' ,
161
+ json = {
162
+ 'iface_id' : '2' ,
163
+ 'host_dev_name' : second_if_name ,
164
+ 'guest_mac' : '06:00:00:00:00:01' ,
165
+ 'state' : 'Attached'
166
+ }
167
+ )
168
+ """ Updates to a network interface with an unavailable MAC are not allowed. """
169
+ assert (not test_microvm .api_session .is_good_response (response .status_code ))
170
+
171
+ response = test_microvm .api_session .put (
172
+ test_microvm .net_cfg_url + '/2' ,
173
+ json = {
174
+ 'iface_id' : '2' ,
175
+ 'host_dev_name' : second_if_name ,
176
+ 'guest_mac' : '08:00:00:00:00:01' ,
177
+ 'state' : 'Attached'
178
+ }
179
+ )
180
+ """ Updates to a network interface with an available MAC are allowed. """
181
+ assert (test_microvm .api_session .is_good_response (response .status_code ))
182
+
146
183
response = test_microvm .api_session .put (
147
184
test_microvm .net_cfg_url + '/1' ,
148
185
json = {
149
186
'iface_id' : '1' ,
150
- 'host_dev_name' : test_microvm .slot .make_tap (name = 'newtap' ),
187
+ 'host_dev_name' : second_if_name ,
188
+ 'guest_mac' : '06:00:00:00:00:01' ,
189
+ 'state' : 'Attached'
190
+ }
191
+ )
192
+ """ Updates to a network interface with an unavailable name are not allowed. """
193
+ assert (not test_microvm .api_session .is_good_response (response .status_code ))
194
+
195
+ response = test_microvm .api_session .put (
196
+ test_microvm .net_cfg_url + '/1' ,
197
+ json = {
198
+ 'iface_id' : '1' ,
199
+ 'host_dev_name' : test_microvm .slot .make_tap (),
151
200
'guest_mac' : '06:00:00:00:00:01' ,
152
201
'state' : 'Attached'
153
202
}
154
203
)
155
- """ Valid updates to the network `host_dev_name` are allowed. """
204
+ """ Updates to a network interface with an available name are allowed. """
156
205
assert (test_microvm .api_session .is_good_response (response .status_code ))
157
206
158
207
0 commit comments