This change replaces the hard coded WSGI app creation with a pipeline of WSGI apps declared in a configuration file. Paste Deploy was used to create the pipeline since it is used by many other OpenStack projects and it is an active project with new contributors and supports Python 3. Dependency on Paste is localized so switching to another library would not be hard if OpenStack moves to another package in the future. The changes are small but the changes for the tests were large since many acl tests were assuming a hard coded WSGI app creation. blueprint declarative-filters Change-Id: I5ce05eab980271873269eca2945dc809f2923045
68 lines
2.7 KiB
Python
68 lines
2.7 KiB
Python
# -*- encoding: utf-8 -*-
|
|
#
|
|
# Copyright © 2013 Julien Danjou
|
|
#
|
|
# Author: Julien Danjou <julien@danjou.info>
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
"""Test basic ceilometer-api app
|
|
"""
|
|
import os
|
|
|
|
from keystoneclient.middleware import auth_token
|
|
|
|
from ceilometer.api.v1 import app
|
|
from ceilometer import messaging
|
|
from ceilometer.openstack.common import fileutils
|
|
from ceilometer.openstack.common.fixture import config
|
|
from ceilometer.openstack.common import test
|
|
from ceilometer import service
|
|
from ceilometer.tests import api as acl
|
|
|
|
|
|
class TestApp(test.BaseTestCase):
|
|
|
|
def setUp(self):
|
|
super(TestApp, self).setUp()
|
|
self.CONF = self.useFixture(config.Config()).conf
|
|
messaging.setup('fake://')
|
|
self.addCleanup(messaging.cleanup)
|
|
|
|
def test_keystone_middleware_conf(self):
|
|
self.CONF.set_override("auth_protocol", "file",
|
|
group=acl.OPT_GROUP_NAME)
|
|
self.CONF.set_override("auth_version", "v2.0",
|
|
group=acl.OPT_GROUP_NAME)
|
|
self.CONF.set_override("auth_uri", None,
|
|
group=acl.OPT_GROUP_NAME)
|
|
api_app = app.make_app(self.CONF, attach_storage=False)
|
|
conf = dict(self.CONF.get(acl.OPT_GROUP_NAME))
|
|
api_app = auth_token.AuthProtocol(api_app,
|
|
conf=conf)
|
|
self.assertTrue(api_app.auth_uri.startswith('file'))
|
|
|
|
def test_keystone_middleware_parse_conffile(self):
|
|
content = "[{0}]\nauth_protocol = file"\
|
|
"\nauth_version = v2.0".format(acl.OPT_GROUP_NAME)
|
|
tmpfile = fileutils.write_to_tempfile(content=content,
|
|
prefix='ceilometer',
|
|
suffix='.conf')
|
|
service.prepare_service(['ceilometer-api',
|
|
'--config-file=%s' % tmpfile])
|
|
api_app = app.make_app(self.CONF, attach_storage=False)
|
|
conf = dict(self.CONF.get(acl.OPT_GROUP_NAME))
|
|
api_app = auth_token.AuthProtocol(api_app,
|
|
conf=conf)
|
|
self.assertTrue(api_app.auth_uri.startswith('file'))
|
|
os.unlink(tmpfile)
|