~ubuntu-branches/ubuntu/trusty/heat/trusty-security

« back to all changes in this revision

Viewing changes to heat/tests/test_wsgi.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2013-10-03 09:43:04 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20131003094304-k2c4qcsfn7cv6eos
Tags: 2013.2~rc1-0ubuntu1
* New upstream release.
* debian/control: Dropped python-d2to1 build dependency.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
2
 
3
 
# Copyright 2010-2011 OpenStack, LLC
 
3
# Copyright 2010-2011 OpenStack Foundation
4
4
# All Rights Reserved.
5
5
#
6
6
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
17
17
 
18
18
 
19
19
import datetime
 
20
import json
 
21
from oslo.config import cfg
20
22
import stubout
21
23
import webob
22
24
 
221
223
        try:
222
224
            resource(request)
223
225
        except exception.HTTPExceptionDisguise as e:
224
 
            self.assertEquals(message_es, e.exc.message)
 
226
            self.assertEqual(message_es, e.exc.message)
225
227
        self.m.VerifyAll()
226
228
 
227
229
 
380
382
        actual = wsgi.JSONRequestDeserializer().default(request)
381
383
        expected = {"body": {"key": "value"}}
382
384
        self.assertEqual(actual, expected)
 
385
 
 
386
    def test_from_json_exceeds_max_json_mb(self):
 
387
        cfg.CONF.set_override('max_json_body_size', 10)
 
388
        body = json.dumps(['a'] * cfg.CONF.max_json_body_size)
 
389
        self.assertTrue(len(body) > cfg.CONF.max_json_body_size)
 
390
        error = self.assertRaises(exception.RequestLimitExceeded,
 
391
                                  wsgi.JSONRequestDeserializer().from_json,
 
392
                                  body)
 
393
        msg = 'Request limit exceeded: JSON body size ' + \
 
394
              '(%s bytes) exceeds maximum allowed size (%s bytes).' % \
 
395
              (len(body), cfg.CONF.max_json_body_size)
 
396
        self.assertEqual(msg, str(error))