mirror of
https://github.com/certbot/certbot.git
synced 2026-05-28 04:34:11 -04:00
Fix tests
This commit is contained in:
parent
6b639679e8
commit
9c915b0ae4
3 changed files with 12 additions and 5 deletions
|
|
@ -177,7 +177,7 @@ class NginxParser(object):
|
|||
if ssl_options is not None:
|
||||
try:
|
||||
with open(ssl_options) as _file:
|
||||
return nginxparser.load(_file)
|
||||
return nginxparser.load(_file).spaced
|
||||
except IOError:
|
||||
logger.debug("Could not open file: %s", ssl_options)
|
||||
except pyparsing.ParseException:
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ class NginxParserTest(util.NginxTest):
|
|||
|
||||
def test_ssl_options_should_be_parsed_ssl_directives(self):
|
||||
nparser = parser.NginxParser(self.config_path, self.ssl_options)
|
||||
self.assertEqual(nparser.loc["ssl_options"],
|
||||
self.assertEqual(nginxparser.UnspacedList(nparser.loc["ssl_options"]),
|
||||
[['ssl_session_cache', 'shared:le_nginx_SSL:1m'],
|
||||
['ssl_session_timeout', '1440m'],
|
||||
['ssl_protocols', 'TLSv1 TLSv1.1 TLSv1.2'],
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from certbot.plugins import common
|
|||
|
||||
from certbot_nginx import constants
|
||||
from certbot_nginx import configurator
|
||||
from certbot_nginx import nginxparser
|
||||
|
||||
|
||||
class NginxTest(unittest.TestCase): # pylint: disable=too-few-public-methods
|
||||
|
|
@ -84,14 +85,20 @@ def filter_comments(tree):
|
|||
def traverse(tree):
|
||||
"""Generator dropping comment nodes"""
|
||||
for entry in tree:
|
||||
key, values = entry
|
||||
# key, values = entry
|
||||
spaceless = [e for e in entry if not nginxparser.spacey(e)]
|
||||
if spaceless:
|
||||
key = spaceless[0]
|
||||
values = spaceless[1] if len(spaceless) > 1 else None
|
||||
else:
|
||||
key = values = ""
|
||||
if isinstance(key, list):
|
||||
new = copy.deepcopy(entry)
|
||||
new[1] = filter_comments(values)
|
||||
yield new
|
||||
else:
|
||||
if key != '#':
|
||||
yield entry
|
||||
if key != '#' and spaceless:
|
||||
yield spaceless
|
||||
|
||||
return list(traverse(tree))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue