Skip to content

Commit

Permalink
ssl-context-factory config test
Browse files Browse the repository at this point in the history
  • Loading branch information
zrvku2000 committed Jan 28, 2025
1 parent ffba946 commit c619148
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/test_runserver_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,37 @@ def app_factory(foo):
with pytest.raises(AiohttpDevConfigError,
match=r"'app\.py\.app_factory' should not have required arguments"):
await config.load_app(config.get_app_factory(module))


@forked
async def test_no_ssl_context_factory(tmpworkdir):
mktree(tmpworkdir, {
'app.py': """\
def app_factory(foo):
return web.Application()
"""
})
config = Config(app_path='app.py', ssl_context_factory_name='get_ssl_context')
module = config.import_module()
with pytest.raises(AiohttpDevConfigError,
match=r"Module 'app.py' does not define a 'get_ssl_context' attribute/class"):
await config.get_ssl_context(module)


@forked
async def test_invalid_ssl_context(tmpworkdir):
mktree(tmpworkdir, {
'app.py': """\
def app_factory(foo):
return web.Application()
def get_ssl_context():
return 'invalid ssl_context'
"""
})
config = Config(app_path='app.py', ssl_context_factory_name='get_ssl_context')
module = config.import_module()
with pytest.raises(AiohttpDevConfigError,
match=r"ssl-context-factory 'get_ssl_context' in \
module 'app.py' didn't return valid SSLContext"):
await config.get_ssl_context(module)

0 comments on commit c619148

Please sign in to comment.