From bbf89cdd79adea06796c25920572328a0b9c1d9a Mon Sep 17 00:00:00 2001 From: Justin Lee Date: Wed, 20 Sep 2017 21:18:28 -0500 Subject: [PATCH] Add unit test for environment variable HAPROXY templates --- tests/test_marathon_lb.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_marathon_lb.py b/tests/test_marathon_lb.py index 85d0a5d1..e88b7591 100644 --- a/tests/test_marathon_lb.py +++ b/tests/test_marathon_lb.py @@ -98,6 +98,38 @@ def test_config_no_apps(self): bind *:9091 mode http +frontend marathon_https_in + bind *:443 ssl crt /etc/ssl/cert.pem + mode http +''' + print("actual config:\n") + print(config) + self.assertMultiLineEqual(config, expected) + + def test_config_env_template(self): + apps = dict() + groups = ['external'] + bind_http_https = True + ssl_certs = "" + os.environ["HAPROXY_HTTP_FRONTEND_HEAD"] = ''' +frontend changed_frontend + bind *:80 + mode http + ''' + templater = marathon_lb.ConfigTemplater() + del os.environ["HAPROXY_HTTP_FRONTEND_HEAD"] + + config = marathon_lb.config(apps, groups, bind_http_https, + ssl_certs, templater) + expected = self.base_config + ''' +frontend changed_frontend + bind *:80 + mode http + +frontend marathon_http_appid_in + bind *:9091 + mode http + frontend marathon_https_in bind *:443 ssl crt /etc/ssl/cert.pem mode http