Allow identity provider to be created with remote_ids set to None

When support was added for multiple remote_ids, identity provider
creation was broken when remote_ids are specified as None instead
of an empty list.  The remote_ids are supposed to be optional.  This
causes 400 errors when using python-openstackclient to create an
identity provider without any remote_ids.

Change-Id: I9a4d1206f6df95636ae350236f6e704ca37f7b73
Closes-bug: #1440185
This commit is contained in:
Nathan Kinder 2015-04-03 12:53:01 -07:00
parent eb1b4381a8
commit 384c3f9100
2 changed files with 18 additions and 1 deletions

View File

@ -58,7 +58,9 @@ class IdentityProviderModel(sql.ModelBase, sql.DictBase):
@classmethod
def from_dict(cls, dictionary):
new_dictionary = dictionary.copy()
remote_ids_list = new_dictionary.pop('remote_ids', [])
remote_ids_list = new_dictionary.pop('remote_ids', None)
if not remote_ids_list:
remote_ids_list = []
identity_provider = cls(**new_dictionary)
remote_ids = []
# NOTE(fmarco76): the remote_ids_list contains only remote ids

View File

@ -856,6 +856,21 @@ class FederatedIdentityProviderTests(FederationTests):
keys_to_check=keys_to_check,
ref=body)
def test_create_idp_remote_none(self):
"""Creates an IdP with a None remote_ids."""
keys_to_check = list(self.idp_keys)
keys_to_check.append('remote_ids')
body = self.default_body.copy()
body['description'] = uuid.uuid4().hex
body['remote_ids'] = None
resp = self._create_default_idp(body=body)
expected = body.copy()
expected['remote_ids'] = []
self.assertValidResponse(resp, 'identity_provider', dummy_validator,
keys_to_check=keys_to_check,
ref=expected)
def test_update_idp_remote_ids(self):
"""Update IdP's remote_ids parameter."""
body = self.default_body.copy()