@@ -165,18 +165,18 @@ def tearDown(self):
165165 def create_VPN (self , public_ip ):
166166 """Creates VPN for the network"""
167167
168- self .debug ("Creating VPN with public IP: %s" % public_ip .ipaddress . id )
168+ self .debug ("Creating VPN with public IP: %s" % public_ip .id )
169169 try :
170170 # Assign VPN to Public IP
171171 vpn = Vpn .create (self .apiclient ,
172- self . public_ip . ipaddress .id ,
172+ public_ip .id ,
173173 account = self .account .name ,
174174 domainid = self .account .domainid )
175175 self .cleanup .append (vpn )
176176
177177 self .debug ("Verifying the remote VPN access" )
178178 vpns = Vpn .list (self .apiclient ,
179- publicipid = public_ip .ipaddress . id ,
179+ publicipid = public_ip .id ,
180180 listall = True )
181181 self .assertEqual (
182182 isinstance (vpns , list ),
@@ -244,7 +244,23 @@ def test_01_VPN_user_limit(self):
244244 self .debug ("Enabling the VPN access for IP: %s" %
245245 self .public_ip .ipaddress )
246246
247- self .create_VPN (self .public_ip )
247+ network_id = self .virtual_machine .nic [0 ].networkid
248+ src_nat_list = PublicIPAddress .list (
249+ self .apiclient ,
250+ account = self .account .name ,
251+ domainid = self .account .domainid ,
252+ listall = True ,
253+ issourcenat = True ,
254+ associatednetworkid = network_id
255+ )
256+ self .assertEqual (
257+ validateList (src_nat_list )[0 ],
258+ PASS ,
259+ "Failed to list source nat ip address"
260+ )
261+ ip = src_nat_list [0 ]
262+
263+ self .create_VPN (ip )
248264 self .debug ("Creating %s VPN users" % limit )
249265 for x in range (limit ):
250266 self .create_VPN_Users ()
@@ -296,9 +312,24 @@ def test_03_enable_vpn_use_port(self):
296312 # 3. add a port forward rule for UDP port 1701. Should result in error
297313 # saying that VPN is enabled over port 1701
298314
315+ network_id = self .virtual_machine .nic [0 ].networkid
316+ src_nat_list = PublicIPAddress .list (
317+ self .apiclient ,
318+ account = self .account .name ,
319+ domainid = self .account .domainid ,
320+ listall = True ,
321+ issourcenat = True ,
322+ associatednetworkid = network_id
323+ )
324+ self .assertEqual (
325+ validateList (src_nat_list )[0 ],
326+ PASS ,
327+ "Failed to list source nat ip address"
328+ )
329+ ip = src_nat_list [0 ]
299330 self .debug ("Enabling the VPN connection for IP: %s" %
300- self . public_ip . ipaddress )
301- self .create_VPN (self . public_ip )
331+ ip . address )
332+ self .create_VPN (ip )
302333
303334 self .debug ("Creating a port forwarding rule on port 1701" )
304335 # Create NAT rule
@@ -307,7 +338,7 @@ def test_03_enable_vpn_use_port(self):
307338 self .apiclient ,
308339 self .virtual_machine ,
309340 self .services ["natrule" ],
310- self . public_ip . ipaddress .id )
341+ ip .id )
311342
312343 self .debug ("Create NAT rule failed! Test successful!" )
313344 return
@@ -322,9 +353,25 @@ def test_04_add_new_users(self):
322353 # 3. We should be able to successfully establish a VPN connection using
323354 # the newly added user credential.
324355
356+ network_id = self .virtual_machine .nic [0 ].networkid
357+ src_nat_list = PublicIPAddress .list (
358+ self .apiclient ,
359+ account = self .account .name ,
360+ domainid = self .account .domainid ,
361+ listall = True ,
362+ issourcenat = True ,
363+ associatednetworkid = network_id
364+ )
365+ self .assertEqual (
366+ validateList (src_nat_list )[0 ],
367+ PASS ,
368+ "Failed to list source nat ip address"
369+ )
370+ ip = src_nat_list [0 ]
371+
325372 self .debug ("Enabling the VPN connection for IP: %s" %
326- self . public_ip . ipaddress )
327- self .create_VPN (self . public_ip )
373+ ip . address )
374+ self .create_VPN (ip )
328375
329376 try :
330377 self .debug ("Adding new VPN user to account: %s" %
@@ -349,9 +396,24 @@ def test_05_add_duplicate_user(self):
349396 # 2. Add a VPN user say "abc" that already an added user to the VPN.
350397 # 3. Adding this VPN user should fail.
351398
399+ network_id = self .virtual_machine .nic [0 ].networkid
400+ src_nat_list = PublicIPAddress .list (
401+ self .apiclient ,
402+ account = self .account .name ,
403+ domainid = self .account .domainid ,
404+ listall = True ,
405+ issourcenat = True ,
406+ associatednetworkid = network_id
407+ )
408+ self .assertEqual (
409+ validateList (src_nat_list )[0 ],
410+ PASS ,
411+ "Failed to list source nat ip address"
412+ )
413+ ip = src_nat_list [0 ]
352414 self .debug ("Enabling the VPN connection for IP: %s" %
353- self . public_ip . ipaddress )
354- self .create_VPN (self . public_ip )
415+ ip . address )
416+ self .create_VPN (ip )
355417
356418 self .debug ("Adding new VPN user to account: %s" %
357419 self .account .name )
@@ -379,9 +441,24 @@ def test_06_add_VPN_user_global_admin(self):
379441 # 2. We should be able to use this newly created user credential to
380442 # establish VPN connection that will give access all VMs of this user
381443
444+ network_id = self .virtual_machine .nic [0 ].networkid
445+ src_nat_list = PublicIPAddress .list (
446+ self .apiclient ,
447+ account = self .account .name ,
448+ domainid = self .account .domainid ,
449+ listall = True ,
450+ issourcenat = True ,
451+ associatednetworkid = network_id
452+ )
453+ self .assertEqual (
454+ validateList (src_nat_list )[0 ],
455+ PASS ,
456+ "Failed to list source nat ip address"
457+ )
458+ ip = src_nat_list [0 ]
382459 self .debug ("Enabling VPN connection to account: %s" %
383460 self .account .name )
384- self .create_VPN (self . public_ip )
461+ self .create_VPN (ip )
385462 self .debug ("Creating VPN user for the account: %s" %
386463 self .account .name )
387464 self .create_VPN_Users ()
@@ -422,9 +499,24 @@ def test_07_add_VPN_user_domain_admin(self):
422499 # 2. We should be able to use this newly created user credential to
423500 # establish VPN connection that will give access all VMs of this user
424501
502+ network_id = self .virtual_machine .nic [0 ].networkid
503+ src_nat_list = PublicIPAddress .list (
504+ self .apiclient ,
505+ account = self .account .name ,
506+ domainid = self .account .domainid ,
507+ listall = True ,
508+ issourcenat = True ,
509+ associatednetworkid = network_id
510+ )
511+ self .assertEqual (
512+ validateList (src_nat_list )[0 ],
513+ PASS ,
514+ "Failed to list source nat ip address"
515+ )
516+ ip = src_nat_list [0 ]
425517 self .debug ("Enabling VPN connection to account: %s" %
426518 self .account .name )
427- self .create_VPN (self . public_ip )
519+ self .create_VPN (ip )
428520 self .debug ("Creating VPN user for the account: %s" %
429521 self .account .name )
430522 self .create_VPN_Users ()
0 commit comments