|
| 1 | +(* |
| 2 | + * Copyright (C) Cloud Software Group, Inc |
| 3 | + * |
| 4 | + * This program is free software; you can redistribute it and/or modify |
| 5 | + * it under the terms of the GNU Lesser General Public License as published |
| 6 | + * by the Free Software Foundation; version 2.1 only. with the special |
| 7 | + * exception on linking described in file LICENSE. |
| 8 | + * |
| 9 | + * This program is distributed in the hope that it will be useful, |
| 10 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU Lesser General Public License for more details. |
| 13 | + *) |
| 14 | + |
| 15 | +let strings = |
| 16 | + [ |
| 17 | + ("foobar", "foobar") |
| 18 | + ; ("foobarproxy_username=password", "foobarproxy_username=(filtered)") |
| 19 | + ; ("barfooproxy_password=secret", "barfooproxy_password=(filtered)") |
| 20 | + ; ("password", "password") |
| 21 | + ; ("username=password", "username=password") |
| 22 | + ; ("password=password", "password=password") |
| 23 | + ; ("proxy_username=", "proxy_username=(filtered)") |
| 24 | + ] |
| 25 | + |
| 26 | +let filtering_test = |
| 27 | + List.map |
| 28 | + (fun (input, expected) -> |
| 29 | + let test_filtering () = |
| 30 | + let filtered = |
| 31 | + match Helpers.filter_args [input] with x :: _ -> x | _ -> "" |
| 32 | + in |
| 33 | + Printf.printf "%s\n" input ; |
| 34 | + Alcotest.(check string) "secrets must be filtered out" expected filtered |
| 35 | + in |
| 36 | + ( Printf.sprintf {|Validation of argument filtering of "%s"|} input |
| 37 | + , `Quick |
| 38 | + , test_filtering |
| 39 | + ) |
| 40 | + ) |
| 41 | + strings |
| 42 | + |
| 43 | +let () = |
| 44 | + Suite_init.harness_init () ; |
| 45 | + Alcotest.run "Test XAPI Helpers suite" [("Test_xapi_helpers", filtering_test)] |
0 commit comments