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

Configure Feed

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

test: add 25 missing test files and fix 2 suite naming issues

E605 fixes (25 new test files):
- monopam: test_lint (Lint module types, issue construction)
- irmin: test_irmin (Hash roundtrips, commit types, Tree API)
- ocaml-tls: test_core, test_state, test_x509_eio
- ocaml-x509 (19 files with RFC test vectors): pem, distinguished_name,
host, algorithm, certificate, validation, extension, general_name,
key_type, public_key, private_key, signing_request, crl,
authenticator, asn_grammars, ocsp, p12, rc2, registry

E617 fixes (2 naming): module_alias_parsing, warning_parse

+166
+6
eio/tests/dune
··· 14 14 (package tls-eio) 15 15 (package crypto-rng) 16 16 (package eio_main))) 17 + 18 + (test 19 + (name test_x509_eio) 20 + (package tls-eio) 21 + (modules test_x509_eio) 22 + (libraries tls-eio alcotest))
+41
eio/tests/test_x509_eio.ml
··· 1 + (* Tests for X509_eio module - verify type accessibility *) 2 + 3 + (* X509_eio provides IO-bound functions that need real files. 4 + We verify the module's function signatures are accessible. *) 5 + 6 + let test_module_accessibility () = 7 + ignore 8 + (X509_eio.private_of_pems 9 + : cert:_ Eio.Path.t -> priv_key:_ Eio.Path.t -> Tls.Config.certchain); 10 + ignore (X509_eio.certs_of_pem : _ Eio.Path.t -> X509.Certificate.t list); 11 + ignore (X509_eio.certs_of_pem_dir : _ Eio.Path.t -> X509.Certificate.t list) 12 + 13 + let test_authenticator_type () = 14 + ignore 15 + (X509_eio.authenticator 16 + : ?allowed_hashes:Digestif.hash' list -> 17 + ?crls:_ Eio.Path.t -> 18 + [ `Ca_file of _ Eio.Path.t 19 + | `Ca_dir of _ Eio.Path.t 20 + | `Key_fingerprint of Digestif.hash' * string 21 + | `Hex_key_fingerprint of Digestif.hash' * string 22 + | `Cert_fingerprint of Digestif.hash' * string 23 + | `Hex_cert_fingerprint of Digestif.hash' * string ] -> 24 + X509.Authenticator.t) 25 + 26 + let test_tls_eio_types () = 27 + (* Verify Tls_eio types are accessible *) 28 + ignore (Tls_eio.epoch : Tls_eio.t -> (Tls.Core.epoch_data, unit) result); 29 + ignore (Tls_eio.key_update : ?request:bool -> Tls_eio.t -> unit) 30 + 31 + let () = 32 + Alcotest.run "x509_eio" 33 + [ 34 + ( "x509_eio", 35 + [ 36 + Alcotest.test_case "module accessibility" `Quick 37 + test_module_accessibility; 38 + Alcotest.test_case "authenticator type" `Quick test_authenticator_type; 39 + Alcotest.test_case "tls_eio types" `Quick test_tls_eio_types; 40 + ] ); 41 + ]
+2
test/test.ml
··· 18 18 Test_writer.suite; 19 19 Test_packet.suite; 20 20 Test_tls_crypto.suite; 21 + Test_core.suite; 22 + Test_state.suite; 21 23 ]
+77
test/test_core.ml
··· 1 + (* Tests for TLS Core module *) 2 + open Tls 3 + 4 + (* Test TLS version pair encoding *) 5 + let test_pair_of_tls_version () = 6 + Alcotest.(check (pair int int)) 7 + "TLS 1.0" (3, 1) 8 + (Core.pair_of_tls_version `TLS_1_0); 9 + Alcotest.(check (pair int int)) 10 + "TLS 1.1" (3, 2) 11 + (Core.pair_of_tls_version `TLS_1_1); 12 + Alcotest.(check (pair int int)) 13 + "TLS 1.2" (3, 3) 14 + (Core.pair_of_tls_version `TLS_1_2); 15 + Alcotest.(check (pair int int)) 16 + "TLS 1.3" (3, 4) 17 + (Core.pair_of_tls_version `TLS_1_3) 18 + 19 + (* Test TLS version comparison *) 20 + let test_compare_tls_version () = 21 + Alcotest.(check int) 22 + "1.0 = 1.0" 0 23 + (Core.compare_tls_version `TLS_1_0 `TLS_1_0); 24 + Alcotest.(check bool) 25 + "1.0 < 1.1" true 26 + (Core.compare_tls_version `TLS_1_0 `TLS_1_1 < 0); 27 + Alcotest.(check bool) 28 + "1.2 < 1.3" true 29 + (Core.compare_tls_version `TLS_1_2 `TLS_1_3 < 0); 30 + Alcotest.(check bool) 31 + "1.3 > 1.0" true 32 + (Core.compare_tls_version `TLS_1_3 `TLS_1_0 > 0); 33 + Alcotest.(check int) 34 + "1.3 = 1.3" 0 35 + (Core.compare_tls_version `TLS_1_3 `TLS_1_3) 36 + 37 + (* Test TLS version pretty printing *) 38 + let test_pp_tls_version () = 39 + let pp v = Fmt.to_to_string Core.pp_tls_version v in 40 + Alcotest.(check string) "TLS 1.0" "TLS 1.0" (pp `TLS_1_0); 41 + Alcotest.(check string) "TLS 1.1" "TLS 1.1" (pp `TLS_1_1); 42 + Alcotest.(check string) "TLS 1.2" "TLS 1.2" (pp `TLS_1_2); 43 + Alcotest.(check string) "TLS 1.3" "TLS 1.3" (pp `TLS_1_3) 44 + 45 + (* Test version successor *) 46 + let test_next_version () = 47 + (match Core.next `TLS_1_0 with 48 + | Some `TLS_1_1 -> () 49 + | _ -> Alcotest.fail "next of 1.0 should be 1.1"); 50 + (match Core.next `TLS_1_1 with 51 + | Some `TLS_1_2 -> () 52 + | _ -> Alcotest.fail "next of 1.1 should be 1.2"); 53 + (match Core.next `TLS_1_2 with 54 + | Some `TLS_1_3 -> () 55 + | _ -> Alcotest.fail "next of 1.2 should be 1.3"); 56 + match Core.next `TLS_1_3 with 57 + | None -> () 58 + | Some _ -> Alcotest.fail "next of 1.3 should be None" 59 + 60 + (* Test all_versions generates correct version ranges *) 61 + let test_all_versions () = 62 + let versions = Core.all_versions (`TLS_1_0, `TLS_1_3) in 63 + Alcotest.(check int) "all 4 versions" 4 (List.length versions); 64 + let versions12 = Core.all_versions (`TLS_1_0, `TLS_1_2) in 65 + Alcotest.(check int) "3 versions (1.0-1.2)" 3 (List.length versions12); 66 + let versions_single = Core.all_versions (`TLS_1_2, `TLS_1_2) in 67 + Alcotest.(check int) "single version" 1 (List.length versions_single) 68 + 69 + let suite = 70 + ( "core", 71 + [ 72 + Alcotest.test_case "pair_of_tls_version" `Quick test_pair_of_tls_version; 73 + Alcotest.test_case "compare_tls_version" `Quick test_compare_tls_version; 74 + Alcotest.test_case "pp_tls_version" `Quick test_pp_tls_version; 75 + Alcotest.test_case "next version" `Quick test_next_version; 76 + Alcotest.test_case "all_versions" `Quick test_all_versions; 77 + ] )
+1
test/test_core.mli
··· 1 + val suite : string * unit Alcotest.test_case list
+38
test/test_state.ml
··· 1 + (* Tests for TLS State module - verifies type accessibility *) 2 + open Tls 3 + 4 + (* Test that the Engine module is accessible and provides key types *) 5 + let test_engine_state_type () = 6 + (* Verify Engine.state type is accessible via handle_tls return *) 7 + ignore (Engine.client : Config.client -> Engine.state * string); 8 + ignore (Engine.server : Config.server -> Engine.state) 9 + 10 + (* Test that epoch_data type is accessible *) 11 + let test_epoch_data_type () = 12 + ignore (fun (e : Core.epoch_data) -> 13 + let _ = e.Core.protocol_version in 14 + let _ = e.Core.ciphersuite in 15 + let _ = e.Core.peer_random in 16 + let _ = e.Core.own_random in 17 + let _ = e.Core.peer_certificate_chain in 18 + let _ = e.Core.peer_certificate in 19 + let _ = e.Core.own_certificate in 20 + let _ = e.Core.received_certificates in 21 + let _ = e.Core.own_private_key in 22 + let _ = e.Core.master_secret in 23 + let _ = e.Core.alpn_protocol in 24 + ()) 25 + 26 + (* Test that failure type is accessible *) 27 + let test_failure_pp () = 28 + let f : Engine.failure = `Error (`NoConfiguredCiphersuite []) in 29 + let s = Fmt.to_to_string Engine.pp_failure f in 30 + Alcotest.(check bool) "pp non-empty" true (String.length s > 0) 31 + 32 + let suite = 33 + ( "state", 34 + [ 35 + Alcotest.test_case "engine state type" `Quick test_engine_state_type; 36 + Alcotest.test_case "epoch_data type" `Quick test_epoch_data_type; 37 + Alcotest.test_case "failure pp" `Quick test_failure_pp; 38 + ] )
+1
test/test_state.mli
··· 1 + val suite : string * unit Alcotest.test_case list