Skip to content

Commit

Permalink
tests - set log level to info and add edit_tls setting
Browse files Browse the repository at this point in the history
  • Loading branch information
fl0ppy-d1sk committed Jan 10, 2024
1 parent 3d2cbda commit 66b1c01
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions examples/kubernetes-tls/tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"kinds": ["kubernetes"],
"timeout": 60,
"delay": 120,
"tls_edit": false,
"tests": [
{
"type": "string",
Expand Down
1 change: 1 addition & 0 deletions src/common/confs/server-http/ssl-certificate-lua.conf
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ ssl_certificate_by_lua_block {
if not ok then
logger:log(ERR, "error while setting private key : " .. err)
else
logger:log(INFO, "certificate set by " .. plugin_id)
return true
end
end
Expand Down
2 changes: 1 addition & 1 deletion tests/DockerTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _setup_test(self):
Test.replace_in_file(
compose,
r"AUTO_LETS_ENCRYPT=yes",
"AUTO_LETS_ENCRYPT=yes\n - USE_LETS_ENCRYPT_STAGING=yes",
"AUTO_LETS_ENCRYPT=yes\n - USE_LETS_ENCRYPT_STAGING=yes\n - LOG_LEVEL=info",
)
Test.replace_in_file(compose, r"DISABLE_DEFAULT_SERVER=yes", "DISABLE_DEFAULT_SERVER=no")
for ex_domain, test_domain in self._domains.items():
Expand Down
1 change: 1 addition & 0 deletions tests/KubernetesTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def init():
"USE_PROXY_PROTOCOL": "yes",
"REAL_IP_FROM": "100.64.0.0/10 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8",
"REAL_IP_HEADER": "proxy_protocol",
"LOG_LEVEL": "info"
}
replace_env = {"API_WHITELIST_IP": "127.0.0.1/8 100.64.0.0/10 192.168.0.0/16 172.16.0.0/12 10.0.0.0/8"}
for yaml in data:
Expand Down
2 changes: 1 addition & 1 deletion tests/LinuxTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def _setup_test(self):
raise Exception("docker exec cp variables.env failed (test)")
proc = self.docker_exec(
self.__distro,
"echo '' >> /etc/bunkerweb/variables.env ; echo 'USE_LETS_ENCRYPT_STAGING=yes' >> /etc/bunkerweb/variables.env",
"echo '' >> /etc/bunkerweb/variables.env ; echo 'USE_LETS_ENCRYPT_STAGING=yes' >> /etc/bunkerweb/variables.env ; echo 'LOG_LEVEL=info' >> /etc/bunkerweb/variables.env",
)
if proc.returncode != 0:
raise (Exception("docker exec append variables.env failed (test)"))
Expand Down
1 change: 1 addition & 0 deletions tests/SwarmTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def init():
if "AUTO_LETS_ENCRYPT=yes" not in data["services"]["bunkerweb"]["environment"]:
data["services"]["bunkerweb"]["environment"].append("AUTO_LETS_ENCRYPT=yes")
data["services"]["bunkerweb"]["environment"].append("USE_LETS_ENCRYPT_STAGING=yes")
data["services"]["bunkerweb"]["environment"].append("LOG_LEVEL=info")
del data["services"]["bunkerweb"]["deploy"]["placement"]
with open(compose, "w") as f:
f.write(dump(data))
Expand Down
12 changes: 8 additions & 4 deletions tests/Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,13 @@ def __run_test(self, test):
ok = test["status"] == r.status_code
if ok and "tls" in test:
ex_tls = test["tls"]
for ex_domain, test_domain in self._domains.items():
if search(ex_domain, ex_tls):
ex_tls = sub(ex_domain, test_domain, ex_tls)
tls_edit = True
if "tls_edit" in test:
tls_edit = test["tls_edit"]
if tls_edit:
for ex_domain, test_domain in self._domains.items():
if search(ex_domain, ex_tls):
ex_tls = sub(ex_domain, test_domain, ex_tls)
connection = create_connection((urlparse(ex_url).netloc, 443))
context = SSLContext()
sock = context.wrap_socket(connection, server_hostname=urlparse(ex_url).netloc)
Expand All @@ -154,7 +158,7 @@ def __run_test(self, test):
x509 = crypto.load_certificate(crypto.FILETYPE_ASN1, cert)
if x509.get_subject().CN != ex_tls:
ok = False
log("TEST", "⚠️", f"wrong cert CN : {x509.get_subject().CN}")
log("TEST", "⚠️", f"wrong cert CN : {x509.get_subject().CN} != {ex_tls}")
return ok
except:
return False
Expand Down

0 comments on commit 66b1c01

Please sign in to comment.