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

« back to all changes in this revision

Viewing changes to .pc/security-fix-tenant-bypass.patch/nova/tests/api/openstack/v2/test_urlmap.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandleman
  • Date: 2012-01-13 09:51:10 UTC
  • mfrom: (1.1.40)
  • Revision ID: package-import@ubuntu.com-20120113095110-ffd6163drcg77wez
Tags: 2012.1~e3~20120113.12049-0ubuntu1
[Chuck Short]
* New upstream version.
* debian/nova_sudoers, debian/nova-common.install, 
  Switch out to nova-rootwrap. (LP: #681774)
* Add "get-origsource-git" which allows developers to 
  generate a tarball from github, by doing:
  fakeroot debian/rules get-orig-source-git
* debian/debian/nova-objectstore.logrotate: Dont determine
  if we are running Debian or Ubuntu. (LP: #91379)

[Adam Gandleman]
* Removed python-nova.postinst, let dh_python2 generate instead since
  python-support is not a dependency. (LP: #907543)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2011 OpenStack LLC.
2
 
# All Rights Reserved.
3
 
#
4
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
5
 
#    not use this file except in compliance with the License. You may obtain
6
 
#    a copy of the License at
7
 
#
8
 
#         http://www.apache.org/licenses/LICENSE-2.0
9
 
#
10
 
#    Unless required by applicable law or agreed to in writing, software
11
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
 
#    License for the specific language governing permissions and limitations
14
 
#    under the License.
15
 
 
16
 
import json
17
 
import webob
18
 
 
19
 
from nova import log as logging
20
 
from nova import test
21
 
from nova.tests.api.openstack import fakes
22
 
 
23
 
LOG = logging.getLogger('nova.tests.api.openstack.v2.test_urlmap')
24
 
 
25
 
 
26
 
class UrlmapTest(test.TestCase):
27
 
    def setUp(self):
28
 
        super(UrlmapTest, self).setUp()
29
 
        fakes.stub_out_rate_limiting(self.stubs)
30
 
 
31
 
    def test_path_version_v1_1(self):
32
 
        """Test URL path specifying v1.1 returns v2 content."""
33
 
        req = webob.Request.blank('/v1.1/')
34
 
        req.accept = "application/json"
35
 
        res = req.get_response(fakes.wsgi_app())
36
 
        self.assertEqual(res.status_int, 200)
37
 
        self.assertEqual(res.content_type, "application/json")
38
 
        body = json.loads(res.body)
39
 
        self.assertEqual(body['version']['id'], 'v2.0')
40
 
 
41
 
    def test_content_type_version_v1_1(self):
42
 
        """Test Content-Type specifying v1.1 returns v2 content."""
43
 
        req = webob.Request.blank('/')
44
 
        req.content_type = "application/json;version=1.1"
45
 
        req.accept = "application/json"
46
 
        res = req.get_response(fakes.wsgi_app())
47
 
        self.assertEqual(res.status_int, 200)
48
 
        self.assertEqual(res.content_type, "application/json")
49
 
        body = json.loads(res.body)
50
 
        self.assertEqual(body['version']['id'], 'v2.0')
51
 
 
52
 
    def test_accept_version_v1_1(self):
53
 
        """Test Accept header specifying v1.1 returns v2 content."""
54
 
        req = webob.Request.blank('/')
55
 
        req.accept = "application/json;version=1.1"
56
 
        res = req.get_response(fakes.wsgi_app())
57
 
        self.assertEqual(res.status_int, 200)
58
 
        self.assertEqual(res.content_type, "application/json")
59
 
        body = json.loads(res.body)
60
 
        self.assertEqual(body['version']['id'], 'v2.0')
61
 
 
62
 
    def test_path_version_v2(self):
63
 
        """Test URL path specifying v2 returns v2 content."""
64
 
        req = webob.Request.blank('/v2/')
65
 
        req.accept = "application/json"
66
 
        res = req.get_response(fakes.wsgi_app())
67
 
        self.assertEqual(res.status_int, 200)
68
 
        self.assertEqual(res.content_type, "application/json")
69
 
        body = json.loads(res.body)
70
 
        self.assertEqual(body['version']['id'], 'v2.0')
71
 
 
72
 
    def test_content_type_version_v2(self):
73
 
        """Test Content-Type specifying v2 returns v2 content."""
74
 
        req = webob.Request.blank('/')
75
 
        req.content_type = "application/json;version=2"
76
 
        req.accept = "application/json"
77
 
        res = req.get_response(fakes.wsgi_app())
78
 
        self.assertEqual(res.status_int, 200)
79
 
        self.assertEqual(res.content_type, "application/json")
80
 
        body = json.loads(res.body)
81
 
        self.assertEqual(body['version']['id'], 'v2.0')
82
 
 
83
 
    def test_accept_version_v2(self):
84
 
        """Test Accept header specifying v2 returns v2 content."""
85
 
        req = webob.Request.blank('/')
86
 
        req.accept = "application/json;version=2"
87
 
        res = req.get_response(fakes.wsgi_app())
88
 
        self.assertEqual(res.status_int, 200)
89
 
        self.assertEqual(res.content_type, "application/json")
90
 
        body = json.loads(res.body)
91
 
        self.assertEqual(body['version']['id'], 'v2.0')
92
 
 
93
 
    def test_path_content_type(self):
94
 
        """Test URL path specifying JSON returns JSON content."""
95
 
        url = '/v2/foobar/images/cedef40a-ed67-4d10-800e-17455edce175.json'
96
 
        req = webob.Request.blank(url)
97
 
        req.accept = "application/xml"
98
 
        res = req.get_response(fakes.wsgi_app())
99
 
        self.assertEqual(res.status_int, 200)
100
 
        self.assertEqual(res.content_type, "application/json")
101
 
        body = json.loads(res.body)
102
 
        self.assertEqual(body['image']['id'],
103
 
                         'cedef40a-ed67-4d10-800e-17455edce175')
104
 
 
105
 
    def test_accept_content_type(self):
106
 
        """Test Accept header specifying JSON returns JSON content."""
107
 
        url = '/v2/foobar/images/cedef40a-ed67-4d10-800e-17455edce175'
108
 
        req = webob.Request.blank(url)
109
 
        req.accept = "application/xml;q=0.8, application/json"
110
 
        res = req.get_response(fakes.wsgi_app())
111
 
        self.assertEqual(res.status_int, 200)
112
 
        self.assertEqual(res.content_type, "application/json")
113
 
        body = json.loads(res.body)
114
 
        self.assertEqual(body['image']['id'],
115
 
                         'cedef40a-ed67-4d10-800e-17455edce175')