Example #1
0
 def test_discover_extensions_v2(self):
     self.requests.get("%s/extensions" % V2_URL, text=EXTENSION_LIST)
     extensions = client.Client().discover_extensions(url=V2_URL)
     self.assertIn(EXTENSION_ALIAS_FOO, extensions)
     self.assertEqual(extensions[EXTENSION_ALIAS_FOO], EXTENSION_NAME_FOO)
     self.assertIn(EXTENSION_ALIAS_BAR, extensions)
     self.assertEqual(extensions[EXTENSION_ALIAS_BAR], EXTENSION_NAME_BAR)
Example #2
0
 def test_discover_extensions_v2(self):
     httpretty.register_uri(httpretty.GET,
                            "%s/extensions" % V2_URL,
                            body=EXTENSION_LIST)
     extensions = client.Client().discover_extensions(url=V2_URL)
     self.assertIn(EXTENSION_ALIAS_FOO, extensions)
     self.assertEqual(extensions[EXTENSION_ALIAS_FOO], EXTENSION_NAME_FOO)
     self.assertIn(EXTENSION_ALIAS_BAR, extensions)
     self.assertEqual(extensions[EXTENSION_ALIAS_BAR], EXTENSION_NAME_BAR)
Example #3
0
 def test_discover_extensions_v2(self):
     self.requests_mock.get("%s/extensions" % V2_URL, text=EXTENSION_LIST)
     # Creating a HTTPClient not using session is deprecated.
     with self.deprecations.expect_deprecations_here():
         extensions = client.Client().discover_extensions(url=V2_URL)
     self.assertIn(EXTENSION_ALIAS_FOO, extensions)
     self.assertEqual(extensions[EXTENSION_ALIAS_FOO], EXTENSION_NAME_FOO)
     self.assertIn(EXTENSION_ALIAS_BAR, extensions)
     self.assertEqual(extensions[EXTENSION_ALIAS_BAR], EXTENSION_NAME_BAR)
Example #4
0
    def test_get_version_local(self):
        self.stub_url(httpretty.GET,
                      base_url="http://localhost:35357/",
                      json=self.TEST_RESPONSE_DICT)

        cs = client.Client()
        versions = cs.discover()
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v2.0', versions)
        self.assertEqual(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
Example #5
0
    def test_get_versions(self):
        self.stub_url('GET',
                      base_url=self.TEST_ROOT_URL,
                      json=self.TEST_RESPONSE_DICT)

        cs = client.Client()
        versions = cs.discover(self.TEST_ROOT_URL)
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v2.0', versions)
        self.assertEqual(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
Example #6
0
    def test_get_version_local(self):
        self.stub_url('GET',
                      base_url="http://localhost:35357/",
                      json=self.TEST_RESPONSE_DICT)

        # Creating a HTTPClient not using session is deprecated.
        with self.deprecations.expect_deprecations_here():
            cs = client.Client()
        versions = cs.discover()
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v2.0', versions)
        self.assertEqual(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
    def test_get_version_local(self):
        self.requests.get("http://localhost:35357/",
                          status_code=300,
                          json=self.TEST_RESPONSE_DICT)

        cs = client.Client()
        versions = cs.discover()
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v3.0', versions)
        self.assertEqual(
            versions['v3.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
        self.assertEqual(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][1]['links'][0]['href'])
Example #8
0
    def test_get_version_local(self):
        httpretty.register_uri(httpretty.GET,
                               "http://localhost:35357/",
                               status=300,
                               body=json.dumps(self.TEST_RESPONSE_DICT))

        cs = client.Client()
        versions = cs.discover()
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v3.0', versions)
        self.assertEqual(
            versions['v3.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
        self.assertEqual(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][1]['links'][0]['href'])
Example #9
0
    def test_get_version_local(self):
        resp = utils.TestResponse({
            "status_code": 200,
            "text": json.dumps(self.TEST_RESPONSE_DICT),
        })
        kwargs = copy.copy(self.TEST_REQUEST_BASE)
        kwargs['headers'] = self.TEST_REQUEST_HEADERS
        requests.request('GET', "http://localhost:35357", **kwargs).AndReturn(
            (resp))
        self.mox.ReplayAll()

        cs = client.Client()
        versions = cs.discover()
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v2.0', versions)
        self.assertEquals(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
Example #10
0
    def test_get_version_local(self):
        resp = httplib2.Response({
            "status": 200,
            "body": json.dumps(self.TEST_RESPONSE_DICT),
        })

        httplib2.Http.request("http://localhost:35357",
                              'GET',
                              headers=self.TEST_REQUEST_HEADERS) \
                              .AndReturn((resp, resp['body']))
        self.mox.ReplayAll()

        cs = client.Client()
        versions = cs.discover()
        self.assertIsInstance(versions, dict)
        self.assertIn('message', versions)
        self.assertIn('v2.0', versions)
        self.assertEquals(
            versions['v2.0']['url'], self.TEST_RESPONSE_DICT['versions']
            ['values'][0]['links'][0]['href'])
Example #11
0
import urlparse

from keystoneclient.generic import client

from magnetodb.api import with_global_env
from magnetodb.common import exception
from magnetodb import storage
from magnetodb.openstack.common.log import logging

LOG = logging.getLogger(__name__)

STATUS_OK = '200'
STATUS_ERROR = '503'

keystoneclient = client.Client()


class HealthCheckApp(object):
    """ Controller for health check request. """
    def __init__(self, auth_uri=''):
        super(HealthCheckApp, self).__init__()
        self.auth_uri = auth_uri

    def __call__(self, environ, start_response):
        path = environ['PATH_INFO']

        LOG.debug('Request received: %s', path)

        if path and path != '/':
            start_response('404 Not found', [('Content-Type', 'text/plain')])
Example #12
0
 def _get_extensions(self, url):
     root = client.Client(url)
     extensions = root.discover_extensions(url)
     if extensions:
         for key, value in extensions.items():
             print "keystone-extension-%s ... ok" % key