How to use _delete_security_group_rule method in tempest

Best Python code snippet using tempest_python

test_security_groups.py

Source:test_security_groups.py Github

copy

Full Screen

...31 secgroup_list = list()32 for secgroup in list_body['security_groups']:33 secgroup_list.append(secgroup['id'])34 self.assertNotIn(secgroup_id, secgroup_list)35 def _delete_security_group_rule(self, rule_id):36 resp, _ = self.client.delete_security_group_rule(rule_id)37 self.assertEqual(204, resp.status)38 # Asserting that the security group is not found in the list39 # after deletion40 resp, list_body = self.client.list_security_group_rules()41 self.assertEqual('200', resp['status'])42 rules_list = list()43 for rule in list_body['security_group_rules']:44 rules_list.append(rule['id'])45 self.assertNotIn(rule_id, rules_list)46 @attr(type='smoke')47 def test_list_security_groups(self):48 # Verify the that security group belonging to tenant exist in list49 resp, body = self.client.list_security_groups()50 self.assertEqual('200', resp['status'])51 security_groups = body['security_groups']52 found = None53 for n in security_groups:54 if (n['name'] == 'default'):55 found = n['id']56 msg = "Security-group list doesn't contain default security-group"57 self.assertIsNotNone(found, msg)58 @attr(type='smoke')59 def test_create_show_delete_security_group(self):60 # Create a security group61 name = data_utils.rand_name('secgroup-')62 resp, group_create_body = self.client.create_security_group(name)63 self.assertEqual('201', resp['status'])64 self.addCleanup(self._delete_security_group,65 group_create_body['security_group']['id'])66 self.assertEqual(group_create_body['security_group']['name'], name)67 # Show details of the created security group68 resp, show_body = self.client.show_security_group(69 group_create_body['security_group']['id'])70 self.assertEqual('200', resp['status'])71 self.assertEqual(show_body['security_group']['name'], name)72 # List security groups and verify if created group is there in response73 resp, list_body = self.client.list_security_groups()74 self.assertEqual('200', resp['status'])75 secgroup_list = list()76 for secgroup in list_body['security_groups']:77 secgroup_list.append(secgroup['id'])78 self.assertIn(group_create_body['security_group']['id'], secgroup_list)79 @attr(type='smoke')80 def test_create_show_delete_security_group_rule(self):81 # Create a security group82 name = data_utils.rand_name('secgroup-')83 resp, group_create_body = self.client.create_security_group(name)84 self.assertEqual('201', resp['status'])85 self.addCleanup(self._delete_security_group,86 group_create_body['security_group']['id'])87 self.assertEqual(group_create_body['security_group']['name'], name)88 # Create rules for each protocol89 protocols = ['tcp', 'udp', 'icmp']90 for protocol in protocols:91 resp, rule_create_body = self.client.create_security_group_rule(92 group_create_body['security_group']['id'],93 protocol=protocol94 )...

Full Screen

Full Screen

base_security_groups.py

Source:base_security_groups.py Github

copy

Full Screen

...62 for key, value in kwargs.items():63 self.assertEqual(value,64 show_rule_body['security_group_rule'][key],65 "%s does not match." % key)66 def _delete_security_group_rule(self, secgroup_rule_id):67 self.client.delete_security_group_rule(secgroup_rule_id)68 rule_list_body = self.client.list_security_group_rules()69 rule_list = [rule['id']70 for rule in rule_list_body['security_group_rules']]71 self.assertNotIn(secgroup_rule_id, rule_list)72 def _test_create_show_delete_security_group_rule(self, **kwargs):73 # The security group rule is deleted by the cleanup call in74 # _create_security_group_rule.75 rule_create_body = (76 self._create_security_group_rule(**kwargs)['security_group_rule'])77 self._show_security_group_rule(78 id=rule_create_body['id'],79 protocol=rule_create_body['protocol'],80 direction=rule_create_body['direction'],...

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