First part letsencrypt
This commit is contained in:
parent
08c38e5f8a
commit
10ed037d94
20 changed files with 222 additions and 45 deletions
|
|
@ -26,7 +26,7 @@ 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
|
||||
|
||||
def test_parser_finds_services():
|
||||
line_list = load_fixture("services")
|
||||
|
|
@ -50,6 +50,8 @@ def test_parser_finds_services():
|
|||
with open(cert_file, 'r') as expected_file:
|
||||
assert expected_file.read() == "Some PEM Certificate"
|
||||
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.letsencrypt_hosts
|
||||
|
||||
def test_parser_finds_services_changed_label():
|
||||
line_list = load_fixture("services-changed-label")
|
||||
|
||||
|
|
@ -73,6 +75,8 @@ def test_parser_finds_services_changed_label():
|
|||
with open(cert_file, 'r') as expected_file:
|
||||
assert expected_file.read() == "Some PEM Certificate"
|
||||
|
||||
assert ['node-exporter.quantum.example.org'] == cfg.letsencrypt_hosts
|
||||
|
||||
def test_parser_finds_services_raw():
|
||||
line_list = load_fixture("services")
|
||||
|
||||
|
|
@ -92,9 +96,12 @@ def test_parser_finds_services_raw():
|
|||
"health-check":"",
|
||||
"port":"31339",
|
||||
"hosts":{
|
||||
"agent.quantum.example.org":[
|
||||
"my-stack_agent:9001"
|
||||
]
|
||||
"agent.quantum.example.org": {
|
||||
"containers": [
|
||||
"my-stack_agent:9001"
|
||||
],
|
||||
"letsencrypt": False
|
||||
}
|
||||
},
|
||||
"redirect":{
|
||||
|
||||
|
|
@ -105,12 +112,18 @@ def test_parser_finds_services_raw():
|
|||
"health-check":"",
|
||||
"port":"31337",
|
||||
"hosts":{
|
||||
"cadvisor.quantum.example.org":[
|
||||
"my-stack_cadvisor:8080"
|
||||
],
|
||||
"node-exporter.quantum.example.org":[
|
||||
"my-stack_node-exporter:9100"
|
||||
]
|
||||
"cadvisor.quantum.example.org":{
|
||||
"containers": [
|
||||
"my-stack_cadvisor:8080"
|
||||
],
|
||||
"letsencrypt": False
|
||||
},
|
||||
"node-exporter.quantum.example.org":{
|
||||
"containers": [
|
||||
"my-stack_node-exporter:9100"
|
||||
],
|
||||
"letsencrypt": True
|
||||
}
|
||||
},
|
||||
"redirect":{
|
||||
|
||||
|
|
@ -121,9 +134,12 @@ def test_parser_finds_services_raw():
|
|||
"health-check":"",
|
||||
"port":"80",
|
||||
"hosts":{
|
||||
"www.somehost.com.br":[
|
||||
"some-service:80"
|
||||
]
|
||||
"www.somehost.com.br":{
|
||||
"containers": [
|
||||
"some-service:80"
|
||||
],
|
||||
"letsencrypt": False
|
||||
}
|
||||
},
|
||||
"redirect":{
|
||||
"somehost.com.br":"https://www.somehost.com.br",
|
||||
|
|
@ -138,9 +154,12 @@ def test_parser_finds_services_raw():
|
|||
"health-check":"",
|
||||
"port":"443",
|
||||
"hosts":{
|
||||
"www.somehost.com.br":[
|
||||
"some-service:80"
|
||||
]
|
||||
"www.somehost.com.br":{
|
||||
"containers": [
|
||||
"some-service:80"
|
||||
],
|
||||
"letsencrypt": False
|
||||
}
|
||||
},
|
||||
"redirect":{
|
||||
"somehost.com.br":"https://www.somehost.com.br",
|
||||
|
|
@ -156,6 +175,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
|
||||
|
||||
|
||||
|
||||
|
|
@ -170,6 +190,66 @@ def test_parser_static():
|
|||
|
||||
with open(path + "/expected/static.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
assert [] == cfg.letsencrypt_hosts
|
||||
|
||||
def test_parser_static_raw():
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/fixtures/static.yml", 'r') as content_file:
|
||||
parsed = yaml.load(content_file.read(), Loader=yaml.FullLoader)
|
||||
|
||||
expected = {
|
||||
"stats": {
|
||||
"username": "admin",
|
||||
"password": "test123",
|
||||
"port": 1936
|
||||
},
|
||||
"customerrors": True,
|
||||
"easymapping": [
|
||||
{
|
||||
"port": 80,
|
||||
"hosts": {
|
||||
"host1.com.br": {
|
||||
"containers": [
|
||||
"container:5000"
|
||||
],
|
||||
"letsencrypt": True
|
||||
},
|
||||
"host2.com.br": {
|
||||
"containers": [
|
||||
"other:3000"
|
||||
]
|
||||
}
|
||||
},
|
||||
"redirect": {
|
||||
"www.host1.com.br": "http://host1.com.br"
|
||||
}
|
||||
},
|
||||
{
|
||||
"port": 443,
|
||||
"ssl_cert": "/etc/haproxy/certs/mycert.pem",
|
||||
"hosts": {
|
||||
"host1.com.br": {
|
||||
"containers": [
|
||||
"container:80"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"port": 8080,
|
||||
"hosts": {
|
||||
"host3.com.br": {
|
||||
"containers": [
|
||||
"domain:8181"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
assert expected == parsed
|
||||
|
||||
|
||||
|
||||
def test_parser_tcp():
|
||||
|
|
@ -187,6 +267,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
|
||||
|
||||
def test_parser_multi_containers():
|
||||
line_list = load_fixture("services-multi-containers")
|
||||
|
|
@ -202,6 +283,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
|
||||
|
||||
|
||||
#test_parser_finds_services_raw()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue