PUT /v1/containers/<id> returns http 406, should be http 405

Bug #1485157 reported by Steve Heyman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Barbican
Fix Released
Medium
Steve Heyman

Bug Description

PUT to the /v1/containers/<id> resource returns http 406, which is what pecan sends when it finds that content types aren't as it expects.

Return code should be 405 in this case ("method not allowed").

This happens because the generic ('index') handler in the Containers controller is missing the template='json' option on the pecan expose decorator. This index function is where we return the (expected) 405 error. Without the template='json' option, the index function isn't called because pecan isn't happy with the content type (which we pass in as application/json). Pecan default is 'text/html'. Adding the decorator allows the call to go through to the index function, and the expected 405 is returned.

To resolve this problem:

1) add template='json' to the pecan expose decorator on the index function in the Containers controller
2) update the functionaltests/api/v1/functional/test_containers_rbac.py file to set the expected return codes in test_data_rbac_update_container dict to 405 (was 406 which is why this testcase passed in the devstack gate).

Steve Heyman (sheyman)
Changed in barbican:
importance: Undecided → Medium
assignee: nobody → Steve Heyman (sheyman)
status: New → Confirmed
Changed in barbican:
status: Confirmed → In Progress
Steve Heyman (sheyman)
description: updated
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to barbican (master)

Reviewed: https://review.openstack.org/213402
Committed: https://git.openstack.org/cgit/openstack/barbican/commit/?id=663a2362bbe56912e9f7f0451fcb9a37e8c387e8
Submitter: Jenkins
Branch: master

commit 663a2362bbe56912e9f7f0451fcb9a37e8c387e8
Author: Steve Heyman <email address hidden>
Date: Fri Aug 14 21:13:31 2015 -0500

    Ensure a http 405 is returned on container(s) PUT

    Added the template='json' option to the pecan expose decorator on
    the index function on the Containers controller to ensure that we
    pass control to that function rather than have pecan determine
    that some content type(s) aren't what it expects.

    Without this fix, pecan looks at the content type (we set as
    application/json) and since its not "text/html" pecan returns an
    http 406 rather than passing control on to the index function which
    sets the more appropriate http 405.

    Closes-Bug #1485157

    Change-Id: I4ff640c7bd412b9946797d2da7be04fe78678c63

Changed in barbican:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in barbican:
milestone: none → liberty-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in barbican:
milestone: liberty-3 → 1.0.0
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.