50 lines
1.5 KiB
Python
50 lines
1.5 KiB
Python
from pathlib import Path
|
|
import runpy
|
|
|
|
|
|
SCRIPT = runpy.run_path(
|
|
str(Path(__file__).parents[2] / "scripts" / "drosync-poc-acceptance.py"),
|
|
run_name="drosync_poc_acceptance",
|
|
)
|
|
|
|
|
|
def test_acceptance_status_requires_audit() -> None:
|
|
acceptance_status = SCRIPT["acceptance_status"]
|
|
|
|
assert acceptance_status("https", False) == "FAIL"
|
|
assert acceptance_status("http", False) == "FAIL"
|
|
|
|
|
|
def test_acceptance_status_only_enforces_https_in_strict_mode() -> None:
|
|
acceptance_status = SCRIPT["acceptance_status"]
|
|
|
|
assert acceptance_status("http", True) == "PASS"
|
|
assert acceptance_status("http", True, True) == "BLOCKED_EXTERNAL"
|
|
assert acceptance_status("https", True, True) == "PASS"
|
|
assert acceptance_status("https", True) == "PASS"
|
|
|
|
|
|
def test_transport_security_records_http_as_an_accepted_risk() -> None:
|
|
transport_security = SCRIPT["transport_security"]
|
|
|
|
evidence = transport_security("http://poc.example.com", False)
|
|
assert evidence == {
|
|
"status": "PASS",
|
|
"scheme": "http",
|
|
"encrypted": False,
|
|
"requireHttps": False,
|
|
"acceptedRisk": "control-plane credentials and metadata use an unencrypted HTTP connection",
|
|
}
|
|
|
|
|
|
def test_transport_security_rejects_http_in_strict_mode() -> None:
|
|
transport_security = SCRIPT["transport_security"]
|
|
external_block = SCRIPT["ExternalBlock"]
|
|
|
|
try:
|
|
transport_security("http://poc.example.com", True)
|
|
except external_block:
|
|
pass
|
|
else:
|
|
raise AssertionError("strict transport policy accepted HTTP")
|