Esempio n. 1
0
    def test_v3_disabled(self):
        client = tests.TestClient(self.public_app)
        # request to /v3 should fail
        resp = client.get('/v3/')
        self.assertEqual(404, resp.status_int)

        # request to /v2.0 should pass
        resp = client.get('/v2.0/')
        self.assertEqual(200, resp.status_int)
        data = jsonutils.loads(resp.body)
        expected = v2_VERSION_RESPONSE
        self._paste_in_port(expected['version'],
                            'http://localhost:%s/v2.0/' %
                            CONF.eventlet_server.public_port)
        self.assertEqual(expected, data)

        # only v2 information should be displayed by requests to /
        v2_only_response = {
            "versions": {
                "values": [
                    v2_EXPECTED_RESPONSE
                ]
            }
        }
        self._paste_in_port(v2_only_response['versions']['values'][0],
                            'http://localhost:%s/v2.0/' %
                            CONF.eventlet_server.public_port)
        resp = client.get('/')
        self.assertEqual(300, resp.status_int)
        data = jsonutils.loads(resp.body)
        self.assertEqual(v2_only_response, data)
Esempio n. 2
0
 def make_request(accept_types=None):
     client = tests.TestClient(self.public_app)
     headers = None
     if accept_types:
         headers = {'Accept': accept_types}
     resp = client.get('/v3', headers=headers)
     self.assertThat(resp.status, tt_matchers.Equals('200 OK'))
     return resp.headers['Content-Type']
Esempio n. 3
0
    def _test_json_home(self, path, exp_json_home_data):
        client = tests.TestClient(self.public_app)
        resp = client.get(path, headers={'Accept': 'application/json-home'})

        self.assertThat(resp.status, tt_matchers.Equals('200 OK'))
        self.assertThat(resp.headers['Content-Type'],
                        tt_matchers.Equals('application/json-home'))

        self.assertThat(jsonutils.loads(resp.body),
                        tt_matchers.Equals(exp_json_home_data))
Esempio n. 4
0
 def test_use_site_url_if_endpoint_unset_v3(self):
     self.config_fixture.config(public_endpoint=None, admin_endpoint=None)
     for app in (self.public_app, self.admin_app):
         client = tests.TestClient(app)
         resp = client.get('/v3/')
         self.assertEqual(200, resp.status_int)
         data = jsonutils.loads(resp.body)
         expected = v3_VERSION_RESPONSE
         self._paste_in_port(expected['version'], 'http://localhost/v3/')
         self.assertEqual(expected, data)
Esempio n. 5
0
 def test_admin_version_v3(self):
     client = tests.TestClient(self.public_app)
     resp = client.get('/v3/')
     self.assertEqual(200, resp.status_int)
     data = jsonutils.loads(resp.body)
     expected = v3_VERSION_RESPONSE
     self._paste_in_port(expected['version'],
                         'http://localhost:%s/v3/' %
                         CONF.eventlet_server.admin_port)
     self.assertEqual(expected, data)
Esempio n. 6
0
 def test_versions_without_headers(self):
     client = tests.TestClient(self.public_app)
     host_name = 'host-%d' % random.randint(10, 30)
     host_port = random.randint(10000, 30000)
     host = 'http://%s:%s/' % (host_name, host_port)
     resp = client.get(host)
     self.assertEqual(300, resp.status_int)
     data = jsonutils.loads(resp.body)
     expected = self._get_expected(host)
     self.assertThat(data, _VersionsEqual(expected))
Esempio n. 7
0
    def test_json_home_v3(self):
        # If the request is /v3 and the Accept header is application/json-home
        # then the server responds with a JSON Home document.

        client = tests.TestClient(self.public_app)
        resp = client.get('/v3/', headers={'Accept': 'application/json-home'})

        self.assertThat(resp.status, tt_matchers.Equals('200 OK'))
        self.assertThat(resp.headers['Content-Type'],
                        tt_matchers.Equals('application/json-home'))

        exp_json_home_data = {
            'resources': V3_JSON_HOME_RESOURCES_INHERIT_ENABLED}

        self.assertThat(jsonutils.loads(resp.body),
                        tt_matchers.Equals(exp_json_home_data))
Esempio n. 8
0
 def test_admin_versions(self):
     client = tests.TestClient(self.admin_app)
     resp = client.get('/')
     self.assertEqual(300, resp.status_int)
     data = jsonutils.loads(resp.body)
     expected = VERSIONS_RESPONSE
     for version in expected['versions']['values']:
         if version['id'] == 'v3.0':
             self._paste_in_port(
                 version, 'http://localhost:%s/v3/' %
                 CONF.eventlet_server.admin_port)
         elif version['id'] == 'v2.0':
             self._paste_in_port(
                 version, 'http://localhost:%s/v2.0/' %
                 CONF.eventlet_server.admin_port)
     self.assertThat(data, _VersionsEqual(expected))
Esempio n. 9
0
    def test_use_site_url_if_endpoint_unset(self):
        self.config_fixture.config(public_endpoint=None, admin_endpoint=None)

        for app in (self.public_app, self.admin_app):
            client = tests.TestClient(app)
            resp = client.get('/')
            self.assertEqual(300, resp.status_int)
            data = jsonutils.loads(resp.body)
            expected = VERSIONS_RESPONSE
            for version in expected['versions']['values']:
                # localhost happens to be the site url for tests
                if version['id'].startswith('v3'):
                    self._paste_in_port(version, 'http://localhost/v3/')
                elif version['id'] == 'v2.0':
                    self._paste_in_port(version, 'http://localhost/v2.0/')
            self.assertThat(data, _VersionsEqual(expected))
Esempio n. 10
0
 def _test_version(self, app_name):
     app = self.loadapp('keystone', app_name)
     client = tests.TestClient(app)
     resp = client.get('/')
     self.assertEqual(300, resp.status_int)
     data = jsonutils.loads(resp.body)
     expected = VERSIONS_RESPONSE
     for version in expected['versions']['values']:
         if version['id'] == 'v3.0':
             self._paste_in_port(
                 version, 'http://localhost:%s/v3/' %
                 CONF.eventlet_server.public_port)
         elif version['id'] == 'v2.0':
             self._paste_in_port(
                 version, 'http://localhost:%s/v2.0/' %
                 CONF.eventlet_server.public_port)
     self.assertThat(data, _VersionsEqual(expected))