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:
authorSeth Schoen <schoen@eff.org>2016-08-04 03:10:20 +0300
committerSeth Schoen <schoen@eff.org>2016-08-04 03:10:20 +0300
commit353cb6e6c627e680c8e573a101a3548c193fc769 (patch)
tree5de3d004476a4b148f923b2706629ade7d00b1ff /certbot-compatibility-test
parent7b67ba6797ce41aad1ec70e0ad894b90204c51f0 (diff)
New _get_names approach for nginx test
Diffstat (limited to 'certbot-compatibility-test')
-rw-r--r--certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py27
1 files changed, 7 insertions, 20 deletions
diff --git a/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py b/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py
index c474d078c..779ba26a7 100644
--- a/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py
+++ b/certbot-compatibility-test/certbot_compatibility_test/configurators/nginx/common.py
@@ -125,25 +125,12 @@ def _get_server_root(config):
def _get_names(config):
"""Returns all and testable domain names in config"""
- # XXX: This is still Apache-specific
all_names = set()
- non_ip_names = set()
- with open(os.path.join(config, "vhosts")) as f:
- for line in f:
- # If parsing a specific vhost
- if line[0].isspace():
- words = line.split()
- if words[0] == "alias":
- all_names.add(words[1])
- non_ip_names.add(words[1])
- # If for port 80 and not IP vhost
- elif words[1] == "80" and not util.IP_REGEX.match(words[3]):
- all_names.add(words[3])
- non_ip_names.add(words[3])
- elif "NameVirtualHost" not in line:
- words = line.split()
- if (words[0].endswith("*") or words[0].endswith("80") and
- not util.IP_REGEX.match(words[1]) and
- words[1].find(".") != -1):
- all_names.add(words[1])
+ for root, _dirs, files in os.walk(config):
+ for this_file in files:
+ for line in open(os.path.join(root, this_file)):
+ if line.strip().starts_with("server_name"):
+ names = line.partition("server_name")[2].rstrip(";")
+ [all_names.add(n) for n in names.split()]
+ non_ip_names = set(n for n in all_names if not util.IP_REGEX.match(n))
return all_names, non_ip_names