diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-07-24 11:27:59 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-07-24 11:27:59 -0600 |
commit | 3d6ec1eeaf70ae4e46042946f8bd35d5b5380401 (patch) | |
tree | 9d2881a2f73de6e779d266ceb6798ec3930d42ea /snaps/openstack/tests/create_security_group_tests.py | |
parent | feae63d11f8295a0d9327496f42949ad5b67fca4 (diff) |
Fixed problems when setting the OpenStack project ID.
There were several calls to retrieve the project ID that required
named parameters which was causing the utility function to always
return None. Additionally, when creating the dict() required by the
Neutron create API 'body' parameter key 'project_id' is not supported
and still uses 'tenant_id'.
As these problems should have been found earlier, this patch also
extends the tests for networks, subnets, ports, and security groups
to use 'tenant_id' rather than 'project_id'.
JIRA: SNAPS-143
Change-Id: Ic69e56145ea6070718d821edd22a1d0f9970995d
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/tests/create_security_group_tests.py')
-rw-r--r-- | snaps/openstack/tests/create_security_group_tests.py | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/snaps/openstack/tests/create_security_group_tests.py b/snaps/openstack/tests/create_security_group_tests.py index dd28d7d..7cae62b 100644 --- a/snaps/openstack/tests/create_security_group_tests.py +++ b/snaps/openstack/tests/create_security_group_tests.py @@ -16,12 +16,9 @@ import unittest import uuid from snaps.openstack import create_security_group -from snaps.openstack.create_security_group import (SecurityGroupSettings, - SecurityGroupRuleSettings, - Direction, Ethertype, - Protocol, - SecurityGroupRuleSettingsError, - SecurityGroupSettingsError) +from snaps.openstack.create_security_group import ( + SecurityGroupSettings, SecurityGroupRuleSettings, Direction, Ethertype, + Protocol, SecurityGroupRuleSettingsError, SecurityGroupSettingsError) from snaps.openstack.tests import validation_utils from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase from snaps.openstack.utils import neutron_utils @@ -212,6 +209,54 @@ class CreateSecurityGroupTests(OSIntegrationTestCase): validation_utils.objects_equivalent(self.sec_grp_creator.get_rules(), rules) + def test_create_group_admin_user_to_new_project(self): + """ + Tests the creation of an OpenStack Security Group without custom rules. + """ + # Create Image + sec_grp_settings = SecurityGroupSettings( + name=self.sec_grp_name, description='hello group', + project_name=self.admin_os_creds.project_name) + self.sec_grp_creator = create_security_group.OpenStackSecurityGroup( + self.os_creds, sec_grp_settings) + self.sec_grp_creator.create() + + sec_grp = neutron_utils.get_security_group(self.neutron, + self.sec_grp_name) + self.assertIsNotNone(sec_grp) + + validation_utils.objects_equivalent( + self.sec_grp_creator.get_security_group(), sec_grp) + rules = neutron_utils.get_rules_by_security_group( + self.neutron, self.sec_grp_creator.get_security_group()) + self.assertEqual(len(self.sec_grp_creator.get_rules()), len(rules)) + validation_utils.objects_equivalent(self.sec_grp_creator.get_rules(), + rules) + + def test_create_group_new_user_to_admin_project(self): + """ + Tests the creation of an OpenStack Security Group without custom rules. + """ + # Create Image + sec_grp_settings = SecurityGroupSettings( + name=self.sec_grp_name, description='hello group', + project_name=self.os_creds.project_name) + self.sec_grp_creator = create_security_group.OpenStackSecurityGroup( + self.admin_os_creds, sec_grp_settings) + self.sec_grp_creator.create() + + sec_grp = neutron_utils.get_security_group(self.neutron, + self.sec_grp_name) + self.assertIsNotNone(sec_grp) + + validation_utils.objects_equivalent( + self.sec_grp_creator.get_security_group(), sec_grp) + rules = neutron_utils.get_rules_by_security_group( + self.neutron, self.sec_grp_creator.get_security_group()) + self.assertEqual(len(self.sec_grp_creator.get_rules()), len(rules)) + validation_utils.objects_equivalent(self.sec_grp_creator.get_rules(), + rules) + def test_create_delete_group(self): """ Tests the creation of an OpenStack Security Group without custom rules. |