-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtest_001_sni.py
More file actions
36 lines (28 loc) · 1.02 KB
/
test_001_sni.py
File metadata and controls
36 lines (28 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import pytest
from pyhttpd.conf import HttpdConf
class TestSNI:
LOG_FILE = "test_sni.log"
@pytest.fixture(autouse=True, scope="class")
def _class_scope(self, env):
conf = HttpdConf(env, extras={
"base":
f'CustomLog logs/{self.LOG_FILE} "%{{SSL_TLS_SNI}}x"'
})
conf.add_vhost_test1()
conf.install()
assert env.apache_restart() == 0
# tests sni escaped characters
def test_ssl_001_01(self, env):
log_path = os.path.join(env.server_logs_dir, self.LOG_FILE)
open(log_path, 'wb').close()
env.run(args=[
'openssl', 's_client',
'-connect', f"localhost:{env.https_port}",
'-servername', "httpd\x01\x0a2024\".org",
'-crlf', '-ign_eof'
], intext="GET / HTTP/1.1\n\n")
with open(log_path, 'rb') as f:
log_content = f.read()
assert b'httpd\x01\n2024' not in log_content, \
f"found unescaped characters in {self.LOG_FILE}.log"