How to use requires_ext method in tempest

Best Python code snippet using tempest_python

test_extension_driver_port_security.py

Source:test_extension_driver_port_security.py Github

copy

Full Screen

...23class PortSecTest(base_security.BaseSecGroupTest,24 base.BaseNetworkTest):25 @test.attr(type='smoke')26 @test.idempotent_id('7c338ddf-e64e-4118-bd33-e49a1f2f1495')27 @test.requires_ext(extension='port-security', service='network')28 def test_port_sec_default_value(self):29 # Default port-sec value is True, and the attr of the port will inherit30 # from the port-sec of the network when it not be specified in API31 network = self.create_network()32 self.assertTrue(network['port_security_enabled'])33 self.create_subnet(network)34 port = self.create_port(network)35 self.assertTrue(port['port_security_enabled'])36 @test.attr(type='smoke')37 @test.idempotent_id('e60eafd2-31de-4c38-8106-55447d033b57')38 @test.requires_ext(extension='port-security', service='network')39 @ddt.unpack40 @ddt.data({'port_sec_net': False, 'port_sec_port': True, 'expected': True},41 {'port_sec_net': True, 'port_sec_port': False,42 'expected': False})43 def test_port_sec_specific_value(self, port_sec_net, port_sec_port,44 expected):45 network = self.create_network(port_security_enabled=port_sec_net)46 self.create_subnet(network)47 port = self.create_port(network, port_security_enabled=port_sec_port)48 self.assertEqual(network['port_security_enabled'], port_sec_net)49 self.assertEqual(port['port_security_enabled'], expected)50 @test.attr(type=['smoke'])51 @test.idempotent_id('05642059-1bfc-4581-9bc9-aaa5db08dd60')52 @test.requires_ext(extension='port-security', service='network')53 def test_create_port_sec_with_security_group(self):54 network = self.create_network(port_security_enabled=True)55 self.create_subnet(network)56 port = self.create_port(network, security_groups=[])57 self.assertTrue(port['port_security_enabled'])58 self.client.delete_port(port['id'])59 port = self.create_port(network, security_groups=[],60 port_security_enabled=False)61 self.assertFalse(port['port_security_enabled'])62 self.assertEmpty(port['security_groups'])63 @test.attr(type=['negative', 'smoke'])64 @test.idempotent_id('05642059-1bfc-4581-9bc9-aaa5db08dd60')65 @test.requires_ext(extension='port-security', service='network')66 def test_port_sec_update_port_failed(self):67 network = self.create_network()68 self.create_subnet(network)69 sec_group_body, sec_group_name = self._create_security_group()70 port = self.create_port(network)71 # Exception when set port-sec to False with sec-group defined72 self.assertRaises(lib_exc.Conflict, self.update_port, port,73 port_security_enabled=False)74 port = self.update_port(port, security_groups=[],75 port_security_enabled=False)76 self.assertEmpty(port['security_groups'])77 self.assertFalse(port['port_security_enabled'])78 port = self.update_port(79 port, security_groups=[sec_group_body['security_group']['id']],80 port_security_enabled=True)81 self.assertNotEmpty(port['security_groups'])82 self.assertTrue(port['port_security_enabled'])83 # Remove security group from port before deletion on resource_cleanup84 self.update_port(port, security_groups=[])85 @test.attr(type=['smoke'])86 @test.idempotent_id('05642059-1bfc-4581-9bc9-aaa5db08dd60')87 @test.requires_ext(extension='port-security', service='network')88 def test_port_sec_update_pass(self):89 network = self.create_network()90 self.create_subnet(network)91 sec_group, _ = self._create_security_group()92 sec_group_id = sec_group['security_group']['id']93 port = self.create_port(network, security_groups=[sec_group_id],94 port_security_enabled=True)95 self.assertNotEmpty(port['security_groups'])96 self.assertTrue(port['port_security_enabled'])97 port = self.update_port(port, security_groups=[])98 self.assertEmpty(port['security_groups'])99 self.assertTrue(port['port_security_enabled'])100 port = self.update_port(port, security_groups=[sec_group_id])101 self.assertNotEmpty(port['security_groups'])102 port = self.update_port(port, security_groups=[],103 port_security_enabled=False)104 self.assertEmpty(port['security_groups'])105 self.assertFalse(port['port_security_enabled'])106 @test.attr(type=['smoke'])107 @test.idempotent_id('2df6114b-b8c3-48a1-96e8-47f08159d35c')108 @test.requires_ext(extension='port-security', service='network')109 def test_delete_with_port_sec(self):110 network = self.create_network(port_security_enabled=True)111 port = self.create_port(network=network,112 port_security_enabled=True)113 self.client.delete_port(port['id'])114 self.assertTrue(self.client.is_resource_deleted('port', port['id']))115 self.client.delete_network(network['id'])116 self.assertTrue(117 self.client.is_resource_deleted('network', network['id']))118 @test.attr(type=['negative', 'smoke'])119 @test.idempotent_id('ed93e453-3f8d-495e-8e7e-b0e268c2ebd9')120 @test.requires_ext(extension='port-security', service='network')121 @test.requires_ext(extension='allowed-address-pairs', service='network')122 def test_allow_address_pairs(self):123 network = self.create_network()124 self.create_subnet(network)125 port = self.create_port(network=network, port_security_enabled=False)126 allowed_address_pairs = [{'ip_address': FAKE_IP,127 'mac_address': FAKE_MAC}]128 # Exception when set address-pairs with port-sec is False129 self.assertRaises(lib_exc.Conflict,130 self.update_port, port,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful