Fixed cfg runtime entry in test

This commit is contained in:
GeorgianaElena
2019-02-11 11:13:22 +02:00
parent 3ee387cd3b
commit 03b4c6218b
2 changed files with 21 additions and 3 deletions

View File

@@ -2,3 +2,4 @@ pytest
pytest-cov pytest-cov
codecov codecov
pytoml pytoml
passlib

View File

@@ -27,13 +27,19 @@ def test_default_config(tmpdir, tljh_dir):
print(toml_cfg) print(toml_cfg)
cfg = toml.loads(toml_cfg) cfg = toml.loads(toml_cfg)
assert cfg["defaultEntryPoints"] == ["http"] 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"] == { assert cfg["entryPoints"] == {
"http": {"address": ":80"}, "http": {"address": ":80"},
"auth_api": { "auth_api": {
"address": ":8099", "address": ":8099",
"auth": { "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) cfg = toml.loads(toml_cfg)
assert cfg["defaultEntryPoints"] == ["http", "https"] assert cfg["defaultEntryPoints"] == ["http", "https"]
assert "acme" in cfg 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"] == { assert cfg["entryPoints"] == {
"http": {"address": ":80", "redirect": {"entryPoint": "https"}}, "http": {"address": ":80", "redirect": {"entryPoint": "https"}},
"https": {"address": ":443", "tls": {}}, "https": {"address": ":443", "tls": {}},
"auth_api": { "auth_api": {
"address": ":8099", "address": ":8099",
"auth": { "auth": {
"basic": {"users": ["api_admin:$apr1$eS/j3kum$q/X2khsIEG/bBGsteP.x./"]} "basic": {"users": [""]}
}, },
"whiteList": {"sourceRange": ["127.0.0.1"]}
}, },
} }
assert cfg["acme"] == { assert cfg["acme"] == {
@@ -91,6 +103,10 @@ def test_manual_ssl_config(tljh_dir):
cfg = toml.loads(toml_cfg) cfg = toml.loads(toml_cfg)
assert cfg["defaultEntryPoints"] == ["http", "https"] assert cfg["defaultEntryPoints"] == ["http", "https"]
assert "acme" not in cfg 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"] == { assert cfg["entryPoints"] == {
"http": {"address": ":80", "redirect": {"entryPoint": "https"}}, "http": {"address": ":80", "redirect": {"entryPoint": "https"}},
"https": { "https": {
@@ -104,7 +120,8 @@ def test_manual_ssl_config(tljh_dir):
"auth_api": { "auth_api": {
"address": ":8099", "address": ":8099",
"auth": { "auth": {
"basic": {"users": ["api_admin:$apr1$eS/j3kum$q/X2khsIEG/bBGsteP.x./"]} "basic": {"users": [""]}
}, },
"whiteList": {"sourceRange": ["127.0.0.1"]}
}, },
} }