Keystone Admin: Creating a roleRef for a non existent user or role returns Internal Server Error

Bug #999608 reported by Rohit Karajgi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Low
Dolph Mathews

Bug Description

Our tempest tests call the create_role_ref() API and pass invalid parameters for userID / roleID / tenantID.

Expected Result: HTTP 404 Not Found or 400 Bad Request
Actual Result: HTTP 200 A roleRef is created

Eg:
rohit@osbox:~/opt/stack/tempest$ nosetests -v -s tempest.tests.identity.test_roles:RolesTest.test_create_user_role_for_non_existent_user

Attempt to assign a role to a non existent user should fail ...
RESP: {'date': 'Tue, 15 May 2012 10:42:10 GMT', 'content-type': 'application/json', 'content-length': '79', 'status': '200', 'vary': 'X-Auth-Token'}
BODY: {u'id': u'039579bfece54093b90862fb593880d5', u'name': u'role20458752500'}
ok

The response and body above show that the call is successful, whereas in this case the userID passed was invalid.
Similarly, the following tests also should return the appropriate errors:
test_create_user_role_for_non_existent_role
test_create_user_role_for_non_existent_tenant

Revision history for this message
Joseph Heck (heckj) wrote :

Awesome bug report, thank you!

Changed in keystone:
status: New → Triaged
importance: Undecided → Low
Dolph Mathews (dolph)
Changed in keystone:
assignee: nobody → Dolph Mathews (dolph)
Revision history for this message
Dolph Mathews (dolph) wrote :

This should be fixed by the patch already in review for bug 968519.

Revision history for this message
Dolph Mathews (dolph) wrote :

Hrm, I just noticed that the bug title cites a 500 Internal Server Error, but in the description you indicate an actual result of "200 OK". If you received a 500, then this probably isn't related to the bug cited above.

Changed in keystone:
status: Triaged → Incomplete
Revision history for this message
Rohit Karajgi (rohitk) wrote :

Dolph, I actually ran the test again, and did observe a ComputeFault.

This is what my test does:

1. Create a new tenant
2. Create a new user for the tenant in Step1.
3. Create a new role
4. Try to assign the role in Step3 to 'a_non_existent_user' for tenant from Step1.

Operation 4 returns a ComputeFault.

Attempt to assign a role to a non existent user should fail ... ERROR

======================================================================
ERROR: Attempt to assign a role to a non existent user should fail
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/opt/stack/tempest/tests/identity/test_roles.py", line 128, in test_assign_user_role_for_non_existent_user
    'junk-user-id-999', role['id'], tenant['id'])
  File "/usr/lib/pymodules/python2.7/unittest2/case.py", line 475, in assertRaises
    callableObj(*args, **kwargs)
  File "/opt/stack/tempest/services/identity/json/admin_client.py", line 74, in assign_user_role
    self.headers)
  File "/opt/stack/tempest/common/rest_client.py", line 152, in post
    return self.request('POST', url, headers, body)
  File "/opt/stack/tempest/common/rest_client.py", line 224, in request
    message = resp_body['computeFault']['message']
KeyError: '\'computeFault\'\n-------------------- >> begin captured logging << --------------------\ntempest.config: INFO: Using tempest config file /home/rohit/dev/community_tempest/etc/tempest.conf\ntempest.common.rest_client: ERROR: Request URL: http://10.2.3.164:35357/v2.0/users/junk-user-id-999/roleRefs\ntempest.common.rest_client: ERROR: Request Body: {"role": {"roleId": "9c3cb25b82f84b3a92f1a60d6ed29da6", "tenantId": "e09f60b4d6e948e2a59f228350e883f2"}}\ntempest.common.rest_client: ERROR: Response Headers: {\'date\': \'Wed, 30 May 2012 16:33:41 GMT\', \'content-type\': \'application/json\', \'content-length\': \'497\', \'status\': \'500\', \'vary\': \'X-Auth-Token\'}\ntempest.common.rest_client: ERROR: Response Body: {u\'error\': {u\'message\': u"An unexpected error prevented the server from fulfilling your request. (IntegrityError) (1452, \'Cannot add or update a child row: a foreign key constraint fails (`keystone`.`user_tenant_membership`, CONSTRAINT `user_tenant_membership_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `user` (`id`))\') \'INSERT INTO user_tenant_membership (user_id, tenant_id) VALUES (%s, %s)\' (\'junk-user-id-999\', \'e09f60b4d6e948e2a59f228350e883f2\')", u\'code\': 500, u\'title\': u\'Internal Server Error\'}}\n--------------------- >> end captured logging << ---------------------'

At this point I can confirm the above behavior, contrary to my bug description above, but complying with the summary.

Revision history for this message
Rohit Karajgi (rohitk) wrote :

I observed this on stable/essex btw.

Changed in keystone:
status: Incomplete → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/6875
Committed: http://github.com/openstack/keystone/commit/23ca656927947dada40591bdd1badd5a531c2983
Submitter: Jenkins
Branch: master

commit 23ca656927947dada40591bdd1badd5a531c2983
Author: Dolph Mathews <email address hidden>
Date: Wed Mar 28 10:37:16 2012 -0700

    Refactor 404's into managers & drivers (bug 968519)

    The goal is to move the responsibility of reference checks away from
    controllers and into the underlying managers & drivers, which can
    handle the task with equal or greater efficiency.

    - Tenant references from create_user/update_user are NOT tested
      due to inconsistencies between backends
    - Additional test coverage improvements

    Also fixes bug 999209, bug 999608, bug 1006029, bug 1006055, bug 1006287,
    bug 1006334, and bug 1006344.

    Change-Id: I7de592e7dd4518038436b9a9fdaab559b00a0537

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
milestone: none → folsom-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: folsom-2 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.