Add test clear text input message with PGP markers
It's possible to trick Lacre by sending PGP markers in message body, causing it to classify that message being already encrypted. This test case is used to reproduce this scenario.
This commit is contained in:
parent
b91501d3dd
commit
b4f30d7e8f
4 changed files with 28 additions and 10 deletions
|
@ -72,7 +72,7 @@ def _report_result(message_file, expected, test_output):
|
|||
else:
|
||||
status = "Failure"
|
||||
|
||||
print(message_file.ljust(30), status)
|
||||
print(message_file.ljust(35), status)
|
||||
|
||||
|
||||
def _execute_case(config, case_name):
|
||||
|
@ -107,7 +107,7 @@ def _main():
|
|||
|
||||
server = _spawn([python, "-m", "lacre.daemon"])
|
||||
|
||||
for case_no in range(1, conf.getint("tests", "cases")):
|
||||
for case_no in range(1, conf.getint("tests", "cases") + 1):
|
||||
_execute_case(conf, case_name=f"case-{case_no}")
|
||||
|
||||
_interrupt(server)
|
||||
|
|
|
@ -30,7 +30,7 @@ certs: test/certs
|
|||
|
||||
[tests]
|
||||
# Number of "test-*" sections in this file, describing test cases.
|
||||
cases: 8
|
||||
cases: 9
|
||||
e2e_log: test/logs/e2e.log
|
||||
e2e_log_format: %(asctime)s %(pathname)s:%(lineno)d %(levelname)s [%(funcName)s] %(message)s
|
||||
e2e_log_datefmt: %Y-%m-%d %H:%M:%S
|
||||
|
@ -84,3 +84,9 @@ descr: Clear text message to address with delimiter and a user with an Ed25519 k
|
|||
to: bob@disposlab
|
||||
in: test/msgin/clear2ed-delim.msg
|
||||
out: -----BEGIN PGP MESSAGE-----
|
||||
|
||||
[case-9]
|
||||
descr: Clear text message with inline PGP markers to recipient without a key.
|
||||
to: carlos@disposlab
|
||||
in: test/msgin/with-markers2clear.msg
|
||||
out: This message includes inline PGP markers.
|
||||
|
|
|
@ -83,12 +83,13 @@ def _load_file(name):
|
|||
|
||||
def _report_result(message_file, expected, test_output):
|
||||
status = None
|
||||
if expected in test_output:
|
||||
expected_line = "\r\n" + expected # + "\r\n"
|
||||
if expected_line in test_output:
|
||||
status = "Success"
|
||||
else:
|
||||
status = "Failure"
|
||||
|
||||
print(message_file.ljust(30), status)
|
||||
print(message_file.ljust(35), status)
|
||||
|
||||
|
||||
def _execute_e2e_test(case_name, config, config_path):
|
||||
|
@ -154,12 +155,12 @@ logging.basicConfig(filename = config.get("tests", "e2e_log"),
|
|||
config_path = os.getcwd() + "/" + CONFIG_FILE
|
||||
|
||||
_write_test_config(config_path,
|
||||
port = config.get("relay", "port"),
|
||||
gpg_keyhome = config.get("dirs", "keys"),
|
||||
smime_certpath = config.get("dirs", "certs"),
|
||||
log_config = config.get("tests", "log_config"))
|
||||
port = config.get("relay", "port"),
|
||||
gpg_keyhome = config.get("dirs", "keys"),
|
||||
smime_certpath = config.get("dirs", "certs"),
|
||||
log_config = config.get("tests", "log_config"))
|
||||
|
||||
for case_no in range(1, config.getint("tests", "cases")+1):
|
||||
for case_no in range(1, config.getint("tests", "cases") + 1):
|
||||
case_name = f"case-{case_no}"
|
||||
logging.info(f"Executing {case_name}: {config.get(case_name, 'descr')}")
|
||||
|
||||
|
|
11
test/msgin/with-markers2clear.msg
Normal file
11
test/msgin/with-markers2clear.msg
Normal file
|
@ -0,0 +1,11 @@
|
|||
From: Dave <dave@localhost>
|
||||
To: Carlos <carlos@localhost>
|
||||
Subject: Test
|
||||
|
||||
This message includes inline PGP markers.
|
||||
It's enough to include these two lines:
|
||||
|
||||
-----BEGIN PGP MESSAGE-----
|
||||
-----END PGP MESSAGE-----
|
||||
|
||||
Test logs will give a hint which path this message takes.
|
Loading…
Reference in a new issue