test_neutron.py 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118
  1. # -*- coding: utf-8 -*-
  2. """
  3. :codeauthor: Jayesh Kariya <jayeshk@saltstack.com>
  4. """
  5. # Import Python Libs
  6. from __future__ import absolute_import, print_function, unicode_literals
  7. import pytest
  8. # Import Salt Libs
  9. import salt.modules.neutron as neutron
  10. # Import Salt Testing Libs
  11. from tests.support.mixins import LoaderModuleMockMixin
  12. from tests.support.mock import MagicMock
  13. from tests.support.unit import TestCase
  14. class MockNeutron(object):
  15. """
  16. Mock of neutron
  17. """
  18. @staticmethod
  19. def get_quotas_tenant():
  20. """
  21. Mock of get_quotas_tenant method
  22. """
  23. return True
  24. @staticmethod
  25. def list_quotas():
  26. """
  27. Mock of list_quotas method
  28. """
  29. return True
  30. @staticmethod
  31. def show_quota(tenant_id):
  32. """
  33. Mock of show_quota method
  34. """
  35. return tenant_id
  36. @staticmethod
  37. def update_quota(
  38. tenant_id,
  39. subnet,
  40. router,
  41. network,
  42. floatingip,
  43. port,
  44. security_group,
  45. security_group_rule,
  46. ):
  47. """
  48. Mock of update_quota method
  49. """
  50. return (
  51. tenant_id,
  52. subnet,
  53. router,
  54. network,
  55. floatingip,
  56. port,
  57. security_group,
  58. security_group_rule,
  59. )
  60. @staticmethod
  61. def delete_quota(tenant_id):
  62. """
  63. Mock of delete_quota method
  64. """
  65. return tenant_id
  66. @staticmethod
  67. def list_extensions():
  68. """
  69. Mock of list_extensions method
  70. """
  71. return True
  72. @staticmethod
  73. def list_ports():
  74. """
  75. Mock of list_ports method
  76. """
  77. return True
  78. @staticmethod
  79. def show_port(port):
  80. """
  81. Mock of show_port method
  82. """
  83. return port
  84. @staticmethod
  85. def create_port(name, network, device_id, admin_state_up):
  86. """
  87. Mock of create_port method
  88. """
  89. return (name, network, device_id, admin_state_up)
  90. @staticmethod
  91. def update_port(port, name, admin_state_up):
  92. """
  93. Mock of update_port method
  94. """
  95. return (port, name, admin_state_up)
  96. @staticmethod
  97. def delete_port(port):
  98. """
  99. Mock of delete_port method
  100. """
  101. return port
  102. @staticmethod
  103. def list_networks():
  104. """
  105. Mock of list_networks method
  106. """
  107. return True
  108. @staticmethod
  109. def show_network(network):
  110. """
  111. Mock of show_network method
  112. """
  113. return network
  114. @staticmethod
  115. def create_network(
  116. name,
  117. admin_state_up,
  118. router_ext,
  119. network_type,
  120. physical_network,
  121. segmentation_id,
  122. shared,
  123. ):
  124. """
  125. Mock of create_network method
  126. """
  127. return (
  128. name,
  129. admin_state_up,
  130. router_ext,
  131. network_type,
  132. physical_network,
  133. segmentation_id,
  134. shared,
  135. )
  136. @staticmethod
  137. def update_network(network, name):
  138. """
  139. Mock of update_network method
  140. """
  141. return (network, name)
  142. @staticmethod
  143. def delete_network(network):
  144. """
  145. Mock of delete_network method
  146. """
  147. return network
  148. @staticmethod
  149. def list_subnets():
  150. """
  151. Mock of list_subnets method
  152. """
  153. return True
  154. @staticmethod
  155. def show_subnet(subnet):
  156. """
  157. Mock of show_subnet method
  158. """
  159. return subnet
  160. @staticmethod
  161. def create_subnet(network, cidr, name, ip_version):
  162. """
  163. Mock of create_subnet method
  164. """
  165. return (network, cidr, name, ip_version)
  166. @staticmethod
  167. def update_subnet(subnet, name):
  168. """
  169. Mock of update_subnet method
  170. """
  171. return (subnet, name)
  172. @staticmethod
  173. def delete_subnet(subnet):
  174. """
  175. Mock of delete_subnet method
  176. """
  177. return subnet
  178. @staticmethod
  179. def list_routers():
  180. """
  181. Mock of list_routers method
  182. """
  183. return True
  184. @staticmethod
  185. def show_router(router):
  186. """
  187. Mock of show_router method
  188. """
  189. return router
  190. @staticmethod
  191. def create_router(name, ext_network, admin_state_up):
  192. """
  193. Mock of create_router method
  194. """
  195. return (name, ext_network, admin_state_up)
  196. @staticmethod
  197. def update_router(router, name, admin_state_up, **kwargs):
  198. """
  199. Mock of update_router method
  200. """
  201. return (router, name, admin_state_up, kwargs)
  202. @staticmethod
  203. def delete_router(router):
  204. """
  205. Mock of delete_router method
  206. """
  207. return router
  208. @staticmethod
  209. def add_interface_router(router, subnet):
  210. """
  211. Mock of add_interface_router method
  212. """
  213. return (router, subnet)
  214. @staticmethod
  215. def remove_interface_router(router, subnet):
  216. """
  217. Mock of remove_interface_router method
  218. """
  219. return (router, subnet)
  220. @staticmethod
  221. def add_gateway_router(router, ext_network):
  222. """
  223. Mock of add_gateway_router method
  224. """
  225. return (router, ext_network)
  226. @staticmethod
  227. def remove_gateway_router(router):
  228. """
  229. Mock of remove_gateway_router method
  230. """
  231. return router
  232. @staticmethod
  233. def list_floatingips():
  234. """
  235. Mock of list_floatingips method
  236. """
  237. return True
  238. @staticmethod
  239. def show_floatingip(floatingip_id):
  240. """
  241. Mock of show_floatingip method
  242. """
  243. return floatingip_id
  244. @staticmethod
  245. def create_floatingip(floating_network, port):
  246. """
  247. Mock of create_floatingip method
  248. """
  249. return (floating_network, port)
  250. @staticmethod
  251. def update_floatingip(floating_network, port):
  252. """
  253. Mock of create_floatingip method
  254. """
  255. return (floating_network, port)
  256. @staticmethod
  257. def delete_floatingip(floatingip_id):
  258. """
  259. Mock of delete_floatingip method
  260. """
  261. return floatingip_id
  262. @staticmethod
  263. def list_security_groups():
  264. """
  265. Mock of list_security_groups method
  266. """
  267. return True
  268. @staticmethod
  269. def show_security_group(security_group):
  270. """
  271. Mock of show_security_group method
  272. """
  273. return security_group
  274. @staticmethod
  275. def create_security_group(name, description):
  276. """
  277. Mock of create_security_group method
  278. """
  279. return (name, description)
  280. @staticmethod
  281. def update_security_group(security_group, name, description):
  282. """
  283. Mock of update_security_group method
  284. """
  285. return (security_group, name, description)
  286. @staticmethod
  287. def delete_security_group(security_group):
  288. """
  289. Mock of delete_security_group method
  290. """
  291. return security_group
  292. @staticmethod
  293. def list_security_group_rules():
  294. """
  295. Mock of list_security_group_rules method
  296. """
  297. return True
  298. @staticmethod
  299. def show_security_group_rule(security_group_rule_id):
  300. """
  301. Mock of show_security_group_rule method
  302. """
  303. return security_group_rule_id
  304. @staticmethod
  305. def create_security_group_rule(
  306. security_group,
  307. remote_group_id,
  308. direction,
  309. protocol,
  310. port_range_min,
  311. port_range_max,
  312. ethertype,
  313. ):
  314. """
  315. Mock of create_security_group_rule method
  316. """
  317. return (
  318. security_group,
  319. remote_group_id,
  320. direction,
  321. protocol,
  322. port_range_min,
  323. port_range_max,
  324. ethertype,
  325. )
  326. @staticmethod
  327. def delete_security_group_rule(security_group_rule_id):
  328. """
  329. Mock of delete_security_group_rule method
  330. """
  331. return security_group_rule_id
  332. @staticmethod
  333. def list_vpnservices(retrieve_all, **kwargs):
  334. """
  335. Mock of list_vpnservices method
  336. """
  337. return (retrieve_all, kwargs)
  338. @staticmethod
  339. def show_vpnservice(vpnservice, **kwargs):
  340. """
  341. Mock of show_vpnservice method
  342. """
  343. return (vpnservice, kwargs)
  344. @staticmethod
  345. def create_vpnservice(subnet, router, name, admin_state_up):
  346. """
  347. Mock of create_vpnservice method
  348. """
  349. return (subnet, router, name, admin_state_up)
  350. @staticmethod
  351. def update_vpnservice(vpnservice, desc):
  352. """
  353. Mock of update_vpnservice method
  354. """
  355. return (vpnservice, desc)
  356. @staticmethod
  357. def delete_vpnservice(vpnservice):
  358. """
  359. Mock of delete_vpnservice method
  360. """
  361. return vpnservice
  362. @staticmethod
  363. def list_ipsec_site_connections():
  364. """
  365. Mock of list_ipsec_site_connections method
  366. """
  367. return True
  368. @staticmethod
  369. def show_ipsec_site_connection(ipsec_site_connection):
  370. """
  371. Mock of show_ipsec_site_connection method
  372. """
  373. return ipsec_site_connection
  374. @staticmethod
  375. def create_ipsec_site_connection(
  376. name,
  377. ipsecpolicy,
  378. ikepolicy,
  379. vpnservice,
  380. peer_cidrs,
  381. peer_address,
  382. peer_id,
  383. psk,
  384. admin_state_up,
  385. **kwargs
  386. ):
  387. """
  388. Mock of create_ipsec_site_connection method
  389. """
  390. return (
  391. name,
  392. ipsecpolicy,
  393. ikepolicy,
  394. vpnservice,
  395. peer_cidrs,
  396. peer_address,
  397. peer_id,
  398. psk,
  399. admin_state_up,
  400. kwargs,
  401. )
  402. @staticmethod
  403. def delete_ipsec_site_connection(ipsec_site_connection):
  404. """
  405. Mock of delete_vpnservice method
  406. """
  407. return ipsec_site_connection
  408. @staticmethod
  409. def list_ikepolicies():
  410. """
  411. Mock of list_ikepolicies method
  412. """
  413. return True
  414. @staticmethod
  415. def show_ikepolicy(ikepolicy):
  416. """
  417. Mock of show_ikepolicy method
  418. """
  419. return ikepolicy
  420. @staticmethod
  421. def create_ikepolicy(name, **kwargs):
  422. """
  423. Mock of create_ikepolicy method
  424. """
  425. return (name, kwargs)
  426. @staticmethod
  427. def delete_ikepolicy(ikepolicy):
  428. """
  429. Mock of delete_ikepolicy method
  430. """
  431. return ikepolicy
  432. @staticmethod
  433. def list_ipsecpolicies():
  434. """
  435. Mock of list_ipsecpolicies method
  436. """
  437. return True
  438. @staticmethod
  439. def show_ipsecpolicy(ipsecpolicy):
  440. """
  441. Mock of show_ipsecpolicy method
  442. """
  443. return ipsecpolicy
  444. @staticmethod
  445. def create_ipsecpolicy(name, **kwargs):
  446. """
  447. Mock of create_ikepolicy method
  448. """
  449. return (name, kwargs)
  450. @staticmethod
  451. def delete_ipsecpolicy(ipsecpolicy):
  452. """
  453. Mock of delete_ipsecpolicy method
  454. """
  455. return ipsecpolicy
  456. class NeutronTestCase(TestCase, LoaderModuleMockMixin):
  457. """
  458. Test cases for salt.modules.neutron
  459. """
  460. def setup_loader_modules(self):
  461. return {neutron: {"_auth": MagicMock(return_value=MockNeutron())}}
  462. # 'get_quotas_tenant' function tests: 1
  463. @pytest.mark.slow_test(seconds=1) # Test takes >0.1 and <=1 seconds
  464. def test_get_quotas_tenant(self):
  465. """
  466. Test if it fetches tenant info in server's context for
  467. following quota operation
  468. """
  469. self.assertTrue(neutron.get_quotas_tenant(profile="openstack1"))
  470. # 'list_quotas' function tests: 1
  471. def test_list_quotas(self):
  472. """
  473. Test if it fetches all tenants quotas
  474. """
  475. self.assertTrue(neutron.list_quotas(profile="openstack1"))
  476. # 'show_quota' function tests: 1
  477. def test_show_quota(self):
  478. """
  479. Test if it fetches information of a certain tenant's quotas
  480. """
  481. self.assertTrue(neutron.show_quota("Salt", profile="openstack1"))
  482. # 'update_quota' function tests: 1
  483. def test_update_quota(self):
  484. """
  485. Test if it update a tenant's quota
  486. """
  487. self.assertTrue(
  488. neutron.update_quota(
  489. "Salt",
  490. subnet="40",
  491. router="50",
  492. network="10",
  493. floatingip="30",
  494. port="30",
  495. security_group="10",
  496. security_group_rule="SS",
  497. )
  498. )
  499. # 'delete_quota' function tests: 1
  500. def test_delete_quota(self):
  501. """
  502. Test if it delete the specified tenant's quota value
  503. """
  504. self.assertTrue(neutron.delete_quota("Salt", profile="openstack1"))
  505. # 'list_extensions' function tests: 1
  506. def test_list_extensions(self):
  507. """
  508. Test if it fetches a list of all extensions on server side
  509. """
  510. self.assertTrue(neutron.list_extensions(profile="openstack1"))
  511. # 'list_ports' function tests: 1
  512. def test_list_ports(self):
  513. """
  514. Test if it fetches a list of all networks for a tenant
  515. """
  516. self.assertTrue(neutron.list_ports(profile="openstack1"))
  517. # 'show_port' function tests: 1
  518. def test_show_port(self):
  519. """
  520. Test if it fetches information of a certain port
  521. """
  522. self.assertTrue(neutron.show_port("1080", profile="openstack1"))
  523. # 'create_port' function tests: 1
  524. def test_create_port(self):
  525. """
  526. Test if it creates a new port
  527. """
  528. self.assertTrue(
  529. neutron.create_port(
  530. "Salt",
  531. "SALTSTACK",
  532. device_id="800",
  533. admin_state_up=True,
  534. profile="openstack1",
  535. )
  536. )
  537. # 'update_port' function tests: 1
  538. def test_update_port(self):
  539. """
  540. Test if it updates a port
  541. """
  542. self.assertTrue(
  543. neutron.update_port(
  544. "800", "SALTSTACK", admin_state_up=True, profile="openstack1"
  545. )
  546. )
  547. # 'delete_port' function tests: 1
  548. def test_delete_port(self):
  549. """
  550. Test if it deletes the specified port
  551. """
  552. self.assertTrue(neutron.delete_port("1080", profile="openstack1"))
  553. # 'list_networks' function tests: 1
  554. def test_list_networks(self):
  555. """
  556. Test if it fetches a list of all networks for a tenant
  557. """
  558. self.assertTrue(neutron.list_networks(profile="openstack1"))
  559. # 'show_network' function tests: 1
  560. def test_show_network(self):
  561. """
  562. Test if it fetches information of a certain network
  563. """
  564. self.assertTrue(neutron.show_network("SALTSTACK", profile="openstack1"))
  565. # 'create_network' function tests: 1
  566. def test_create_network(self):
  567. """
  568. Test if it creates a new network
  569. """
  570. self.assertTrue(neutron.create_network("SALT", profile="openstack1"))
  571. # 'update_network' function tests: 1
  572. def test_update_network(self):
  573. """
  574. Test if it updates a network
  575. """
  576. self.assertTrue(
  577. neutron.update_network("SALT", "SLATSTACK", profile="openstack1")
  578. )
  579. # 'delete_network' function tests: 1
  580. def test_delete_network(self):
  581. """
  582. Test if it deletes the specified network
  583. """
  584. self.assertTrue(neutron.delete_network("SALTSTACK", profile="openstack1"))
  585. # 'list_subnets' function tests: 1
  586. def test_list_subnets(self):
  587. """
  588. Test if it fetches a list of all networks for a tenant
  589. """
  590. self.assertTrue(neutron.list_subnets(profile="openstack1"))
  591. # 'show_subnet' function tests: 1
  592. def test_show_subnet(self):
  593. """
  594. Test if it fetches information of a certain subnet
  595. """
  596. self.assertTrue(neutron.show_subnet("SALTSTACK", profile="openstack1"))
  597. # 'create_subnet' function tests: 1
  598. def test_create_subnet(self):
  599. """
  600. Test if it creates a new subnet
  601. """
  602. self.assertTrue(
  603. neutron.create_subnet(
  604. "192.168.1.0",
  605. "192.168.1.0/24",
  606. name="Salt",
  607. ip_version=4,
  608. profile="openstack1",
  609. )
  610. )
  611. # 'update_subnet' function tests: 1
  612. def test_update_subnet(self):
  613. """
  614. Test if it updates a subnet
  615. """
  616. self.assertTrue(
  617. neutron.update_subnet("255.255.255.0", name="Salt", profile="openstack1")
  618. )
  619. # 'delete_subnet' function tests: 1
  620. def test_delete_subnet(self):
  621. """
  622. Test if it deletes the specified subnet
  623. """
  624. self.assertTrue(neutron.delete_subnet("255.255.255.0", profile="openstack1"))
  625. # 'list_routers' function tests: 1
  626. def test_list_routers(self):
  627. """
  628. Test if it fetches a list of all routers for a tenant
  629. """
  630. self.assertTrue(neutron.list_routers(profile="openstack1"))
  631. # 'show_router' function tests: 1
  632. def test_show_router(self):
  633. """
  634. Test if it fetches information of a certain router
  635. """
  636. self.assertTrue(neutron.show_router("SALTSTACK", profile="openstack1"))
  637. # 'create_router' function tests: 1
  638. def test_create_router(self):
  639. """
  640. Test if it creates a new router
  641. """
  642. self.assertTrue(
  643. neutron.create_router(
  644. "SALT", "192.168.1.0", admin_state_up=True, profile="openstack1"
  645. )
  646. )
  647. # 'update_router' function tests: 1
  648. def test_update_router(self):
  649. """
  650. Test if it updates a router
  651. """
  652. self.assertTrue(
  653. neutron.update_router("255.255.255.0", name="Salt", profile="openstack1")
  654. )
  655. # 'delete_router' function tests: 1
  656. def test_delete_router(self):
  657. """
  658. Test if it delete the specified router
  659. """
  660. self.assertTrue(neutron.delete_router("SALTSTACK", profile="openstack1"))
  661. # 'add_interface_router' function tests: 1
  662. def test_add_interface_router(self):
  663. """
  664. Test if it adds an internal network interface to the specified router
  665. """
  666. self.assertTrue(
  667. neutron.add_interface_router("Salt", "255.255.255.0", profile="openstack1")
  668. )
  669. # 'remove_interface_router' function tests: 1
  670. def test_remove_interface_router(self):
  671. """
  672. Test if it removes an internal network interface from the specified
  673. router
  674. """
  675. self.assertTrue(
  676. neutron.remove_interface_router(
  677. "Salt", "255.255.255.0", profile="openstack1"
  678. )
  679. )
  680. # 'add_gateway_router' function tests: 1
  681. def test_add_gateway_router(self):
  682. """
  683. Test if it adds an external network gateway to the specified router
  684. """
  685. self.assertTrue(
  686. neutron.add_gateway_router("Salt", "SALTSTACK", profile="openstack1")
  687. )
  688. # 'remove_gateway_router' function tests: 1
  689. def test_remove_gateway_router(self):
  690. """
  691. Test if it removes an external network gateway from the specified router
  692. """
  693. self.assertTrue(
  694. neutron.remove_gateway_router("SALTSTACK", profile="openstack1")
  695. )
  696. # 'list_floatingips' function tests: 1
  697. def test_list_floatingips(self):
  698. """
  699. Test if it fetch a list of all floatingIPs for a tenant
  700. """
  701. self.assertTrue(neutron.list_floatingips(profile="openstack1"))
  702. # 'show_floatingip' function tests: 1
  703. def test_show_floatingip(self):
  704. """
  705. Test if it fetches information of a certain floatingIP
  706. """
  707. self.assertTrue(neutron.show_floatingip("SALTSTACK", profile="openstack1"))
  708. # 'create_floatingip' function tests: 1
  709. def test_create_floatingip(self):
  710. """
  711. Test if it creates a new floatingIP
  712. """
  713. self.assertTrue(
  714. neutron.create_floatingip("SALTSTACK", port="800", profile="openstack1")
  715. )
  716. # 'update_floatingip' function tests: 1
  717. def test_update_floatingip(self):
  718. """
  719. Test if it updates a floatingIP
  720. """
  721. self.assertTrue(
  722. neutron.update_floatingip("SALTSTACK", port="800", profile="openstack1")
  723. )
  724. # 'delete_floatingip' function tests: 1
  725. def test_delete_floatingip(self):
  726. """
  727. Test if it deletes the specified floating IP
  728. """
  729. self.assertTrue(neutron.delete_floatingip("SALTSTACK", profile="openstack1"))
  730. # 'list_security_groups' function tests: 1
  731. def test_list_security_groups(self):
  732. """
  733. Test if it fetches a list of all security groups for a tenant
  734. """
  735. self.assertTrue(neutron.list_security_groups(profile="openstack1"))
  736. # 'show_security_group' function tests: 1
  737. def test_show_security_group(self):
  738. """
  739. Test if it fetches information of a certain security group
  740. """
  741. self.assertTrue(neutron.show_security_group("SALTSTACK", profile="openstack1"))
  742. # 'create_security_group' function tests: 1
  743. def test_create_security_group(self):
  744. """
  745. Test if it creates a new security group
  746. """
  747. self.assertTrue(
  748. neutron.create_security_group(
  749. "SALTSTACK", "Security group", profile="openstack1"
  750. )
  751. )
  752. # 'update_security_group' function tests: 1
  753. def test_update_security_group(self):
  754. """
  755. Test if it updates a security group
  756. """
  757. self.assertTrue(
  758. neutron.update_security_group(
  759. "SALT", "SALTSTACK", "Security group", profile="openstack1"
  760. )
  761. )
  762. # 'delete_security_group' function tests: 1
  763. def test_delete_security_group(self):
  764. """
  765. Test if it deletes the specified security group
  766. """
  767. self.assertTrue(neutron.delete_security_group("SALT", profile="openstack1"))
  768. # 'list_security_group_rules' function tests: 1
  769. def test_list_security_group_rules(self):
  770. """
  771. Test if it fetches a list of all security group rules for a tenant
  772. """
  773. self.assertTrue(neutron.list_security_group_rules(profile="openstack1"))
  774. # 'show_security_group_rule' function tests: 1
  775. def test_show_security_group_rule(self):
  776. """
  777. Test if it fetches information of a certain security group rule
  778. """
  779. self.assertTrue(
  780. neutron.show_security_group_rule("SALTSTACK", profile="openstack1")
  781. )
  782. # 'create_security_group_rule' function tests: 1
  783. def test_create_security_group_rule(self):
  784. """
  785. Test if it creates a new security group rule
  786. """
  787. self.assertTrue(
  788. neutron.create_security_group_rule("SALTSTACK", profile="openstack1")
  789. )
  790. # 'delete_security_group_rule' function tests: 1
  791. def test_delete_security_group_rule(self):
  792. """
  793. Test if it deletes the specified security group rule
  794. """
  795. self.assertTrue(
  796. neutron.delete_security_group_rule("SALTSTACK", profile="openstack1")
  797. )
  798. # 'list_vpnservices' function tests: 1
  799. def test_list_vpnservices(self):
  800. """
  801. Test if it fetches a list of all configured VPN services for a tenant
  802. """
  803. self.assertTrue(neutron.list_vpnservices(True, profile="openstack1"))
  804. # 'show_vpnservice' function tests: 1
  805. def test_show_vpnservice(self):
  806. """
  807. Test if it fetches information of a specific VPN service
  808. """
  809. self.assertTrue(neutron.show_vpnservice("SALT", profile="openstack1"))
  810. # 'create_vpnservice' function tests: 1
  811. def test_create_vpnservice(self):
  812. """
  813. Test if it creates a new VPN service
  814. """
  815. self.assertTrue(
  816. neutron.create_vpnservice(
  817. "255.255.255.0", "SALT", "SALTSTACK", True, profile="openstack1"
  818. )
  819. )
  820. # 'update_vpnservice' function tests: 1
  821. def test_update_vpnservice(self):
  822. """
  823. Test if it updates a VPN service
  824. """
  825. self.assertTrue(
  826. neutron.update_vpnservice("SALT", "VPN Service1", profile="openstack1")
  827. )
  828. # 'delete_vpnservice' function tests: 1
  829. def test_delete_vpnservice(self):
  830. """
  831. Test if it deletes the specified VPN service
  832. """
  833. self.assertTrue(
  834. neutron.delete_vpnservice("SALT VPN Service1", profile="openstack1")
  835. )
  836. # 'list_ipsec_site_connections' function tests: 1
  837. def test_list_ipsec_site(self):
  838. """
  839. Test if it fetches all configured IPsec Site Connections for a tenant
  840. """
  841. self.assertTrue(neutron.list_ipsec_site_connections(profile="openstack1"))
  842. # 'show_ipsec_site_connection' function tests: 1
  843. def test_show_ipsec_site_connection(self):
  844. """
  845. Test if it fetches information of a specific IPsecSiteConnection
  846. """
  847. self.assertTrue(
  848. neutron.show_ipsec_site_connection("SALT", profile="openstack1")
  849. )
  850. # 'create_ipsec_site_connection' function tests: 1
  851. def test_create_ipsec_site(self):
  852. """
  853. Test if it creates a new IPsecSiteConnection
  854. """
  855. self.assertTrue(
  856. neutron.create_ipsec_site_connection(
  857. "SALTSTACK",
  858. "A",
  859. "B",
  860. "C",
  861. "192.168.1.0/24",
  862. "192.168.1.11",
  863. "192.168.1.10",
  864. "secret",
  865. profile="openstack1",
  866. )
  867. )
  868. # 'delete_ipsec_site_connection' function tests: 1
  869. def test_delete_ipsec_site(self):
  870. """
  871. Test if it deletes the specified IPsecSiteConnection
  872. """
  873. self.assertTrue(
  874. neutron.delete_ipsec_site_connection(
  875. "SALT VPN Service1", profile="openstack1"
  876. )
  877. )
  878. # 'list_ikepolicies' function tests: 1
  879. def test_list_ikepolicies(self):
  880. """
  881. Test if it fetches a list of all configured IKEPolicies for a tenant
  882. """
  883. self.assertTrue(neutron.list_ikepolicies(profile="openstack1"))
  884. # 'show_ikepolicy' function tests: 1
  885. def test_show_ikepolicy(self):
  886. """
  887. Test if it fetches information of a specific IKEPolicy
  888. """
  889. self.assertTrue(neutron.show_ikepolicy("SALT", profile="openstack1"))
  890. # 'create_ikepolicy' function tests: 1
  891. def test_create_ikepolicy(self):
  892. """
  893. Test if it creates a new IKEPolicy
  894. """
  895. self.assertTrue(neutron.create_ikepolicy("SALTSTACK", profile="openstack1"))
  896. # 'delete_ikepolicy' function tests: 1
  897. def test_delete_ikepolicy(self):
  898. """
  899. Test if it deletes the specified IKEPolicy
  900. """
  901. self.assertTrue(neutron.delete_ikepolicy("SALT", profile="openstack1"))
  902. # 'list_ipsecpolicies' function tests: 1
  903. def test_list_ipsecpolicies(self):
  904. """
  905. Test if it fetches a list of all configured IPsecPolicies for a tenant
  906. """
  907. self.assertTrue(neutron.list_ipsecpolicies(profile="openstack1"))
  908. # 'show_ipsecpolicy' function tests: 1
  909. def test_show_ipsecpolicy(self):
  910. """
  911. Test if it fetches information of a specific IPsecPolicy
  912. """
  913. self.assertTrue(neutron.show_ipsecpolicy("SALT", profile="openstack1"))
  914. # 'create_ipsecpolicy' function tests: 1
  915. def test_create_ipsecpolicy(self):
  916. """
  917. Test if it creates a new IPsecPolicy
  918. """
  919. self.assertTrue(neutron.create_ipsecpolicy("SALTSTACK", profile="openstack1"))
  920. # 'delete_ipsecpolicy' function tests: 1
  921. def test_delete_ipsecpolicy(self):
  922. """
  923. Test if it deletes the specified IPsecPolicy
  924. """
  925. self.assertTrue(neutron.delete_ipsecpolicy("SALT", profile="openstack1"))