test_backend_id_mapping_sql.py (keystone-19.0.0) | : | test_backend_id_mapping_sql.py (keystone-19.0.1) | ||
---|---|---|---|---|
skipping to change at line 35 | skipping to change at line 35 | |||
from keystone.tests.unit import test_backend_sql | from keystone.tests.unit import test_backend_sql | |||
PROVIDERS = provider_api.ProviderAPIs | PROVIDERS = provider_api.ProviderAPIs | |||
class SqlIDMappingTable(test_backend_sql.SqlModels): | class SqlIDMappingTable(test_backend_sql.SqlModels): | |||
"""Set of tests for checking SQL Identity ID Mapping.""" | """Set of tests for checking SQL Identity ID Mapping.""" | |||
def test_id_mapping(self): | def test_id_mapping(self): | |||
cols = (('public_id', sql.String, 64), | cols = (('public_id', sql.String, 64), | |||
('domain_id', sql.String, 64), | ('domain_id', sql.String, 64), | |||
('local_id', sql.String, 64), | ('local_id', sql.String, 255), | |||
('entity_type', sql.Enum, None)) | ('entity_type', sql.Enum, None)) | |||
self.assertExpectedSchema('id_mapping', cols) | self.assertExpectedSchema('id_mapping', cols) | |||
class SqlIDMapping(test_backend_sql.SqlTests): | class SqlIDMapping(test_backend_sql.SqlTests): | |||
def setUp(self): | def setUp(self): | |||
super(SqlIDMapping, self).setUp() | super(SqlIDMapping, self).setUp() | |||
self.load_sample_data() | self.load_sample_data() | |||
def load_sample_data(self): | def load_sample_data(self): | |||
skipping to change at line 170 | skipping to change at line 170 | |||
# Check no mappings for the new local entity | # Check no mappings for the new local entity | |||
self.assertIsNone(PROVIDERS.id_mapping_api.get_public_id(local_entity)) | self.assertIsNone(PROVIDERS.id_mapping_api.get_public_id(local_entity)) | |||
# Create the new mapping and then read it back | # Create the new mapping and then read it back | |||
public_id = PROVIDERS.id_mapping_api.create_id_mapping(local_entity) | public_id = PROVIDERS.id_mapping_api.create_id_mapping(local_entity) | |||
self.assertThat(mapping_sql.list_id_mappings(), | self.assertThat(mapping_sql.list_id_mappings(), | |||
matchers.HasLength(initial_mappings + 1)) | matchers.HasLength(initial_mappings + 1)) | |||
self.assertEqual( | self.assertEqual( | |||
public_id, PROVIDERS.id_mapping_api.get_public_id(local_entity)) | public_id, PROVIDERS.id_mapping_api.get_public_id(local_entity)) | |||
def test_id_mapping_handles_ids_greater_than_64_characters(self): | ||||
initial_mappings = len(mapping_sql.list_id_mappings()) | ||||
local_id = 'Aa' * 100 | ||||
local_entity = {'domain_id': self.domainA['id'], | ||||
'local_id': local_id, | ||||
'entity_type': mapping.EntityType.GROUP} | ||||
# Check no mappings for the new local entity | ||||
self.assertIsNone(PROVIDERS.id_mapping_api.get_public_id(local_entity)) | ||||
# Create the new mapping and then read it back | ||||
public_id = PROVIDERS.id_mapping_api.create_id_mapping(local_entity) | ||||
self.assertThat(mapping_sql.list_id_mappings(), | ||||
matchers.HasLength(initial_mappings + 1)) | ||||
self.assertEqual( | ||||
public_id, PROVIDERS.id_mapping_api.get_public_id(local_entity)) | ||||
self.assertEqual( | ||||
local_id, | ||||
PROVIDERS.id_mapping_api.get_id_mapping(public_id)['local_id']) | ||||
def test_delete_public_id_is_silent(self): | def test_delete_public_id_is_silent(self): | |||
# Test that deleting an invalid public key is silent | # Test that deleting an invalid public key is silent | |||
PROVIDERS.id_mapping_api.delete_id_mapping(uuid.uuid4().hex) | PROVIDERS.id_mapping_api.delete_id_mapping(uuid.uuid4().hex) | |||
def test_purge_mappings(self): | def test_purge_mappings(self): | |||
initial_mappings = len(mapping_sql.list_id_mappings()) | initial_mappings = len(mapping_sql.list_id_mappings()) | |||
local_id1 = uuid.uuid4().hex | local_id1 = uuid.uuid4().hex | |||
local_id2 = uuid.uuid4().hex | local_id2 = uuid.uuid4().hex | |||
local_id3 = uuid.uuid4().hex | local_id3 = uuid.uuid4().hex | |||
local_id4 = uuid.uuid4().hex | local_id4 = uuid.uuid4().hex | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 21 lines changed or added |