diff --git a/tests/test_forensics.py b/tests/test_forensics.py index c2fadec..dca5a35 100644 --- a/tests/test_forensics.py +++ b/tests/test_forensics.py @@ -415,6 +415,53 @@ def test_exif_cli_comment_only(): assert "Comment" in result.output assert "flag{comment_only}" in result.output +def test_adobe_xmp_extraction(): + """ + Verifies that get_metadata successfully parses XMP fields (like license resource). + """ + import struct + xmp_xml = ( + b"\n" + b"\n" + b" \n" + b" \n" + b" \n" + b"\n" + b"" + ) + xmp_prefix = b"http://ns.adobe.com/xap/1.0/\x00" + app1_payload = xmp_prefix + xmp_xml + app1_len = len(app1_payload) + 2 + mock_jpeg = ( + b"\xff\xd8" + b"\xff\xe1" + + struct.pack(">H", app1_len) + + app1_payload + + b"\xff\xd9" + ) + + test_file = TEST_ENV / "mock_xmp.jpg" + with open(test_file, "wb") as f: + f.write(mock_jpeg) + + meta = get_metadata(test_file) + assert meta.exif_data.get("cc:license") == "cGljb0NURnt0ZXN0X3htcF9mbGFnfQ==" + +def test_adobe_xmp_cli(): + """ + Verifies that the ctf inspect CLI prints the parsed XMP fields. + """ + from ctf.main import cli + runner = CliRunner() + test_file = TEST_ENV / "mock_xmp.jpg" + + result = runner.invoke(cli, ["inspect", "-e", str(test_file)]) + assert result.exit_code == 0 + assert "EXIF Metadata" in result.output + assert "cc:license" in result.output + assert "cGljb0NURnt0ZXN0X3htcF9mbGFnfQ==" in result.output + +