Expose a bug when create trust with roles

The test here should pass with 400 Bad Request because
that there is no valid roles in the request body.
But Keystone raise 500 error because that it doesn't
check the roles key.

Partial-Bug: #1734244
Change-Id: Ic007c8f83717aa69ecb831d460a3829d3f8f1a6d
This commit is contained in:
wangxiyuan 2017-11-24 12:31:19 +08:00 committed by Colleen Murphy
parent 8401eb83f9
commit 62f9e57cd8
1 changed files with 15 additions and 0 deletions

View File

@ -19,6 +19,7 @@ import keystone.conf
from keystone import exception
from keystone.tests import unit
from keystone.tests.unit import test_v3
from keystone.tests.unit import utils as test_utils
CONF = keystone.conf.CONF
@ -296,6 +297,20 @@ class TestTrustOperations(test_v3.RestfulTestCase):
self.post('/OS-TRUST/trusts', body={'trust': ref},
expected_status=http_client.NOT_FOUND)
@test_utils.wip('Waiting on validation to be added from fixing bug'
'1734244')
def test_create_trust_with_extra_attributes_fails(self):
ref = unit.new_trust_ref(trustor_user_id=self.user_id,
trustee_user_id=self.trustee_user_id,
project_id=self.project_id,
role_ids=[self.role_id])
ref['roles'].append({'fake_key': 'fake_value'})
# Should return 400 Bad Request because `fake_key` is an extra
# attribute that keystone doesn't associate with trusts.
self.post('/OS-TRUST/trusts', body={'trust': ref},
expected_status=http_client.BAD_REQUEST)
def test_create_trust_with_non_existant_role_name_returns_not_found(self):
ref = unit.new_trust_ref(
trustor_user_id=self.user_id,