Renaming Letsencrypt to Certbot, since it will be more generic allowing other issuers.
This commit is contained in:
parent
55888752c9
commit
5dbe0a6d28
40 changed files with 188 additions and 184 deletions
|
|
@ -49,10 +49,10 @@ class HaproxyConfigGenerator:
|
|||
def __init__(self, mapping):
|
||||
self.mapping = mapping
|
||||
self.mapping.setdefault("ssl_mode", 'default')
|
||||
self.mapping.setdefault("letsencrypt", {"email": "", "staging": False})
|
||||
self.mapping.setdefault("certbot", {"email": "", "staging": False})
|
||||
self.mapping["ssl_mode"] = self.mapping["ssl_mode"].lower()
|
||||
self.label = DockerLabelHandler(mapping['lookup_label'] if 'lookup_label' in mapping else "easyhaproxy")
|
||||
self.letsencrypt_hosts = []
|
||||
self.certbot_hosts = []
|
||||
self.serving_hosts = []
|
||||
self.certs = {}
|
||||
|
||||
|
|
@ -106,10 +106,10 @@ class HaproxyConfigGenerator:
|
|||
"80"
|
||||
)
|
||||
|
||||
letsencrypt = self.label.get_bool(
|
||||
self.label.create([definition, "letsencrypt"]),
|
||||
certbot = self.label.get_bool(
|
||||
self.label.create([definition, "certbot"]),
|
||||
False
|
||||
) and self.mapping["letsencrypt"]["email"] != ""
|
||||
) and self.mapping["certbot"]["email"] != ""
|
||||
clone_to_ssl = self.label.get_bool(
|
||||
self.label.create([definition, "clone_to_ssl"])
|
||||
)
|
||||
|
|
@ -139,9 +139,9 @@ class HaproxyConfigGenerator:
|
|||
self.serving_hosts.append("%s:%s" % (hostname, port))
|
||||
easymapping[port]["hosts"].setdefault(hostname, {})
|
||||
easymapping[port]["hosts"][hostname].setdefault("containers", [])
|
||||
easymapping[port]["hosts"][hostname].setdefault("letsencrypt", False)
|
||||
easymapping[port]["hosts"][hostname].setdefault("certbot", False)
|
||||
easymapping[port]["hosts"][hostname]["containers"] += ["{}:{}".format(container, ct_port)]
|
||||
easymapping[port]["hosts"][hostname]["letsencrypt"] = letsencrypt
|
||||
easymapping[port]["hosts"][hostname]["certbot"] = certbot
|
||||
easymapping[port]["hosts"][hostname]["redirect_ssl"] = self.label.get_bool(
|
||||
self.label.create([definition, "redirect_ssl"])
|
||||
)
|
||||
|
|
@ -150,7 +150,7 @@ class HaproxyConfigGenerator:
|
|||
self.label.create([definition, "redirect"])
|
||||
)
|
||||
|
||||
if letsencrypt or clone_to_ssl:
|
||||
if certbot or clone_to_ssl:
|
||||
if "443" not in easymapping:
|
||||
easymapping["443"] = {
|
||||
"mode": "http",
|
||||
|
|
@ -160,10 +160,10 @@ class HaproxyConfigGenerator:
|
|||
"redirect": dict(),
|
||||
}
|
||||
easymapping["443"]["hosts"][hostname] = dict(easymapping[port]["hosts"][hostname])
|
||||
easymapping["443"]["hosts"][hostname]["letsencrypt"] = False
|
||||
easymapping["443"]["hosts"][hostname]["certbot"] = False
|
||||
easymapping["443"]["hosts"][hostname]["redirect_ssl"] = False
|
||||
easymapping["443"]["ssl"] = True
|
||||
self.letsencrypt_hosts.append(hostname) if letsencrypt and hostname not in self.letsencrypt_hosts else self.letsencrypt_hosts
|
||||
self.certbot_hosts.append(hostname) if certbot and hostname not in self.certbot_hosts else self.certbot_hosts
|
||||
|
||||
|
||||
# handle SSL
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ class Functions:
|
|||
class Consts:
|
||||
easyhaproxy_config = "/etc/haproxy/static/config.yml"
|
||||
haproxy_config = "/etc/haproxy/haproxy.cfg"
|
||||
certs_letsencrypt = "/certs/letsencrypt"
|
||||
certs_certbot = "/certs/certbot"
|
||||
certs_haproxy = "/certs/haproxy"
|
||||
|
||||
|
||||
|
|
@ -259,11 +259,11 @@ class Certbot:
|
|||
Functions.save(filename, cert + key)
|
||||
|
||||
def find_live_certificates(self):
|
||||
letsencrypt_certs = "/etc/letsencrypt/live/"
|
||||
if not os.path.exists(letsencrypt_certs):
|
||||
certbot_certs = "/etc/letsencrypt/live/"
|
||||
if not os.path.exists(certbot_certs):
|
||||
return
|
||||
for item in os.listdir(letsencrypt_certs):
|
||||
path = os.path.join(letsencrypt_certs, item)
|
||||
for item in os.listdir(certbot_certs):
|
||||
path = os.path.join(certbot_certs, item)
|
||||
if os.path.isdir(path):
|
||||
cert = Functions.load(os.path.join(path, "cert.pem"))
|
||||
key = Functions.load(os.path.join(path, "privkey.pem"))
|
||||
|
|
|
|||
10
src/main.py
10
src/main.py
|
|
@ -8,12 +8,12 @@ def start():
|
|||
if processor_obj is None:
|
||||
exit(1)
|
||||
|
||||
os.makedirs(Consts.certs_letsencrypt, exist_ok=True)
|
||||
os.makedirs(Consts.certs_certbot, exist_ok=True)
|
||||
os.makedirs(Consts.certs_haproxy, exist_ok=True)
|
||||
|
||||
processor_obj.save_config(Consts.haproxy_config)
|
||||
processor_obj.save_certs(Consts.certs_haproxy)
|
||||
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
|
||||
certbot_certs_found = processor_obj.get_certbot_hosts()
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to run after save_config
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.TRACE, 'Object Found: %s' % (processor_obj.get_parsed_object()))
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ def start():
|
|||
haproxy.haproxy("start")
|
||||
haproxy.sleep()
|
||||
|
||||
certbot = Certbot(Consts.certs_letsencrypt, os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"), os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "").lower())
|
||||
certbot = Certbot(Consts.certs_certbot, os.getenv("EASYHAPROXY_CERTBOT_EMAIL"), os.getenv("EASYHAPROXY_CERTBOT_SERVER", "").lower())
|
||||
|
||||
while True:
|
||||
if old_haproxy is not None:
|
||||
|
|
@ -31,12 +31,12 @@ def start():
|
|||
try:
|
||||
old_parsed = processor_obj.get_parsed_object()
|
||||
processor_obj.refresh()
|
||||
if certbot.check_certificates(letsencrypt_certs_found) or DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive():
|
||||
if certbot.check_certificates(certbot_certs_found) or DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive():
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'New configuration found. Reloading...')
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.TRACE, 'Object Found: %s' % (processor_obj.get_parsed_object()))
|
||||
processor_obj.save_config(Consts.haproxy_config)
|
||||
processor_obj.save_certs(Consts.certs_haproxy)
|
||||
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
|
||||
certbot_certs_found = processor_obj.get_certbot_hosts()
|
||||
Functions.log(Functions.EASYHAPROXY_LOG, Functions.DEBUG, 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
|
||||
old_haproxy = haproxy
|
||||
haproxy = DaemonizeHAProxy()
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class ContainerEnv:
|
|||
}
|
||||
|
||||
env_vars["lookup_label"] = os.getenv("EASYHAPROXY_LABEL_PREFIX") if os.getenv("EASYHAPROXY_LABEL_PREFIX") else "easyhaproxy"
|
||||
if (os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL")):
|
||||
env_vars["letsencrypt"] = {
|
||||
"email": os.getenv("EASYHAPROXY_LETSENCRYPT_EMAIL"),
|
||||
"server": os.getenv("EASYHAPROXY_LETSENCRYPT_SERVER", "false").lower() in ["true", "1", "yes"]
|
||||
if (os.getenv("EASYHAPROXY_CERTBOT_EMAIL")):
|
||||
env_vars["certbot"] = {
|
||||
"email": os.getenv("EASYHAPROXY_CERTBOT_EMAIL"),
|
||||
"server": os.getenv("EASYHAPROXY_CERTBOT_SERVER", "false").lower() in ["true", "1", "yes"]
|
||||
}
|
||||
|
||||
return env_vars
|
||||
|
|
@ -57,7 +57,7 @@ class ProcessorInterface:
|
|||
return None
|
||||
|
||||
def refresh(self):
|
||||
self.letsencrypt_hosts = None
|
||||
self.certbot_hosts = None
|
||||
self.parsed_object = None
|
||||
self.cfg = None
|
||||
self.hosts = None
|
||||
|
|
@ -71,8 +71,8 @@ class ProcessorInterface:
|
|||
def parse(self):
|
||||
self.cfg = HaproxyConfigGenerator(ContainerEnv.read())
|
||||
|
||||
def get_letsencrypt_hosts(self):
|
||||
return self.letsencrypt_hosts
|
||||
def get_certbot_hosts(self):
|
||||
return self.certbot_hosts
|
||||
|
||||
def get_hosts(self):
|
||||
return self.hosts
|
||||
|
|
@ -88,7 +88,7 @@ class ProcessorInterface:
|
|||
|
||||
def get_haproxy_conf(self):
|
||||
conf = self.cfg.generate(self.parsed_object)
|
||||
self.letsencrypt_hosts = self.cfg.letsencrypt_hosts
|
||||
self.certbot_hosts = self.cfg.certbot_hosts
|
||||
self.hosts = self.cfg.serving_hosts
|
||||
return conf
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ class Kubernetes(ProcessorInterface):
|
|||
|
||||
ssl_hosts = []
|
||||
|
||||
letsencrypt = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.letsencrypt")
|
||||
certbot = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.certbot")
|
||||
redirect_ssl = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect_ssl")
|
||||
redirect = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.redirect")
|
||||
mode = self._check_annotation(ingress.metadata.annotations, "easyhaproxy.mode")
|
||||
|
|
@ -252,8 +252,8 @@ class Kubernetes(ProcessorInterface):
|
|||
rule_data["%s.clone_to_ssl" % (definition)] = 'true'
|
||||
if redirect_ssl is not None:
|
||||
rule_data["%s.redirect_ssl" % (definition)] = redirect_ssl
|
||||
if letsencrypt is not None:
|
||||
rule_data["%s.letsencrypt" % (definition)] = letsencrypt
|
||||
if certbot is not None:
|
||||
rule_data["%s.certbot" % (definition)] = certbot
|
||||
if redirect is not None:
|
||||
rule_data["%s.redirect" % (definition)] = redirect
|
||||
if mode is not None:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{% if "ssl" in o %}
|
||||
bind *:{{ o["port"] }} ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
bind *:{{ o["port"] }} ssl crt /certs/certbot/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
{% elif "h2" in o and o["h2"] %}
|
||||
bind *:{{ o["port"] }} proto h2
|
||||
option http-use-htx
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@
|
|||
|
||||
{%- for k in o["hosts"] %}
|
||||
{% set host = k.replace(".", "_") + "_{0}".format(o["port"]) %}
|
||||
{% set letsencrypt = o["hosts"][k]["letsencrypt"] %}
|
||||
{% set certbot = o["hosts"][k]["certbot"] %}
|
||||
|
||||
acl is_rule_{{ host }}_1 hdr(host) -i {{ k }}
|
||||
acl is_rule_{{ host }}_2 hdr(host) -i {{ k }}:{{ o["port"] }}
|
||||
{% if letsencrypt %}
|
||||
acl is_letsencrypt_{{ host }} path_beg /.well-known/acme-challenge/
|
||||
use_backend letsencrypt_backend if is_letsencrypt_{{ host }} is_rule_{{ host }}_1 OR is_letsencrypt_{{ host }} is_rule_{{ host }}_2
|
||||
{% if certbot %}
|
||||
acl is_certbot_{{ host }} path_beg /.well-known/acme-challenge/
|
||||
use_backend certbot_backend if is_certbot_{{ host }} is_rule_{{ host }}_1 OR is_certbot_{{ host }} is_rule_{{ host }}_2
|
||||
{% endif %}
|
||||
{% if o["hosts"][k]["redirect_ssl"] %}
|
||||
http-request redirect scheme https code 301 if {% if letsencrypt %}!is_letsencrypt_{{ host }} {% endif %}is_rule_{{ host }}_1 OR {% if letsencrypt %}!is_letsencrypt_{{ host }} {% endif %}is_rule_{{ host }}_2
|
||||
http-request redirect scheme https code 301 if {% if certbot %}!is_certbot_{{ host }} {% endif %}is_rule_{{ host }}_1 OR {% if certbot %}!is_certbot_{{ host }} {% endif %}is_rule_{{ host }}_2
|
||||
{% else %}
|
||||
use_backend srv_{{ host }} if is_rule_{{ host }}_1 OR is_rule_{{ host }}_2
|
||||
{% endif %}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ backend srv_{{ host }}
|
|||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ backend srv_stats
|
|||
server Local 127.0.0.1:1936
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
bind *:443 ssl crt /certs/certbot/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
mode http
|
||||
|
||||
acl is_rule_hostssl_local_443_1 hdr(host) -i hostssl.local
|
||||
|
|
@ -84,8 +84,8 @@ frontend http_in_90
|
|||
|
||||
acl is_rule_host2_local_90_1 hdr(host) -i host2.local
|
||||
acl is_rule_host2_local_90_2 hdr(host) -i host2.local:90
|
||||
acl is_letsencrypt_host2_local_90 path_beg /.well-known/acme-challenge/
|
||||
use_backend letsencrypt_backend if is_letsencrypt_host2_local_90 is_rule_host2_local_90_1 OR is_letsencrypt_host2_local_90 is_rule_host2_local_90_2
|
||||
acl is_certbot_host2_local_90 path_beg /.well-known/acme-challenge/
|
||||
use_backend certbot_backend if is_certbot_host2_local_90 is_rule_host2_local_90_1 OR is_certbot_host2_local_90 is_rule_host2_local_90_2
|
||||
use_backend srv_host2_local_90 if is_rule_host2_local_90_1 OR is_rule_host2_local_90_2
|
||||
|
||||
backend srv_host2_local_90
|
||||
|
|
@ -96,6 +96,6 @@ backend srv_host2_local_90
|
|||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||
server srv-0 test_processor_docker:9000 check weight 1
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -23,6 +23,6 @@ defaults
|
|||
timeout server 10m
|
||||
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ frontend http_in_80
|
|||
|
||||
acl is_rule_test_example_org_80_1 hdr(host) -i test.example.org
|
||||
acl is_rule_test_example_org_80_2 hdr(host) -i test.example.org:80
|
||||
acl is_letsencrypt_test_example_org_80 path_beg /.well-known/acme-challenge/
|
||||
use_backend letsencrypt_backend if is_letsencrypt_test_example_org_80 is_rule_test_example_org_80_1 OR is_letsencrypt_test_example_org_80 is_rule_test_example_org_80_2
|
||||
http-request redirect scheme https code 301 if !is_letsencrypt_test_example_org_80 is_rule_test_example_org_80_1 OR !is_letsencrypt_test_example_org_80 is_rule_test_example_org_80_2
|
||||
acl is_certbot_test_example_org_80 path_beg /.well-known/acme-challenge/
|
||||
use_backend certbot_backend if is_certbot_test_example_org_80 is_rule_test_example_org_80_1 OR is_certbot_test_example_org_80 is_rule_test_example_org_80_2
|
||||
http-request redirect scheme https code 301 if !is_certbot_test_example_org_80 is_rule_test_example_org_80_1 OR !is_certbot_test_example_org_80 is_rule_test_example_org_80_2
|
||||
|
||||
acl is_rule_test2_example_org_80_1 hdr(host) -i test2.example.org
|
||||
acl is_rule_test2_example_org_80_2 hdr(host) -i test2.example.org:80
|
||||
|
|
@ -74,7 +74,7 @@ backend srv_test2_example_org_80
|
|||
server srv-0 83d57d592e26:8080 check weight 1
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
bind *:443 ssl crt /certs/certbot/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
mode http
|
||||
|
||||
acl is_rule_test_example_org_443_1 hdr(host) -i test.example.org
|
||||
|
|
@ -90,6 +90,6 @@ backend srv_test_example_org_443
|
|||
server srv-0 f5c645a0dfc6:80 check weight 1 verify none
|
||||
server srv-1 b63438410b6a:80 check weight 1 verify none
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -40,6 +40,6 @@ backend srv_www_helloworld_com_19901
|
|||
server srv-0 test_nginx.2.t5r94mjlced7m3t5orfjbowmm:80 check weight 1
|
||||
server srv-1 test_nginx.1.p552hqxkdx88narjrp5kouwb2:80 check weight 1
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -73,6 +73,6 @@ backend srv_hello_com_19901
|
|||
server srv-0 3e63154954b0:80 check weight 1
|
||||
server srv-1 eb294c110eb1:80 check weight 1
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ backend srv_host1_local_80
|
|||
server srv-0 5b69bc7fea1b:80 check weight 1
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
bind *:443 ssl crt /certs/certbot/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
mode http
|
||||
|
||||
acl is_rule_host2_local_443_1 hdr(host) -i host2.local
|
||||
|
|
@ -75,6 +75,6 @@ backend srv_host1_local_443
|
|||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||
server srv-0 5b69bc7fea1b:8080 check weight 1
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -37,6 +37,6 @@ backend srv_agent_quantum_local_31339
|
|||
tcp-check connect ssl
|
||||
server srv-0 test_agent:9001 check weight 1 verify none
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -47,8 +47,8 @@ frontend http_in_31337
|
|||
|
||||
acl is_rule_node-exporter_quantum_example_org_31337_1 hdr(host) -i node-exporter.quantum.example.org
|
||||
acl is_rule_node-exporter_quantum_example_org_31337_2 hdr(host) -i node-exporter.quantum.example.org:31337
|
||||
acl is_letsencrypt_node-exporter_quantum_example_org_31337 path_beg /.well-known/acme-challenge/
|
||||
use_backend letsencrypt_backend if is_letsencrypt_node-exporter_quantum_example_org_31337 is_rule_node-exporter_quantum_example_org_31337_1 OR is_letsencrypt_node-exporter_quantum_example_org_31337 is_rule_node-exporter_quantum_example_org_31337_2
|
||||
acl is_certbot_node-exporter_quantum_example_org_31337 path_beg /.well-known/acme-challenge/
|
||||
use_backend certbot_backend if is_certbot_node-exporter_quantum_example_org_31337 is_rule_node-exporter_quantum_example_org_31337_1 OR is_certbot_node-exporter_quantum_example_org_31337 is_rule_node-exporter_quantum_example_org_31337_2
|
||||
use_backend srv_node-exporter_quantum_example_org_31337 if is_rule_node-exporter_quantum_example_org_31337_1 OR is_rule_node-exporter_quantum_example_org_31337_2
|
||||
|
||||
backend srv_cadvisor_quantum_example_org_31337
|
||||
|
|
@ -67,7 +67,7 @@ backend srv_node-exporter_quantum_example_org_31337
|
|||
server srv-0 my-stack_node-exporter:9100 check weight 1
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
bind *:443 ssl crt /certs/certbot/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
mode http
|
||||
redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i somehost.com.br }
|
||||
redirect prefix https://www.somehost.com.br code 301 if { hdr(host) -i somehost.com }
|
||||
|
|
@ -119,6 +119,6 @@ backend srv_www_somehost_com_br_80
|
|||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||
server srv-0 some-service:80 check weight 1
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -33,6 +33,6 @@ backend srv_stats
|
|||
mode http
|
||||
server Local 127.0.0.1:1936
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ defaults
|
|||
timeout server 10m
|
||||
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ frontend http_in_80
|
|||
|
||||
acl is_rule_host1_com_br_80_1 hdr(host) -i host1.com.br
|
||||
acl is_rule_host1_com_br_80_2 hdr(host) -i host1.com.br:80
|
||||
acl is_letsencrypt_host1_com_br_80 path_beg /.well-known/acme-challenge/
|
||||
use_backend letsencrypt_backend if is_letsencrypt_host1_com_br_80 is_rule_host1_com_br_80_1 OR is_letsencrypt_host1_com_br_80 is_rule_host1_com_br_80_2
|
||||
acl is_certbot_host1_com_br_80 path_beg /.well-known/acme-challenge/
|
||||
use_backend certbot_backend if is_certbot_host1_com_br_80 is_rule_host1_com_br_80_1 OR is_certbot_host1_com_br_80 is_rule_host1_com_br_80_2
|
||||
use_backend srv_host1_com_br_80 if is_rule_host1_com_br_80_1 OR is_rule_host1_com_br_80_2
|
||||
|
||||
acl is_rule_host2_com_br_80_1 hdr(host) -i host2.com.br
|
||||
|
|
@ -74,7 +74,7 @@ backend srv_host2_com_br_80
|
|||
server srv-0 other:3000 check weight 1
|
||||
|
||||
frontend http_in_443
|
||||
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
bind *:443 ssl crt /certs/certbot/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||
mode http
|
||||
|
||||
acl is_rule_host1_com_br_443_1 hdr(host) -i host1.com.br
|
||||
|
|
@ -105,6 +105,6 @@ backend srv_host3_com_br_8080
|
|||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||
server srv-0 domain:8181 check weight 1
|
||||
|
||||
backend letsencrypt_backend
|
||||
backend certbot_backend
|
||||
mode http
|
||||
server certbot 127.0.0.1:2080
|
||||
|
|
|
|||
2
src/tests/fixtures/services
vendored
2
src/tests/fixtures/services
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{"portainer-agent_agent": {"com.docker.stack.image":"portainer/agent:1.5.1","com.docker.stack.namespace":"portainer-agent"},
|
||||
"my-stack_agent": {"easyhaproxy.agent.host":"agent.quantum.example.org","easyhaproxy.agent.localport":"9001","easyhaproxy.agent.mode":"tcp","easyhaproxy.agent.port":"31339","com.docker.stack.image":"portainer/agent:1.5.1","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring"},
|
||||
"my-stack_cadvisor": {"easyhaproxy.cadvisor.host":"cadvisor.quantum.example.org","easyhaproxy.cadvisor.localport":"8080","easyhaproxy.cadvisor.port":"31337","com.docker.stack.image":"gcr.io/google-containers/cadvisor:v0.34.0","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring"},
|
||||
"my-stack_node-exporter": {"easyhaproxy.exp.host":"node-exporter.quantum.example.org","easyhaproxy.exp.localport":"9100","easyhaproxy.exp.port":"31337","com.docker.stack.image":"stefanprodan/swarmprom-node-exporter:v0.16.0","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring","easyhaproxy.exp.letsencrypt":"true"},
|
||||
"my-stack_node-exporter": {"easyhaproxy.exp.host":"node-exporter.quantum.example.org","easyhaproxy.exp.localport":"9100","easyhaproxy.exp.port":"31337","com.docker.stack.image":"stefanprodan/swarmprom-node-exporter:v0.16.0","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring","easyhaproxy.exp.certbot":"true"},
|
||||
"my-stack_reverse-proxy": {"com.docker.stack.image":"quay.io/pngmbh/easy-haproxy:tcp-mode","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring"},
|
||||
"some-service": {"easyhaproxy.http.port":"80","easyhaproxy.http.host":"www.somehost.com.br","easyhaproxy.http.localport":"80","easyhaproxy.http.redirect":"{\"somehost.com.br\":\"https://www.somehost.com.br\",\"somehost.com\":\"https://www.somehost.com.br\",\"www.somehost.com\":\"https://www.somehost.com.br\",\"byjg.ca\":\"https://www.somehost.com.br\",\"www.byjg.ca\":\"https://www.somehost.com.br\"}","easyhaproxy.https.port":"443","easyhaproxy.https.host":"www.somehost.com.br","easyhaproxy.https.localport":"80","easyhaproxy.https.redirect":"{\"somehost.com.br\":\"https://www.somehost.com.br\",\"somehost.com\":\"https://www.somehost.com.br\",\"www.somehost.com\":\"https://www.somehost.com.br\",\"byjg.ca\":\"https://www.somehost.com.br\",\"www.byjg.ca\":\"https://www.somehost.com.br\"}","easyhaproxy.https.sslcert":"U29tZSBQRU0gQ2VydGlmaWNhdGU="}}
|
||||
2
src/tests/fixtures/services-changed-label
vendored
2
src/tests/fixtures/services-changed-label
vendored
|
|
@ -1,6 +1,6 @@
|
|||
{"portainer-agent_agent": {"com.docker.stack.image":"portainer/agent:1.5.1","com.docker.stack.namespace":"portainer-agent"},
|
||||
"my-stack_agent": {"haproxy.agent.host":"agent.quantum.example.org","haproxy.agent.localport":"9001","haproxy.agent.mode":"tcp","haproxy.agent.port":"31339","com.docker.stack.image":"portainer/agent:1.5.1","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring"},
|
||||
"my-stack_cadvisor": {"haproxy.cadvisor.host":"cadvisor.quantum.example.org","haproxy.cadvisor.localport":"8080","haproxy.cadvisor.port":"31337","com.docker.stack.image":"gcr.io/google-containers/cadvisor:v0.34.0","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring"},
|
||||
"my-stack_node-exporter": {"haproxy.exp.host":"node-exporter.quantum.example.org","haproxy.exp.localport":"9100","haproxy.exp.port":"31337","com.docker.stack.image":"stefanprodan/swarmprom-node-exporter:v0.16.0","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring","haproxy.exp.letsencrypt":"yes"},
|
||||
"my-stack_node-exporter": {"haproxy.exp.host":"node-exporter.quantum.example.org","haproxy.exp.localport":"9100","haproxy.exp.port":"31337","com.docker.stack.image":"stefanprodan/swarmprom-node-exporter:v0.16.0","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring","haproxy.exp.certbot":"yes"},
|
||||
"my-stack_reverse-proxy": {"com.docker.stack.image":"quay.io/pngmbh/easy-haproxy:tcp-mode","com.docker.stack.namespace":"my-stack","com.planetary-quantum":"monitoring"},
|
||||
"some-service": {"haproxy.http.port":"80","haproxy.http.host":"www.somehost.com.br","haproxy.http.localport":"80","haproxy.http.redirect":"{\"somehost.com.br\":\"https://www.somehost.com.br\",\"somehost.com\":\"https://www.somehost.com.br\",\"www.somehost.com\":\"https://www.somehost.com.br\",\"byjg.ca\":\"https://www.somehost.com.br\",\"www.byjg.ca\":\"https://www.somehost.com.br\"}","haproxy.https.port":"443","haproxy.https.host":"www.somehost.com.br","haproxy.https.localport":"80","haproxy.https.redirect":"{\"somehost.com.br\":\"https://www.somehost.com.br\",\"somehost.com\":\"https://www.somehost.com.br\",\"www.somehost.com\":\"https://www.somehost.com.br\",\"byjg.ca\":\"https://www.somehost.com.br\",\"www.byjg.ca\":\"https://www.somehost.com.br\"}","haproxy.https.sslcert":"U29tZSBQRU0gQ2VydGlmaWNhdGU="}}
|
||||
4
src/tests/fixtures/services-letsencrypt
vendored
4
src/tests/fixtures/services-letsencrypt
vendored
|
|
@ -1,4 +1,4 @@
|
|||
{"f5c645a0dfc6": {"com.docker.compose.config-hash":"b95ebc27d0e61caa418cdfa632e05a656da9bbc3ea0d4603651971015f10a1f0","com.docker.compose.container-number":"1","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:bea3509d6fdc8d7f9ec95563a5a226dc977ee74fb3e980e0de70e892c2d38dde","com.docker.compose.oneoff":"False","com.docker.compose.project":"docker","com.docker.compose.project.config_files":"/workspace/docker-easy-haproxy/examples/docker/docker-compose-test.yml","com.docker.compose.project.working_dir":"/workspace/docker-easy-haproxy/examples/docker","com.docker.compose.service":"nginx","com.docker.compose.version":"2.8.0","easyhaproxy.http.host":"test.example.org","easyhaproxy.http.letsencrypt":"true","easyhaproxy.http.localport":"80","easyhaproxy.http.port":"80","easyhaproxy.http.redirect":"{\"google.helloworld.com\": \"www.google.com\"}","easyhaproxy.http.redirect_ssl":"true"},
|
||||
{"f5c645a0dfc6": {"com.docker.compose.config-hash":"b95ebc27d0e61caa418cdfa632e05a656da9bbc3ea0d4603651971015f10a1f0","com.docker.compose.container-number":"1","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:bea3509d6fdc8d7f9ec95563a5a226dc977ee74fb3e980e0de70e892c2d38dde","com.docker.compose.oneoff":"False","com.docker.compose.project":"docker","com.docker.compose.project.config_files":"/workspace/docker-easy-haproxy/examples/docker/docker-compose-test.yml","com.docker.compose.project.working_dir":"/workspace/docker-easy-haproxy/examples/docker","com.docker.compose.service":"nginx","com.docker.compose.version":"2.8.0","easyhaproxy.http.host":"test.example.org","easyhaproxy.http.certbot":"true","easyhaproxy.http.localport":"80","easyhaproxy.http.port":"80","easyhaproxy.http.redirect":"{\"google.helloworld.com\": \"www.google.com\"}","easyhaproxy.http.redirect_ssl":"true"},
|
||||
"bbd4d1854155": {"com.docker.compose.config-hash":"3dc790bf2bea944359c75a40c45655bd868f1d85beb599d1ca797e8ea2c95ee4","com.docker.compose.container-number":"1","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:0fd95b1512c207048ab3fcc74032354f38143fbb8235ac2a47da903c98a58205","com.docker.compose.oneoff":"False","com.docker.compose.project":"docker","com.docker.compose.project.config_files":"/workspace/docker-easy-haproxy/examples/docker/docker-compose-test.yml","com.docker.compose.project.working_dir":"/workspace/docker-easy-haproxy/examples/docker","com.docker.compose.service":"haproxy","com.docker.compose.version":"2.8.0"},
|
||||
"b63438410b6a": {"com.docker.compose.config-hash":"b95ebc27d0e61caa418cdfa632e05a656da9bbc3ea0d4603651971015f10a1f0","com.docker.compose.container-number":"2","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:bea3509d6fdc8d7f9ec95563a5a226dc977ee74fb3e980e0de70e892c2d38dde","com.docker.compose.oneoff":"False","com.docker.compose.project":"docker","com.docker.compose.project.config_files":"/workspace/docker-easy-haproxy/examples/docker/docker-compose-test.yml","com.docker.compose.project.working_dir":"/workspace/docker-easy-haproxy/examples/docker","com.docker.compose.service":"nginx","com.docker.compose.version":"2.8.0","easyhaproxy.http.host":"test.example.org","easyhaproxy.http.letsencrypt":"true","easyhaproxy.http.localport":"80","easyhaproxy.http.port":"80","easyhaproxy.http.redirect":"{\"google.helloworld.com\": \"www.google.com\"}","easyhaproxy.http.redirect_ssl":"true"},
|
||||
"b63438410b6a": {"com.docker.compose.config-hash":"b95ebc27d0e61caa418cdfa632e05a656da9bbc3ea0d4603651971015f10a1f0","com.docker.compose.container-number":"2","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:bea3509d6fdc8d7f9ec95563a5a226dc977ee74fb3e980e0de70e892c2d38dde","com.docker.compose.oneoff":"False","com.docker.compose.project":"docker","com.docker.compose.project.config_files":"/workspace/docker-easy-haproxy/examples/docker/docker-compose-test.yml","com.docker.compose.project.working_dir":"/workspace/docker-easy-haproxy/examples/docker","com.docker.compose.service":"nginx","com.docker.compose.version":"2.8.0","easyhaproxy.http.host":"test.example.org","easyhaproxy.http.certbot":"true","easyhaproxy.http.localport":"80","easyhaproxy.http.port":"80","easyhaproxy.http.redirect":"{\"google.helloworld.com\": \"www.google.com\"}","easyhaproxy.http.redirect_ssl":"true"},
|
||||
"83d57d592e26": {"com.docker.compose.config-hash":"8c5871144f1e8a3aeca037207c02f011ab2c6e6c311a3773602b63541762dab5","com.docker.compose.container-number":"1","com.docker.compose.depends_on":"","com.docker.compose.image":"sha256:c4232396c715f3d568816c666e6d9b4a68ef6c36f6243b4007c4ee1d8335fd65","com.docker.compose.oneoff":"False","com.docker.compose.project":"docker","com.docker.compose.project.config_files":"/workspace/docker-easy-haproxy/examples/docker/docker-compose-test.yml","com.docker.compose.project.working_dir":"/workspace/docker-easy-haproxy/examples/docker","com.docker.compose.service":"static","com.docker.compose.version":"2.8.0","easyhaproxy.http.host":"test2.example.org","easyhaproxy.http.localport":"8080","easyhaproxy.http.port":"80","io.buildah.version":"1.21.0"}}
|
||||
2
src/tests/fixtures/static.yml
vendored
2
src/tests/fixtures/static.yml
vendored
|
|
@ -11,7 +11,7 @@ easymapping:
|
|||
host1.com.br:
|
||||
containers:
|
||||
- container:5000
|
||||
letsencrypt: true
|
||||
certbot: true
|
||||
host2.com.br:
|
||||
containers:
|
||||
- other:3000
|
||||
|
|
|
|||
|
|
@ -87,32 +87,32 @@ def test_container_env_stats_password():
|
|||
|
||||
|
||||
def test_container_env_stats_password():
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = 'acme@example.org'
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = 'acme@example.org'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"letsencrypt": {
|
||||
"certbot": {
|
||||
"email": "acme@example.org",
|
||||
"server": False
|
||||
}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = ''
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = ''
|
||||
|
||||
def test_container_env_letsencrypt():
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = 'acme@example.org'
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_SERVER'] = 'true'
|
||||
def test_container_env_certbot():
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = 'acme@example.org'
|
||||
os.environ['EASYHAPROXY_CERTBOT_SERVER'] = 'true'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"letsencrypt": {
|
||||
"certbot": {
|
||||
"email": "acme@example.org",
|
||||
"server": True
|
||||
}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = ''
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = ''
|
||||
|
|
@ -46,7 +46,7 @@ def test_processor_docker():
|
|||
"easyhaproxy.http2.port": "90",
|
||||
"easyhaproxy.http2.localport": "9000",
|
||||
"easyhaproxy.http2.host": "host2.local",
|
||||
"easyhaproxy.http2.letsencrypt": "true",
|
||||
"easyhaproxy.http2.certbot": "true",
|
||||
})
|
||||
container2 = client.containers.run("byjg/static-httpserver",
|
||||
name="test2_processor_docker",
|
||||
|
|
@ -62,10 +62,10 @@ def test_processor_docker():
|
|||
try:
|
||||
time.sleep(1)
|
||||
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = 'docker@example.org'
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = 'docker@example.org'
|
||||
|
||||
static = ProcessorInterface.factory("docker")
|
||||
assert static.get_letsencrypt_hosts() is None
|
||||
assert static.get_certbot_hosts() is None
|
||||
|
||||
assert {
|
||||
'easyhaproxy.http.host': 'host1.local',
|
||||
|
|
@ -74,7 +74,7 @@ def test_processor_docker():
|
|||
'easyhaproxy.http2.host': 'host2.local',
|
||||
'easyhaproxy.http2.localport': '9000',
|
||||
'easyhaproxy.http2.port': '90',
|
||||
'easyhaproxy.http2.letsencrypt': 'true',
|
||||
'easyhaproxy.http2.certbot': 'true',
|
||||
} == _get_hydrated_object(static.get_parsed_object(), "easyhaproxy.http")
|
||||
assert {
|
||||
'easyhaproxy.ssl.host': 'hostssl.local',
|
||||
|
|
@ -90,7 +90,7 @@ def test_processor_docker():
|
|||
assert haproxy_cfg == Functions.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), "./expected/docker.txt")).replace("test_processor_docker", _get_ip_host(
|
||||
static.get_parsed_object(), "easyhaproxy.http")).replace("test2_processor_docker", _get_ip_host(static.get_parsed_object(), "easyhaproxy.ssl"))
|
||||
|
||||
assert static.get_letsencrypt_hosts() == ['host2.local']
|
||||
assert static.get_certbot_hosts() == ['host2.local']
|
||||
assert static.get_hosts() == [
|
||||
'hostssl.local:443',
|
||||
'host1.local:80',
|
||||
|
|
@ -100,7 +100,7 @@ def test_processor_docker():
|
|||
'hostssl.local.pem': 'Some PEM Certificate'
|
||||
}
|
||||
finally:
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = ''
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = ''
|
||||
container.stop()
|
||||
container2.stop()
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import json
|
|||
|
||||
CERTS_FOLDER="/tmp/certs"
|
||||
CERT_FILE="/tmp/certs/haproxy/www.somehost.com.br.pem"
|
||||
LETSENCRYPT_EMAIL="some@email.com"
|
||||
CERTBOT_EMAIL="some@email.com"
|
||||
|
||||
def load_fixture(file):
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
|
@ -33,15 +33,15 @@ def test_parser_doesnt_crash():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/no-services.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_finds_services():
|
||||
line_list = load_fixture("services")
|
||||
|
||||
result = {
|
||||
"customerrors": False,
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
"certbot": {
|
||||
"email": CERTBOT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
|
|
@ -58,7 +58,7 @@ def test_parser_finds_services():
|
|||
|
||||
assert {"www.somehost.com.br.pem":"Some PEM Certificate"} == cfg.certs
|
||||
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.letsencrypt_hosts
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_finds_services_changed_label():
|
||||
line_list = load_fixture("services-changed-label")
|
||||
|
|
@ -66,8 +66,8 @@ def test_parser_finds_services_changed_label():
|
|||
result = {
|
||||
"customerrors": False,
|
||||
"lookup_label": "haproxy",
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
"certbot": {
|
||||
"email": CERTBOT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
|
|
@ -87,15 +87,15 @@ def test_parser_finds_services_changed_label():
|
|||
|
||||
assert {"www.somehost.com.br.pem":"Some PEM Certificate"} == cfg.certs
|
||||
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.letsencrypt_hosts
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_finds_services_raw():
|
||||
line_list = load_fixture("services")
|
||||
|
||||
result = {
|
||||
"customerrors": False,
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
"certbot": {
|
||||
"email": CERTBOT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
|
|
@ -117,7 +117,7 @@ def test_parser_finds_services_raw():
|
|||
"containers": [
|
||||
"my-stack_agent:9001"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
}
|
||||
},
|
||||
|
|
@ -134,14 +134,14 @@ def test_parser_finds_services_raw():
|
|||
"containers": [
|
||||
"my-stack_cadvisor:8080"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
},
|
||||
"node-exporter.quantum.example.org":{
|
||||
"containers": [
|
||||
"my-stack_node-exporter:9100"
|
||||
],
|
||||
"letsencrypt": True,
|
||||
"certbot": True,
|
||||
"redirect_ssl": False
|
||||
}
|
||||
},
|
||||
|
|
@ -158,14 +158,14 @@ def test_parser_finds_services_raw():
|
|||
"containers": [
|
||||
"my-stack_node-exporter:9100"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
},
|
||||
"www.somehost.com.br":{
|
||||
"containers": [
|
||||
"some-service:80"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
}
|
||||
},
|
||||
|
|
@ -187,7 +187,7 @@ def test_parser_finds_services_raw():
|
|||
"containers": [
|
||||
"some-service:80"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
}
|
||||
},
|
||||
|
|
@ -204,7 +204,7 @@ def test_parser_finds_services_raw():
|
|||
processed = list(cfg.parse(line_list))
|
||||
|
||||
assert parsed_object == processed
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.letsencrypt_hosts
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.certbot_hosts
|
||||
|
||||
|
||||
|
||||
|
|
@ -219,7 +219,7 @@ def test_parser_static():
|
|||
|
||||
with open(path + "/expected/static.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_static_raw():
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
|
|
@ -241,7 +241,7 @@ def test_parser_static_raw():
|
|||
"containers": [
|
||||
"container:5000"
|
||||
],
|
||||
"letsencrypt": True
|
||||
"certbot": True
|
||||
},
|
||||
"host2.com.br": {
|
||||
"containers": [
|
||||
|
|
@ -299,7 +299,7 @@ def test_parser_tcp():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/services-tcp.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_multi_containers():
|
||||
line_list = load_fixture("services-multi-containers")
|
||||
|
|
@ -318,7 +318,7 @@ def test_parser_multi_containers():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/services-multi-containers.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
|
||||
def test_parser_multiple_hosts():
|
||||
|
|
@ -340,7 +340,7 @@ def test_parser_multiple_hosts():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/services-multiple-hosts.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
|
||||
def test_parser_redirect_ssl():
|
||||
|
|
@ -361,7 +361,7 @@ def test_parser_redirect_ssl():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/services-redirect-ssl.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
|
||||
def test_parser_ssl_strict():
|
||||
|
|
@ -382,7 +382,7 @@ def test_parser_ssl_strict():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/ssl-strict.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_ssl_loose():
|
||||
line_list = load_fixture("no-services")
|
||||
|
|
@ -399,7 +399,7 @@ def test_parser_ssl_loose():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/ssl-loose.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
def test_parser_ssl_letsencrypt():
|
||||
line_list = load_fixture("services-letsencrypt")
|
||||
|
|
@ -409,8 +409,8 @@ def test_parser_ssl_letsencrypt():
|
|||
"stats": {
|
||||
"password": "password"
|
||||
},
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
"certbot": {
|
||||
"email": CERTBOT_EMAIL
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -421,7 +421,7 @@ def test_parser_ssl_letsencrypt():
|
|||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/services-letsencrypt.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert ["test.example.org"] == cfg.letsencrypt_hosts
|
||||
assert ["test.example.org"] == cfg.certbot_hosts
|
||||
|
||||
|
||||
def test_parser_finds_services_clone_to_ssl_raw():
|
||||
|
|
@ -429,8 +429,8 @@ def test_parser_finds_services_clone_to_ssl_raw():
|
|||
|
||||
result = {
|
||||
"customerrors": False,
|
||||
"letsencrypt": {
|
||||
"email": LETSENCRYPT_EMAIL
|
||||
"certbot": {
|
||||
"email": CERTBOT_EMAIL
|
||||
},
|
||||
"stats": {
|
||||
"port": 0
|
||||
|
|
@ -450,21 +450,21 @@ def test_parser_finds_services_clone_to_ssl_raw():
|
|||
"containers":[
|
||||
"10.152.183.215:8080"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
},
|
||||
"valida.me":{
|
||||
"containers":[
|
||||
"10.152.183.62:8080"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
},
|
||||
"www.valida.me":{
|
||||
"containers":[
|
||||
"10.152.183.62:8080"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
}
|
||||
},
|
||||
|
|
@ -481,7 +481,7 @@ def test_parser_finds_services_clone_to_ssl_raw():
|
|||
"containers":[
|
||||
"10.152.183.215:8080"
|
||||
],
|
||||
"letsencrypt": False,
|
||||
"certbot": False,
|
||||
"redirect_ssl": False
|
||||
}
|
||||
},
|
||||
|
|
@ -496,12 +496,12 @@ def test_parser_finds_services_clone_to_ssl_raw():
|
|||
processed = list(cfg.parse(line_list))
|
||||
|
||||
assert parsed_object == processed
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
assert [] == cfg.certbot_hosts
|
||||
|
||||
|
||||
|
||||
#test_parser_finds_services_raw()
|
||||
#test_parser_tcp()
|
||||
#test_parser_multiple_hosts()
|
||||
#test_parser_ssl_letsencrypt()
|
||||
#test_parser_ssl_certbot()
|
||||
#test_parser_finds_services()
|
||||
|
|
@ -15,7 +15,7 @@ def test_processor_static():
|
|||
"containers":[
|
||||
"container:5000"
|
||||
],
|
||||
"letsencrypt": True
|
||||
"certbot": True
|
||||
},
|
||||
"host2.com.br":{
|
||||
"containers":[
|
||||
|
|
@ -57,7 +57,7 @@ def test_processor_static():
|
|||
'host3.com.br:8080'
|
||||
]
|
||||
|
||||
assert static.get_letsencrypt_hosts() is None
|
||||
assert static.get_certbot_hosts() is None
|
||||
assert static.get_parsed_object() == parsed_object
|
||||
assert static.get_hosts() == hosts
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ def test_processor_static():
|
|||
assert haproxy_cfg == Functions.load(os.path.join(os.path.dirname(os.path.realpath(__file__)), "./expected/static.txt"))
|
||||
|
||||
# @todo: Static doesnt populate this fields
|
||||
assert static.get_letsencrypt_hosts() == []
|
||||
assert static.get_certbot_hosts() == []
|
||||
assert static.get_parsed_object() == parsed_object
|
||||
assert static.get_hosts() == hosts
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue