Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/certbot/certbot.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorohemorange <ebportnoy@gmail.com>2017-04-27 04:44:06 +0300
committerBrad Warren <bmw@users.noreply.github.com>2017-04-27 04:44:06 +0300
commit1611df4120bc6ed5bbbe9202070b52c6d2db0741 (patch)
treef33fc4462e75c0917b684e0610fbd1091e317a60 /certbot-nginx
parent5f9c6539d5a4e277770f30865ca4d162bad03cf8 (diff)
Allow empty nginx blocks (#4555)
* modify test config file to allow valid config that fails to parse in parser.py * make failing tests pass by fixing the problem
Diffstat (limited to 'certbot-nginx')
-rw-r--r--certbot-nginx/certbot_nginx/parser.py2
-rw-r--r--certbot-nginx/certbot_nginx/tests/parser_test.py6
-rw-r--r--certbot-nginx/certbot_nginx/tests/testdata/etc_nginx/nginx.conf3
3 files changed, 7 insertions, 4 deletions
diff --git a/certbot-nginx/certbot_nginx/parser.py b/certbot-nginx/certbot_nginx/parser.py
index 6f3f344db..9f1a08b3b 100644
--- a/certbot-nginx/certbot_nginx/parser.py
+++ b/certbot-nginx/certbot_nginx/parser.py
@@ -110,7 +110,7 @@ class NginxParser(object):
srv = servers[filename] # workaround undefined loop var in lambdas
# Find all the server blocks
- _do_for_subarray(tree, lambda x: x[0] == ['server'],
+ _do_for_subarray(tree, lambda x: len(x) >= 2 and x[0] == ['server'],
lambda x, y: srv.append((x[1], y)))
# Find 'include' statements in server blocks and append their trees
diff --git a/certbot-nginx/certbot_nginx/tests/parser_test.py b/certbot-nginx/certbot_nginx/tests/parser_test.py
index 9c2b8656e..8a8bd0ff1 100644
--- a/certbot-nginx/certbot_nginx/tests/parser_test.py
+++ b/certbot-nginx/certbot_nginx/tests/parser_test.py
@@ -125,13 +125,13 @@ class NginxParserTest(util.NginxTest):
False, True,
set(['localhost',
r'~^(www\.)?(example|bar)\.']),
- [], [9, 1, 9])
+ [], [10, 1, 9])
vhost2 = obj.VirtualHost(nparser.abs_path('nginx.conf'),
[obj.Addr('somename', '8080', False, False),
obj.Addr('', '8000', False, False)],
False, True,
set(['somename', 'another.alias', 'alias']),
- [], [9, 1, 12])
+ [], [10, 1, 12])
vhost3 = obj.VirtualHost(nparser.abs_path('sites-enabled/example.com'),
[obj.Addr('69.50.225.155', '9000',
False, False),
@@ -186,7 +186,7 @@ class NginxParserTest(util.NginxTest):
None, None, None,
set(['localhost',
r'~^(www\.)?(example|bar)\.']),
- None, [9, 1, 9])
+ None, [10, 1, 9])
nparser.add_server_directives(mock_vhost,
[['foo', 'bar'], ['\n ', 'ssl_certificate', ' ',
'/etc/ssl/cert.pem']],
diff --git a/certbot-nginx/certbot_nginx/tests/testdata/etc_nginx/nginx.conf b/certbot-nginx/certbot_nginx/tests/testdata/etc_nginx/nginx.conf
index 0af503e6b..ccce4dc1b 100644
--- a/certbot-nginx/certbot_nginx/tests/testdata/etc_nginx/nginx.conf
+++ b/certbot-nginx/certbot_nginx/tests/testdata/etc_nginx/nginx.conf
@@ -14,6 +14,9 @@ events {
worker_connections 1024;
}
+empty {
+}
+
include foo.conf;
http {