~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/api/test_sizelimit.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2012 OpenStack, LLC
 
2
#
 
3
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
4
#    not use this file except in compliance with the License. You may obtain
 
5
#    a copy of the License at
 
6
#
 
7
#         http://www.apache.org/licenses/LICENSE-2.0
 
8
#
 
9
#    Unless required by applicable law or agreed to in writing, software
 
10
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
11
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
12
#    License for the specific language governing permissions and limitations
 
13
#    under the License.
 
14
 
 
15
import webob
 
16
 
 
17
import nova.api.sizelimit
 
18
from nova import flags
 
19
from nova import test
 
20
 
 
21
FLAGS = flags.FLAGS
 
22
MAX_REQUEST_BODY_SIZE = FLAGS.osapi_max_request_body_size
 
23
 
 
24
 
 
25
class TestRequestBodySizeLimiter(test.TestCase):
 
26
 
 
27
    def setUp(self):
 
28
        super(TestRequestBodySizeLimiter, self).setUp()
 
29
 
 
30
        @webob.dec.wsgify()
 
31
        def fake_app(req):
 
32
            return webob.Response()
 
33
 
 
34
        self.middleware = nova.api.sizelimit.RequestBodySizeLimiter(fake_app)
 
35
        self.request = webob.Request.blank('/', method='POST')
 
36
 
 
37
    def test_content_length_acceptable(self):
 
38
        self.request.headers['Content-Length'] = MAX_REQUEST_BODY_SIZE
 
39
        self.request.body = "0" * MAX_REQUEST_BODY_SIZE
 
40
        response = self.request.get_response(self.middleware)
 
41
        self.assertEqual(response.status_int, 200)
 
42
 
 
43
    def test_content_length_to_large(self):
 
44
        self.request.headers['Content-Length'] = MAX_REQUEST_BODY_SIZE + 1
 
45
        response = self.request.get_response(self.middleware)
 
46
        self.assertEqual(response.status_int, 400)
 
47
 
 
48
    def test_request_to_large(self):
 
49
        self.request.body = "0" * (MAX_REQUEST_BODY_SIZE + 1)
 
50
        response = self.request.get_response(self.middleware)
 
51
        self.assertEqual(response.status_int, 400)