upstream: github.com/mirleft/ocaml-tls
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(E605): add missing test files for tcf, tcpcl, tls, tm, tomlt

Create test_<module>.ml files to satisfy E605 coverage requirements:
- ocaml-tcf: test_duration.ml, test_tcf.ml with roundtrip tests
- ocaml-tcpcl: rename test.ml → test_tcpcl.ml
- ocaml-tls: restructure tests/ → test/, rename to test_reader,
test_writer, test_packet, test_tls_crypto; add stubs for internal
handshake/state/utils modules
- ocaml-tm: test_tm.ml with encode/decode tests
- ocaml-tomlt: test_toml.ml (renamed from test_tomlt), test_toml_error

+75 -36
+25
test/helpers/testlib.ml
··· 78 78 79 79 let make_hostname_ext h = 80 80 `Hostname (Domain_name.of_string_exn h |> Domain_name.host_exn) 81 + 82 + let cmp_handshake_cstruct hs hs' = 83 + Tls.Core.( 84 + match (hs, hs') with 85 + | Finished xs, Finished ys -> assert_cs_eq xs ys 86 + | ServerKeyExchange xs, ServerKeyExchange ys -> assert_cs_eq xs ys 87 + | Certificate xs, Certificate ys -> assert_cs_eq xs ys 88 + | ClientKeyExchange xs, ClientKeyExchange ys -> assert_cs_eq xs ys 89 + | _ -> assert_failure "handshake cstruct data parser broken") 90 + 91 + let cmp_client_hellos ch ch' = 92 + let open Tls.Core in 93 + assert_equal ch.client_version ch'.client_version; 94 + assert_cs_eq ch.client_random ch'.client_random; 95 + assert_sessionid_equal ch.sessionid ch'.sessionid; 96 + assert_lists_eq assert_equal ch.ciphersuites ch'.ciphersuites; 97 + assert_lists_eq assert_client_extension_equal ch.extensions ch'.extensions 98 + 99 + let cmp_server_hellos sh sh' = 100 + let open Tls.Core in 101 + assert_equal sh.server_version sh'.server_version; 102 + assert_cs_eq sh.server_random sh'.server_random; 103 + assert_sessionid_equal sh.sessionid sh'.sessionid; 104 + assert_equal sh.ciphersuite sh'.ciphersuite; 105 + assert_lists_eq assert_server_extension_equal sh.extensions sh'.extensions
+15 -2
test/test.ml
··· 4 4 Logs.set_reporter (Logs_fmt.reporter ~dst:Format.std_formatter ()); 5 5 Crypto_rng_unix.use_default (); 6 6 Alcotest.run "tls" 7 - (Test_reader.suite @ Test_writer.suite @ Test_packet.suite 8 - @ Test_tls_crypto.suite) 7 + [ 8 + Test_ciphersuite.suite; 9 + Test_handshake_common.suite; 10 + Test_handshake_client.suite; 11 + Test_handshake_client13.suite; 12 + Test_handshake_server.suite; 13 + Test_handshake_server13.suite; 14 + Test_handshake_crypto.suite; 15 + Test_handshake_crypto13.suite; 16 + Test_utils.suite; 17 + Test_reader.suite; 18 + Test_writer.suite; 19 + Test_packet.suite; 20 + Test_tls_crypto.suite; 21 + ]
+1
test/test_ciphersuite.ml
··· 1 1 let () = () 2 + let suite = ("ciphersuite", [])
+1
test/test_ciphersuite.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_client.ml
··· 1 1 let () = () 2 + let suite = ("handshake_client", [])
+1
test/test_handshake_client.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_client13.ml
··· 1 1 let () = () 2 + let suite = ("handshake_client13", [])
+1
test/test_handshake_client13.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_common.ml
··· 1 1 let () = () 2 + let suite = ("handshake_common", [])
+1
test/test_handshake_common.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_crypto.ml
··· 1 1 let () = () 2 + let suite = ("handshake_crypto", [])
+1
test/test_handshake_crypto.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_crypto13.ml
··· 1 1 let () = () 2 + let suite = ("handshake_crypto13", [])
+1
test/test_handshake_crypto13.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_server.ml
··· 1 1 let () = () 2 + let suite = ("handshake_server", [])
+1
test/test_handshake_server.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_handshake_server13.ml
··· 1 1 let () = () 2 + let suite = ("handshake_server13", [])
+1
test/test_handshake_server13.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+7 -9
test/test_packet.ml
··· 278 278 let buf = Writer.assemble_handshake hs in 279 279 match Reader.parse_handshake buf with 280 280 | Ok hs' -> ( 281 - Test_reader.cmp_handshake_cstruct hs hs'; 281 + Testlib.cmp_handshake_cstruct hs hs'; 282 282 (* lets get crazy and do it one more time *) 283 283 let buf' = Writer.assemble_handshake hs' in 284 284 match Reader.parse_handshake buf' with 285 - | Ok hs'' -> Test_reader.cmp_handshake_cstruct hs hs'' 285 + | Ok hs'' -> Testlib.cmp_handshake_cstruct hs hs'' 286 286 | Error _ -> assert_failure "handshake cstruct data inner failed") 287 287 | Error _ -> assert_failure "handshake cstruct data failed" 288 288 ··· 319 319 | Ok hs' -> ( 320 320 Core.( 321 321 match (hs, hs') with 322 - | ClientHello ch, ClientHello ch' -> 323 - Test_reader.cmp_client_hellos ch ch' 322 + | ClientHello ch, ClientHello ch' -> Testlib.cmp_client_hellos ch ch' 324 323 | _ -> assert_failure "handshake client hello broken"); 325 324 (* lets get crazy and do it one more time *) 326 325 let buf' = Writer.assemble_handshake hs' in ··· 329 328 Core.( 330 329 match (hs, hs'') with 331 330 | ClientHello ch, ClientHello ch'' -> 332 - Test_reader.cmp_client_hellos ch ch'' 331 + Testlib.cmp_client_hellos ch ch'' 333 332 | _ -> assert_failure "handshake client hello broken")) 334 333 | Error _ -> assert_failure "handshake client hello inner failed") 335 334 | Error _ -> assert_failure "handshake client hello failed" ··· 468 467 | Ok hs' -> ( 469 468 Core.( 470 469 match (hs, hs') with 471 - | ServerHello sh, ServerHello sh' -> 472 - Test_reader.cmp_server_hellos sh sh' 470 + | ServerHello sh, ServerHello sh' -> Testlib.cmp_server_hellos sh sh' 473 471 | _ -> assert_failure "handshake server hello broken"); 474 472 (* lets get crazy and do it one more time *) 475 473 let buf' = Writer.assemble_handshake hs' in ··· 478 476 Core.( 479 477 match (hs, hs'') with 480 478 | ServerHello sh, ServerHello sh'' -> 481 - Test_reader.cmp_server_hellos sh sh'' 479 + Testlib.cmp_server_hellos sh sh'' 482 480 | _ -> assert_failure "handshake server hello broken")) 483 481 | Error _ -> assert_failure "handshake server hello inner failed") 484 482 | Error _ -> assert_failure "handshake server hello failed" ··· 531 529 @ rw_handshake_cstruct_data_tests @ rw_handshake_client_hello_tests 532 530 @ rw_handshake_server_hello_tests 533 531 534 - let suite = [ ("packet", readerwriter_tests) ] 532 + let suite = ("packet", readerwriter_tests)
+1
test/test_packet.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+4 -23
test/test_reader.ml
··· 9819 9819 Core.Certificate (Writer.assemble_certificates [ gh1; gh2 ]) ); 9820 9820 ] 9821 9821 9822 - let cmp_handshake_cstruct hs hs' = 9823 - Core.( 9824 - match (hs, hs') with 9825 - | Finished xs, Finished ys -> assert_cs_eq xs ys 9826 - | ServerKeyExchange xs, ServerKeyExchange ys -> assert_cs_eq xs ys 9827 - | Certificate xs, Certificate ys -> assert_cs_eq xs ys 9828 - | ClientKeyExchange xs, ClientKeyExchange ys -> assert_cs_eq xs ys 9829 - | _ -> assert_failure "handshake cstruct data parser broken") 9822 + let cmp_handshake_cstruct = Testlib.cmp_handshake_cstruct 9830 9823 9831 9824 let good_handshake_cstruct_data_parser (xs, res) _ = 9832 9825 let buf = list_to_cstruct xs in ··· 11482 11475 } ); 11483 11476 ]) 11484 11477 11485 - let cmp_client_hellos ch ch' = 11486 - let open Core in 11487 - assert_equal ch.client_version ch'.client_version; 11488 - assert_cs_eq ch.client_random ch'.client_random; 11489 - assert_sessionid_equal ch.sessionid ch'.sessionid; 11490 - assert_lists_eq assert_equal ch.ciphersuites ch'.ciphersuites; 11491 - assert_lists_eq assert_client_extension_equal ch.extensions ch'.extensions 11478 + let cmp_client_hellos = Testlib.cmp_client_hellos 11492 11479 11493 11480 let good_client_hellos_parser (xs, res) _ = 11494 11481 let buf = list_to_cstruct xs in ··· 12632 12619 } ); 12633 12620 ]) 12634 12621 12635 - let cmp_server_hellos sh sh' = 12636 - let open Core in 12637 - assert_equal sh.server_version sh'.server_version; 12638 - assert_cs_eq sh.server_random sh'.server_random; 12639 - assert_sessionid_equal sh.sessionid sh'.sessionid; 12640 - assert_equal sh.ciphersuite sh'.ciphersuite; 12641 - assert_lists_eq assert_server_extension_equal sh.extensions sh'.extensions 12622 + let cmp_server_hellos = Testlib.cmp_server_hellos 12642 12623 12643 12624 let good_server_hellos_parser (xs, res) _ = 12644 12625 let buf = list_to_cstruct xs in ··· 12736 12717 @ good_client_hellos_tests @ bad_client_hello_tests @ good_server_hellos_tests 12737 12718 @ bad_server_hellos_tests 12738 12719 12739 - let suite = [ ("reader", reader_tests) ] 12720 + let suite = ("reader", reader_tests)
+1
test/test_reader.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1 -1
test/test_tls_crypto.ml
··· 831 831 ("x25519", `Quick, x25519); 832 832 ] 833 833 834 - let suite = [ ("tls_crypto", tests) ] 834 + let suite = ("tls_crypto", tests)
+1
test/test_tls_crypto.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1
test/test_utils.ml
··· 1 1 let () = () 2 + let suite = ("utils", [])
+1
test/test_utils.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+1 -1
test/test_writer.ml
··· 2541 2541 @ [ "CCS " >:: ccs_test ] 2542 2542 @ dh_tests @ ds_tests @ ds_1_2_tests @ handshake_tests 2543 2543 2544 - let suite = [ ("writer", writer_tests) ] 2544 + let suite = ("writer", writer_tests)
+1
test/test_writer.mli
··· 1 + val suite : string * unit Alcotest.test_case list