Best Python code snippet using tempest_python
test_security_group_default_rules.py
Source:test_security_group_default_rules.py
...35 def _create_security_group_default_rules(self, ip_protocol='tcp',36 from_port=22, to_port=22,37 cidr='10.10.0.0/24'):38 # Create Security Group default rule39 rule = self.adm_client.create_security_default_group_rule(40 ip_protocol=ip_protocol,41 from_port=from_port,42 to_port=to_port,43 cidr=cidr)['security_group_default_rule']44 self.assertEqual(ip_protocol, rule['ip_protocol'])45 self.assertEqual(from_port, rule['from_port'])46 self.assertEqual(to_port, rule['to_port'])47 self.assertEqual(cidr, rule['ip_range']['cidr'])48 return rule49 @test.idempotent_id('6d880615-eec3-4d29-97c5-7a074dde239d')50 def test_create_delete_security_group_default_rules(self):51 # Create and delete Security Group default rule52 ip_protocols = ['tcp', 'udp', 'icmp']53 for ip_protocol in ip_protocols:54 rule = self._create_security_group_default_rules(ip_protocol)55 # Delete Security Group default rule56 self.adm_client.delete_security_group_default_rule(rule['id'])57 self.assertRaises(lib_exc.NotFound,58 self.adm_client.show_security_group_default_rule,59 rule['id'])60 @test.idempotent_id('4d752e0a-33a1-4c3a-b498-ff8667ca22e5')61 def test_create_security_group_default_rule_without_cidr(self):62 ip_protocol = 'udp'63 from_port = 8064 to_port = 8065 rule = self.adm_client.create_security_default_group_rule(66 ip_protocol=ip_protocol,67 from_port=from_port,68 to_port=to_port)['security_group_default_rule']69 self.addCleanup(self.adm_client.delete_security_group_default_rule,70 rule['id'])71 self.assertNotEqual(0, rule['id'])72 self.assertEqual('0.0.0.0/0', rule['ip_range']['cidr'])73 @test.idempotent_id('29f2d218-69b0-4a95-8f3d-6bd0ef732b3a')74 def test_create_security_group_default_rule_with_blank_cidr(self):75 ip_protocol = 'icmp'76 from_port = 1077 to_port = 1078 cidr = ''79 rule = self.adm_client.create_security_default_group_rule(80 ip_protocol=ip_protocol,81 from_port=from_port,82 to_port=to_port,83 cidr=cidr)['security_group_default_rule']84 self.addCleanup(self.adm_client.delete_security_group_default_rule,85 rule['id'])86 self.assertNotEqual(0, rule['id'])87 self.assertEqual('0.0.0.0/0', rule['ip_range']['cidr'])88 @test.idempotent_id('6e6de55e-9146-4ae0-89f2-3569586e0b9b')89 def test_security_group_default_rules_list(self):90 ip_protocol = 'tcp'91 from_port = 2292 to_port = 2293 cidr = '10.10.0.0/24'...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!