Remove the v3 to v2 resource test case

With the v2.0 resource API removal in Queens, these tests are no longer
required.

bp removed-as-of-queens

Change-Id: Ie84d1b2e54281f512ebffe8372dd56a77b34af13
This commit is contained in:
Gage Hugo 2017-10-04 10:44:15 -05:00
parent 78eae3d497
commit 09b828d860
1 changed files with 0 additions and 137 deletions

View File

@ -16,7 +16,6 @@ from six.moves import http_client
from six.moves import range
from testtools import matchers
from keystone.common import controller
import keystone.conf
from keystone.credential.providers import fernet as credential_fernet
from keystone import exception
@ -1284,139 +1283,3 @@ class ResourceTestCase(test_v3.RestfulTestCase,
'/projects/%(project_id)s' % {
'project_id': projects[0]['project']['id']},
expected_status=http_client.FORBIDDEN)
class ResourceV3toV2MethodsTestCase(unit.TestCase):
"""Test domain V3 to V2 conversion methods."""
def _setup_initial_projects(self):
self.project_id = uuid.uuid4().hex
self.domain_id = CONF.identity.default_domain_id
self.parent_id = uuid.uuid4().hex
# Project with only domain_id in ref
self.project1 = unit.new_project_ref(id=self.project_id,
name=self.project_id,
domain_id=self.domain_id)
# Project with both domain_id and parent_id in ref
self.project2 = unit.new_project_ref(id=self.project_id,
name=self.project_id,
domain_id=self.domain_id,
parent_id=self.parent_id)
# Project with no domain_id and parent_id in ref
self.project3 = unit.new_project_ref(id=self.project_id,
name=self.project_id,
domain_id=self.domain_id,
parent_id=self.parent_id)
# Expected result with no domain_id and parent_id
self.expected_project = {'id': self.project_id,
'name': self.project_id}
def test_v2controller_filter_domain_id(self):
# V2.0 is not domain aware, ensure domain_id is popped off the ref.
other_data = uuid.uuid4().hex
domain_id = CONF.identity.default_domain_id
ref = {'domain_id': domain_id,
'other_data': other_data}
ref_no_domain = {'other_data': other_data}
expected_ref = ref_no_domain.copy()
updated_ref = controller.V2Controller.filter_domain_id(ref)
self.assertIs(ref, updated_ref)
self.assertDictEqual(expected_ref, ref)
# Make sure we don't error/muck up data if domain_id isn't present
updated_ref = controller.V2Controller.filter_domain_id(ref_no_domain)
self.assertIs(ref_no_domain, updated_ref)
self.assertDictEqual(expected_ref, ref_no_domain)
def test_v3controller_filter_domain_id(self):
# No data should be filtered out in this case.
other_data = uuid.uuid4().hex
domain_id = uuid.uuid4().hex
ref = {'domain_id': domain_id,
'other_data': other_data}
expected_ref = ref.copy()
updated_ref = controller.V3Controller.filter_domain_id(ref)
self.assertIs(ref, updated_ref)
self.assertDictEqual(expected_ref, ref)
def test_v2controller_filter_domain(self):
other_data = uuid.uuid4().hex
domain_id = uuid.uuid4().hex
non_default_domain_ref = {'domain': {'id': domain_id},
'other_data': other_data}
default_domain_ref = {'domain': {'id': 'default'},
'other_data': other_data}
updated_ref = controller.V2Controller.filter_domain(default_domain_ref)
self.assertNotIn('domain', updated_ref)
self.assertNotIn(
'domain',
controller.V2Controller.filter_domain(non_default_domain_ref))
def test_v2controller_filter_project_parent_id(self):
# V2.0 is not project hierarchy aware, ensure parent_id is popped off.
other_data = uuid.uuid4().hex
parent_id = uuid.uuid4().hex
ref = {'parent_id': parent_id,
'other_data': other_data}
ref_no_parent = {'other_data': other_data}
expected_ref = ref_no_parent.copy()
updated_ref = controller.V2Controller.filter_project_parent_id(ref)
self.assertIs(ref, updated_ref)
self.assertDictEqual(expected_ref, ref)
# Make sure we don't error/muck up data if parent_id isn't present
updated_ref = controller.V2Controller.filter_project_parent_id(
ref_no_parent)
self.assertIs(ref_no_parent, updated_ref)
self.assertDictEqual(expected_ref, ref_no_parent)
def test_v3_to_v2_project_method(self):
self._setup_initial_projects()
# TODO(shaleh): these optional fields are not handled well by the
# v3_to_v2 code. Manually remove them for now. Eventually update
# new_project_ref to not return optional values
del self.project1['enabled']
del self.project1['description']
del self.project2['enabled']
del self.project2['description']
del self.project3['enabled']
del self.project3['description']
updated_project1 = controller.V2Controller.v3_to_v2_project(
self.project1)
self.assertIs(self.project1, updated_project1)
self.assertDictEqual(self.expected_project, self.project1)
updated_project2 = controller.V2Controller.v3_to_v2_project(
self.project2)
self.assertIs(self.project2, updated_project2)
self.assertDictEqual(self.expected_project, self.project2)
updated_project3 = controller.V2Controller.v3_to_v2_project(
self.project3)
self.assertIs(self.project3, updated_project3)
self.assertDictEqual(self.expected_project, self.project2)
def test_v3_to_v2_project_method_list(self):
self._setup_initial_projects()
project_list = [self.project1, self.project2, self.project3]
# TODO(shaleh): these optional fields are not handled well by the
# v3_to_v2 code. Manually remove them for now. Eventually update
# new_project_ref to not return optional values
for p in project_list:
del p['enabled']
del p['description']
updated_list = controller.V2Controller.v3_to_v2_project(project_list)
self.assertEqual(len(updated_list), len(project_list))
for i, ref in enumerate(updated_list):
# Order should not change.
self.assertIs(ref, project_list[i])
self.assertDictEqual(self.expected_project, self.project1)
self.assertDictEqual(self.expected_project, self.project2)
self.assertDictEqual(self.expected_project, self.project3)