Skip to content

Commit

Permalink
WSGI: added the control for non empty X-PROJECT-ID
Browse files Browse the repository at this point in the history
Closes-bug: #1228249

Change-Id: I6fbf0344fd45f9581a28a55ef852139b32e93ed7
  • Loading branch information
razorinc committed Sep 27, 2013
1 parent e8e3bae commit c5d62ed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions marconi/queues/transport/wsgi/driver.py
Expand Up @@ -52,6 +52,11 @@ def _check_media_type(req, resp, params):

def _extract_project_id(req, resp, params):
params['project_id'] = req.get_header('X-PROJECT-ID')
if params['project_id'] == "":
raise falcon.HTTPBadRequest('Empty project header not allowed',
_(u'''
X-PROJECT-ID cannot be an empty string. Specify the right header X-PROJECT-ID
and retry.'''))


class Driver(transport.DriverBase):
Expand Down
17 changes: 16 additions & 1 deletion tests/unit/queues/transport/wsgi/test_queue_lifecycle.py
Expand Up @@ -36,7 +36,22 @@ def setUp(self):
self.wsgi_cfg = config.namespace(
'drivers:transport:wsgi').from_options()

@ddt.data('480924', 'foo', '', None)
def test_empty_project_id(self):
path = '/v1/queues/gumshoe'

self.simulate_get(path, '')
self.assertEquals(self.srmock.status, falcon.HTTP_400)

self.simulate_put(path, '')
self.assertEquals(self.srmock.status, falcon.HTTP_400)

self.simulate_head(path, '')
self.assertEquals(self.srmock.status, falcon.HTTP_400)

self.simulate_delete(path, '')
self.assertEquals(self.srmock.status, falcon.HTTP_400)

@ddt.data('480924', 'foo', None)
def test_basics_thoroughly(self, project_id):
path = '/v1/queues/gumshoe'

Expand Down

0 comments on commit c5d62ed

Please sign in to comment.