diff options
author | Nachiappan VR N <nachiappan.veerappan-nachiappan@hp.com> | 2013-07-22 15:50:33 -0700 |
---|---|---|
committer | Nachiappan VR N <nachiappan.veerappan-nachiappan@hp.com> | 2013-07-23 13:59:19 -0700 |
commit | 0a401529947c98ab761256e233b157071a57ab70 (patch) | |
tree | 54a102dfe0acb2feef90e08e40900ee96f246485 /tests | |
parent | c6b7dd8959f96e4b5bf282860245603ff94b0084 (diff) | |
download | keystone-0a401529947c98ab761256e233b157071a57ab70.tar.gz keystone-0a401529947c98ab761256e233b157071a57ab70.tar.xz keystone-0a401529947c98ab761256e233b157071a57ab70.zip |
Fixing broken credential schema in sqlite.
Credential table has foreign key constraint
referring to tenant table which is dropped.
Since sqlite does not support alter table
drop constraint, the foreign key constraint
was not dropped. When we try to load credential
table using sqlite backend it fails because tenant
table does not exist. Fix is provided such that
the credential table is recreated without foreign
key constraint and the data is moved from old
credential table to the new credential table.
Fixes Bug #1190383
Change-Id: I3afb04254f33e12fccb7da84c8674feba36622c8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_sql_upgrade.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_sql_upgrade.py b/tests/test_sql_upgrade.py index 64bf53c8..ed00deae 100644 --- a/tests/test_sql_upgrade.py +++ b/tests/test_sql_upgrade.py @@ -1122,6 +1122,46 @@ class SqlUpgradeTests(test.TestCase): self.assertEqual(len(data['roles']), 1) self.assertIn(role_list[5]['id'], data['roles']) + def test_drop_credential_constraint(self): + ec2_credential = { + 'id': '100', + 'user_id': 'foo', + 'project_id': 'bar', + 'type': 'ec2', + 'blob': json.dumps({ + "access": "12345", + "secret": "12345" + }) + } + user = { + 'id': 'foo', + 'name': 'FOO', + 'password': 'foo2', + 'enabled': True, + 'email': 'foo@bar.com', + 'extra': json.dumps({'enabled': True}) + } + tenant = { + 'id': 'bar', + 'name': 'BAR', + 'description': 'description', + 'enabled': True, + 'extra': json.dumps({'enabled': True}) + } + session = self.Session() + self.upgrade(7) + self.insert_dict(session, 'user', user) + self.insert_dict(session, 'tenant', tenant) + self.insert_dict(session, 'credential', ec2_credential) + session.commit() + self.upgrade(30) + cred_table = sqlalchemy.Table('credential', + self.metadata, + autoload=True) + cred = session.query(cred_table).filter("id='100'").one() + self.assertEqual(cred.user_id, + ec2_credential['user_id']) + def populate_user_table(self, with_pass_enab=False, with_pass_enab_domain=False): # Populate the appropriate fields in the user |