From 03b4c6218b71297f13240301b17eb0dabdcd33cd Mon Sep 17 00:00:00 2001 From: GeorgianaElena Date: Mon, 11 Feb 2019 11:13:22 +0200 Subject: [PATCH] Fixed cfg runtime entry in test --- dev-requirements.txt | 1 + tests/test_traefik.py | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index fd93238..292131f 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -2,3 +2,4 @@ pytest pytest-cov codecov pytoml +passlib diff --git a/tests/test_traefik.py b/tests/test_traefik.py index 302b9e6..3480c0e 100644 --- a/tests/test_traefik.py +++ b/tests/test_traefik.py @@ -27,13 +27,19 @@ def test_default_config(tmpdir, tljh_dir): print(toml_cfg) cfg = toml.loads(toml_cfg) assert cfg["defaultEntryPoints"] == ["http"] + assert len(cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"]) == 1 + assert cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"][0].startswith("api_admin") + # runtime generated entry, value not testable + cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"] = [""] + assert cfg["entryPoints"] == { "http": {"address": ":80"}, "auth_api": { "address": ":8099", "auth": { - "basic": {"users": ["api_admin:$apr1$eS/j3kum$q/X2khsIEG/bBGsteP.x./"]} + "basic": {"users": [""]} }, + "whiteList": {"sourceRange": ["127.0.0.1"]} }, } @@ -57,14 +63,20 @@ def test_letsencrypt_config(tljh_dir): cfg = toml.loads(toml_cfg) assert cfg["defaultEntryPoints"] == ["http", "https"] assert "acme" in cfg + assert len(cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"]) == 1 + assert cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"][0].startswith("api_admin") + # runtime generated entry, value not testable + cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"] = [""] + assert cfg["entryPoints"] == { "http": {"address": ":80", "redirect": {"entryPoint": "https"}}, "https": {"address": ":443", "tls": {}}, "auth_api": { "address": ":8099", "auth": { - "basic": {"users": ["api_admin:$apr1$eS/j3kum$q/X2khsIEG/bBGsteP.x./"]} + "basic": {"users": [""]} }, + "whiteList": {"sourceRange": ["127.0.0.1"]} }, } assert cfg["acme"] == { @@ -91,6 +103,10 @@ def test_manual_ssl_config(tljh_dir): cfg = toml.loads(toml_cfg) assert cfg["defaultEntryPoints"] == ["http", "https"] assert "acme" not in cfg + assert len(cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"]) == 1 + assert cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"][0].startswith("api_admin") + # runtime generated entry, value not testable + cfg["entryPoints"]["auth_api"]["auth"]["basic"]["users"] = [""] assert cfg["entryPoints"] == { "http": {"address": ":80", "redirect": {"entryPoint": "https"}}, "https": { @@ -104,7 +120,8 @@ def test_manual_ssl_config(tljh_dir): "auth_api": { "address": ":8099", "auth": { - "basic": {"users": ["api_admin:$apr1$eS/j3kum$q/X2khsIEG/bBGsteP.x./"]} + "basic": {"users": [""]} }, + "whiteList": {"sourceRange": ["127.0.0.1"]} }, }