예제 #1
0
 def test_get_version_list_secure_proxy_ssl_header_https(self):
     self.config(secure_proxy_ssl_header='HTTP_X_FORWARDED_PROTO')
     environ = webob.request.environ_from_url('http://localhost:9292')
     environ['HTTP_X_FORWARDED_PROTO'] = "https"
     req = WsgiRequest(environ)
     res = versions.Controller().index(req)
     self.assertEqual(300, res.status_int)
     self.assertEqual('application/json', res.content_type)
     results = jsonutils.loads(res.body)['versions']
     expected = [
         {
             'id': 'v2.3',
             'status': 'CURRENT',
             'links': [{
                 'rel': 'self',
                 'href': 'https://localhost:9292/v2/'
             }],
         },
         {
             'id': 'v2.2',
             'status': 'SUPPORTED',
             'links': [{
                 'rel': 'self',
                 'href': 'https://localhost:9292/v2/'
             }],
         },
         {
             'id': 'v2.1',
             'status': 'SUPPORTED',
             'links': [{
                 'rel': 'self',
                 'href': 'https://localhost:9292/v2/'
             }],
         },
         {
             'id': 'v2.0',
             'status': 'SUPPORTED',
             'links': [{
                 'rel': 'self',
                 'href': 'https://localhost:9292/v2/'
             }],
         },
         {
             'id': 'v1.1',
             'status': 'DEPRECATED',
             'links': [{
                 'rel': 'self',
                 'href': 'https://localhost:9292/v1/'
             }],
         },
         {
             'id': 'v1.0',
             'status': 'DEPRECATED',
             'links': [{
                 'rel': 'self',
                 'href': 'https://localhost:9292/v1/'
             }],
         },
     ]
     self.assertEqual(expected, results)
예제 #2
0
 def test_get_version_list_secure_proxy_ssl_header(self):
     self.config(secure_proxy_ssl_header='HTTP_X_FORWARDED_PROTO')
     url = 'http://localhost:9292'
     environ = webob.request.environ_from_url(url)
     req = WsgiRequest(environ)
     res = versions.Controller().index(req)
     self.assertEqual(http.MULTIPLE_CHOICES, res.status_int)
     self.assertEqual('application/json', res.content_type)
     results = jsonutils.loads(res.body)['versions']
     expected = self._get_versions_list(url)
     self.assertEqual(expected, results)
예제 #3
0
    def test_get_version_list_secure_proxy_ssl_header_https(self):
        self.config(secure_proxy_ssl_header='HTTP_X_FORWARDED_PROTO')
        url = 'http://localhost:9292'
        ssl_url = 'https://localhost:9292'
        environ = webob.request.environ_from_url(url)
        environ['HTTP_X_FORWARDED_PROTO'] = "https"
        req = WsgiRequest(environ)
        res = versions.Controller().index(req)
        self.assertEqual(http.MULTIPLE_CHOICES, res.status_int)
        self.assertEqual('application/json', res.content_type)
        results = jsonutils.loads(res.body)['versions']
        expected = get_versions_list(ssl_url)
        self.assertEqual(expected, results)

        self.config(enabled_backends='slow:one,fast:two')
        res = versions.Controller().index(req)
        results = jsonutils.loads(res.body)['versions']
        expected = get_versions_list(ssl_url, enabled_backends=True)
        self.assertEqual(expected, results)