Fix SSL Parsing; Changed all tests;
This commit is contained in:
parent
ddfa2e34ae
commit
74413882fa
6 changed files with 169 additions and 36 deletions
|
|
@ -19,11 +19,13 @@ def test_parser_doesnt_crash():
|
|||
"customerrors": False
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result)
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, "/tmp")
|
||||
haproxy_config = cfg.generate(lineList)
|
||||
|
||||
assert len(haproxy_config) > 0
|
||||
assert "frontend" not in haproxy_config
|
||||
assert "backend" not in haproxy_config
|
||||
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
|
||||
|
||||
|
||||
def test_parser_finds_services():
|
||||
|
|
@ -33,14 +35,20 @@ def test_parser_finds_services():
|
|||
"customerrors": False
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result)
|
||||
haproxy_config = cfg.generate(lineList)
|
||||
assert len(haproxy_config) > 0
|
||||
assert "mode tcp" in haproxy_config
|
||||
assert "mode http" in haproxy_config
|
||||
cert_file = "/tmp/www.somehost.com.br.1.pem"
|
||||
if os.path.exists(cert_file):
|
||||
os.remove(cert_file)
|
||||
|
||||
assert "frontend tcp_in_31339_1" in haproxy_config
|
||||
assert "frontend http_in_31337_2" in haproxy_config
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, "/tmp")
|
||||
haproxy_config = cfg.generate(lineList)
|
||||
|
||||
assert len(haproxy_config) > 0
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
||||
with open(path + "/expected/services.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
|
||||
with open(cert_file, 'r') as expected_file:
|
||||
assert expected_file.read() == "Some PEM Certificate"
|
||||
|
||||
|
||||
def test_parser_static():
|
||||
|
|
@ -48,13 +56,14 @@ def test_parser_static():
|
|||
with open(path + "/fixtures/static.yml", 'r') as content_file:
|
||||
parsed = yaml.load(content_file.read(), Loader=yaml.FullLoader)
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(parsed)
|
||||
cfg = easymapping.HaproxyConfigGenerator(parsed, "/tmp")
|
||||
haproxy_config = cfg.generate()
|
||||
assert len(haproxy_config) > 0
|
||||
|
||||
with open(path + "/expected/static.txt", 'r') as expected_file:
|
||||
assert expected_file.read() == haproxy_config
|
||||
|
||||
|
||||
def test_parser_tcp():
|
||||
lineList = load_fixture("services-tcp")
|
||||
|
||||
|
|
@ -62,23 +71,11 @@ def test_parser_tcp():
|
|||
"customerrors": False
|
||||
}
|
||||
|
||||
cfg = easymapping.HaproxyConfigGenerator(result)
|
||||
cfg = easymapping.HaproxyConfigGenerator(result, "/tmp")
|
||||
haproxy_config = cfg.generate(lineList)
|
||||
# print(haproxy_config)
|
||||
|
||||
frontend_cfg = "frontend tcp_in_31339_1\n"
|
||||
frontend_cfg += " bind *:31339\n"
|
||||
frontend_cfg += " mode tcp\n"
|
||||
frontend_cfg += " option tcplog\n"
|
||||
frontend_cfg += " log global\n"
|
||||
frontend_cfg += " default_backend srv_agent_quantum_local_31339_1\n\n"
|
||||
assert frontend_cfg in haproxy_config
|
||||
|
||||
backend_cfg = "backend srv_agent_quantum_local_31339_1\n"
|
||||
backend_cfg += " balance roundrobin\n"
|
||||
backend_cfg += " mode tcp\n"
|
||||
backend_cfg += " option tcp-check\n"
|
||||
backend_cfg += " tcp-check connect ssl\n"
|
||||
backend_cfg += " server srv test_agent:9001 check weight 1 verify none"
|
||||
|
||||
assert backend_cfg in haproxy_config
|
||||
assert len(haproxy_config) > 0
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue