Merge "Test proxy-server.conf-sample"

This commit is contained in:
Zuul 2021-03-31 08:56:27 +00:00 committed by Gerrit Code Review
commit bed368154a
2 changed files with 30 additions and 2 deletions

View File

@ -122,7 +122,7 @@ class ConfigString(NamedConfigLoader):
self.filename = "string"
defaults = {
'here': "string",
'__file__': self.contents,
'__file__': self,
}
self.parser = loadwsgi.NicerConfigParser("string", defaults=defaults)
self.parser.optionxform = str # Don't lower-case keys
@ -130,6 +130,15 @@ class ConfigString(NamedConfigLoader):
self.parser.defaults = lambda: dict(self.parser._defaults, **defaults)
self.parser.readfp(self.contents)
def readline(self, *args, **kwargs):
return self.contents.readline(*args, **kwargs)
def seek(self, *args, **kwargs):
return self.contents.seek(*args, **kwargs)
def __iter__(self):
return iter(self.contents)
def wrap_conf_type(f):
"""
@ -386,7 +395,7 @@ def loadapp(conf_file, global_conf=None, allow_modify_pipeline=True):
func = getattr(app, 'modify_wsgi_pipeline', None)
if func and allow_modify_pipeline:
func(PipelineWrapper(ctx))
# cache the freshly created app so we con't have to redo
# cache the freshly created app so we don't have to redo
# initialization checks and log startup messages again
ctx.app_context.create = lambda: app
return ctx.create()

View File

@ -1486,6 +1486,25 @@ class TestProxyServerConfigLoading(unittest.TestCase):
f.write(dedent(conf_body))
return conf_path
def _default_conf(self):
conf_path = os.path.abspath(os.path.join(
os.path.dirname(__file__),
'../../../',
'etc/proxy-server.conf-sample'
))
with open(conf_path) as f:
conf_body = f.read()
fixed_body = conf_body.replace('# swift_dir = /etc/swift',
'swift_dir = %s' % self.tempdir)
conf_path = self._write_conf(fixed_body)
return conf_path
def test_default_proxy_config(self):
app = loadapp(self._default_conf())
req = Request.blank('/info')
resp = req.get_response(app)
self.assertEqual(resp.status_int, 200)
def _write_conf_and_load_app(self, conf_sections, app_name='proxy-server'):
# write proxy-server.conf file, load app
conf_body = dedent("""