Use auth_token from keystonemiddleware

auth_token middleware in python-keystoneclient is deprecated and has
been moved to the keystonemiddleware repo.

test_keystone_middleware_conf and
test_keystone_middleware_parse_conffile were removed. These tests
were relying on undocumented behavior (how the config options turn
into attributes). This doesn't work anymore since the
keystonemiddleware version doesn't provide any public API other than
calling it as a wsgi app, and then doesn't document what internal
operations it will do when called so isn't safe to be called in
unit tests. Tests verifying that the auth_token middleware can read
its config options should be done in keystonemiddleware.

Closes-Bug: #1342274

Change-Id: I1aadbe24db63eb2507b088cd53886d7f2e192cab
This commit is contained in:
Brant Knudson 2014-06-24 16:25:26 -05:00
parent c638d043b1
commit 243d4ad7ef
3 changed files with 2 additions and 53 deletions

View File

@ -18,64 +18,12 @@
"""Test basic ceilometer-api app
"""
import json
import os
import mock
import wsme
from ceilometer.api import app
from ceilometer.openstack.common import fileutils
from ceilometer.openstack.common.fixture import config
from ceilometer.openstack.common import gettextutils
from ceilometer import service
from ceilometer.tests import api as acl
from ceilometer.tests.api import v2
from ceilometer.tests import base
class TestApp(base.BaseTestCase):
def setUp(self):
super(TestApp, self).setUp()
self.CONF = self.useFixture(config.Config()).conf
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("pipeline_cfg_file",
self.path_get("etc/ceilometer/pipeline.yaml"))
self.CONF.set_override('connection', "log://", group="database")
self.CONF.set_override("auth_uri", None, group=acl.OPT_GROUP_NAME)
file_name = self.path_get('etc/ceilometer/api_paste.ini')
self.CONF.set_override("api_paste_config", file_name)
api_app = app.load_app()
self.assertTrue(api_app.auth_uri.startswith('file'))
def test_keystone_middleware_parse_conffile(self):
pipeline_conf = self.path_get("etc/ceilometer/pipeline.yaml")
api_conf = self.path_get('etc/ceilometer/api_paste.ini')
content = ("[DEFAULT]\n"
"rpc_backend = fake\n"
"pipeline_cfg_file = {0}\n"
"api_paste_config = {1}\n"
"[{2}]\n"
"auth_protocol = file\n"
"auth_version = v2.0\n".format(pipeline_conf,
api_conf,
acl.OPT_GROUP_NAME))
tmpfile = fileutils.write_to_tempfile(content=content,
prefix='ceilometer',
suffix='.conf')
service.prepare_service(['ceilometer-api',
'--config-file=%s' % tmpfile])
self.CONF.set_override('connection', "log://", group="database")
api_app = app.load_app()
self.assertTrue(api_app.auth_uri.startswith('file'))
os.unlink(tmpfile)
class TestPecanApp(v2.FunctionalTest):

View File

@ -11,5 +11,5 @@ pipeline = authtoken api-server
paste.app_factory = ceilometer.api.app:app_factory
[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
paste.filter_factory = keystonemiddleware.auth_token:filter_factory

View File

@ -7,6 +7,7 @@ happybase>=0.5,!=0.7
iso8601>=0.1.9
jsonpath-rw>=1.2.0,<2.0
jsonschema>=2.0.0,<3.0.0
keystonemiddleware>=1.0.0
lockfile>=0.8
lxml>=2.3
msgpack-python>=0.4.0