From 7b3d8e1d13bab22c82b38012cfcb8cbfe67ed7e5 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Thu, 8 Nov 2018 13:13:04 +0100 Subject: sid: functorize well-formedness checks Offload the test for member count and size constraints of sas and ia, respectively, into a separate validation module. This is a preparatory step toward adding less rigid parsing modes. --- sid_test.ml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'sid_test.ml') diff --git a/sid_test.ml b/sid_test.ml index 7da0d7f..26a125b 100644 --- a/sid_test.ml +++ b/sid_test.ml @@ -111,8 +111,8 @@ let sf_parse_nosa_fail () = (Printf.sprintf "unexpectedly parsed garbage as SID [%s]" (Sid.to_string s)) | Error e -> - assert_equal e "Invalid SID: error parsing SID [S-1-1] at position 5, \ - grammar mandates at least one subauthority" + assert_equal e "input malformed: subauthority list failed “strict” \ + validation (count=0)" let sf_parse_trailing_ok () = let s = unwrap_of_string "S-1-0-0-" in @@ -139,8 +139,8 @@ let sf_parse_oobia_fail () = with | Ok _ -> assert_failure "unexpectedly parsed the out of bounds subauth" | Error e -> - assert_equal e "input malformed: identifier authority from 2³² on must \ - be hex-encoded (value=18446744073709551615)" + assert_equal e "input malformed: decimal identifier authority failed \ + “strict” validation (value=18446744073709551615)" let sf_parse_oobsa_fail () = match Sid.of_string @@ -189,8 +189,8 @@ let sf_parse_iaxxoob_fail () = (* ias <= UINT32_MAX → decimal; hex not allowed *) match Sid.of_string "S-1-0x0000deadbeef-17-01" with | Error e -> - let expect = "input malformed: identifier authority less than 2³² must \ - not be hex-encoded (value=3735928559)" + let expect = "input malformed: hex-encoded identifier authority failed \ + “strict” validation (value=3735928559)" in assert_equal ~msg:(Printf.sprintf "[%s] ≠ [%s]" e expect) @@ -236,8 +236,8 @@ let sf_parse_iaxxlong_fail () = (* too many digits, need exactly 12 *) match Sid.of_string "S-1-0xC01DC01DB100D-17-01" with | Error e -> - let expect = "Invalid SID: error parsing SID [S-1-0xC01DC01DB100D-17-01] \ - at position 18, grammar mandates at least one subauthority" + let expect = "input malformed: subauthority list failed “strict” \ + validation (count=0)" in assert_equal ~msg:(Printf.sprintf "[%s] ≠ [%s]" e expect) -- cgit v1.2.3