Merge branch 'issue/41' into issue/43
This commit is contained in:
commit
812590d86c
46 changed files with 859 additions and 542 deletions
|
|
@ -1,147 +1,192 @@
|
|||
import pytest
|
||||
import os
|
||||
|
||||
from functions import Functions
|
||||
from processor import ContainerEnv
|
||||
from functions import Functions, ContainerEnv
|
||||
|
||||
|
||||
def test_container_env_empty():
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {"autoconfig": "",
|
||||
"eab_hmac_key": "",
|
||||
"eab_kid": "",
|
||||
"email": "",
|
||||
"server": False,
|
||||
"retry_count": 60}
|
||||
} == ContainerEnv.read()
|
||||
|
||||
# os.environ['CERTBOT_LOG_LEVEL'] = 'warn'
|
||||
|
||||
|
||||
def test_container_env_customerrors():
|
||||
os.environ['HAPROXY_CUSTOMERRORS'] = 'true'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": True,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": True,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {"autoconfig": "",
|
||||
"eab_hmac_key": "",
|
||||
"eab_kid": "",
|
||||
"email": "",
|
||||
"server": False,
|
||||
"retry_count": 60}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['HAPROXY_CUSTOMERRORS'] = ''
|
||||
|
||||
|
||||
def test_container_env_sslmode():
|
||||
os.environ['EASYHAPROXY_SSL_MODE'] = 'STRICT'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "strict",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": False,
|
||||
"ssl_mode": "strict",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {"autoconfig": "",
|
||||
"eab_hmac_key": "",
|
||||
"eab_kid": "",
|
||||
"email": "",
|
||||
"server": False,
|
||||
"retry_count": 60}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['EASYHAPROXY_SSL_MODE'] = ''
|
||||
|
||||
|
||||
def test_container_env_stats():
|
||||
os.environ['HAPROXY_USERNAME'] = 'abc'
|
||||
os.environ['HAPROXY_STATS_PORT'] = '2101'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {"autoconfig": "",
|
||||
"eab_hmac_key": "",
|
||||
"eab_kid": "",
|
||||
"email": "",
|
||||
"server": False,
|
||||
"retry_count": 60}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['HAPROXY_USERNAME'] = ''
|
||||
os.environ['HAPROXY_STATS_PORT'] = ''
|
||||
|
||||
|
||||
def test_container_env_stats_password():
|
||||
os.environ['HAPROXY_PASSWORD'] = 'xyz'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"stats": {
|
||||
"username": "admin",
|
||||
"password": "xyz",
|
||||
"port": "1936"
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"stats": {
|
||||
"username": "admin",
|
||||
"password": "xyz",
|
||||
"port": "1936"
|
||||
|
||||
},
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
},
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {"autoconfig": "",
|
||||
"eab_hmac_key": "",
|
||||
"eab_kid": "",
|
||||
"email": "",
|
||||
"server": False,
|
||||
"retry_count": 60}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['HAPROXY_PASSWORD'] = ''
|
||||
|
||||
|
||||
def test_container_env_stats_password():
|
||||
def test_container_env_stats_password_2():
|
||||
os.environ['HAPROXY_USERNAME'] = 'abc'
|
||||
os.environ['HAPROXY_STATS_PORT'] = '2101'
|
||||
os.environ['HAPROXY_PASSWORD'] = 'xyz'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"stats": {
|
||||
"username": "abc",
|
||||
"password": "xyz",
|
||||
"port": "2101"
|
||||
|
||||
},
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"stats": {
|
||||
"username": "abc",
|
||||
"password": "xyz",
|
||||
"port": "2101"
|
||||
},
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {"autoconfig": "",
|
||||
"eab_hmac_key": "",
|
||||
"eab_kid": "",
|
||||
"email": "",
|
||||
"server": False,
|
||||
"retry_count": 60}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['HAPROXY_USERNAME'] = ''
|
||||
os.environ['HAPROXY_STATS_PORT'] = ''
|
||||
os.environ['HAPROXY_PASSWORD'] = ''
|
||||
|
||||
|
||||
def test_container_env_stats_password():
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = 'acme@example.org'
|
||||
def test_container_env_certbot_email():
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = 'acme@example.org'
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"letsencrypt": {
|
||||
"email": "acme@example.org",
|
||||
"server": False
|
||||
},
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.DEBUG,
|
||||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {
|
||||
"autoconfig": "",
|
||||
'eab_hmac_key': "",
|
||||
'eab_kid': "",
|
||||
"email": "acme@example.org",
|
||||
"server": False,
|
||||
"retry_count": 60
|
||||
}
|
||||
} == 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_full():
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = 'acme@example.org'
|
||||
os.environ['EASYHAPROXY_CERTBOT_SERVER'] = 'schema://url/a'
|
||||
os.environ['EASYHAPROXY_CERTBOT_EAB_KID'] = 'eab_kid'
|
||||
os.environ['EASYHAPROXY_CERTBOT_EAB_HMAC_KEY'] = 'eab_hmac_key'
|
||||
os.environ['EASYHAPROXY_CERTBOT_RETRY_COUNT'] = "10"
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
|
|
@ -156,6 +201,14 @@ def test_container_env_letsencrypt():
|
|||
"haproxy": Functions.INFO,
|
||||
"certbot": Functions.DEBUG,
|
||||
},
|
||||
"certbot": {
|
||||
"autoconfig": "",
|
||||
"email": "acme@example.org",
|
||||
"server": "schema://url/a",
|
||||
'eab_hmac_key': 'eab_hmac_key',
|
||||
'eab_kid': 'eab_kid',
|
||||
'retry_count': 10
|
||||
}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['EASYHAPROXY_LETSENCRYPT_EMAIL'] = ''
|
||||
|
|
@ -166,16 +219,22 @@ def test_container_log_level():
|
|||
os.environ['HAPROXY_LOG_LEVEL'] = Functions.FATAL
|
||||
try:
|
||||
assert {
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.ERROR,
|
||||
"haproxy": Functions.FATAL,
|
||||
"certbot": Functions.TRACE,
|
||||
},
|
||||
} == ContainerEnv.read()
|
||||
"customerrors": False,
|
||||
"ssl_mode": "default",
|
||||
"lookup_label": "easyhaproxy",
|
||||
"logLevel": {
|
||||
"easyhaproxy": Functions.ERROR,
|
||||
"haproxy": Functions.FATAL,
|
||||
"certbot": Functions.TRACE,
|
||||
},
|
||||
"certbot": {
|
||||
"autoconfig": "",
|
||||
'eab_hmac_key': "",
|
||||
'eab_kid': "",
|
||||
"email": "acme@example.org",
|
||||
"server": False,
|
||||
"retry_count": 60
|
||||
}
|
||||
} == ContainerEnv.read()
|
||||
finally:
|
||||
os.environ['CERTBOT_LOG_LEVEL'] = ''
|
||||
os.environ['EASYHAPROXY_LOG_LEVEL'] = ''
|
||||
os.environ['HAPROXY_LOG_LEVEL'] = ''
|
||||
os.environ['EASYHAPROXY_CERTBOT_EMAIL'] = ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue