Skip to content

Commit 497bbfa

Browse files
authored
Merge master into feature/configure-ssh-phase2 (#6398)
2 parents 2f00a21 + 0441299 commit 497bbfa

File tree

13 files changed

+280
-274
lines changed

13 files changed

+280
-274
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ DUNE_IU_PACKAGES1+=message-switch message-switch-cli message-switch-core message
156156
DUNE_IU_PACKAGES1+=message-switch-unix xapi-idl xapi-forkexecd xapi-storage xapi-storage-script xapi-storage-cli
157157
DUNE_IU_PACKAGES1+=xapi-nbd varstored-guard xapi-log xapi-open-uri xapi-tracing xapi-tracing-export xapi-expiry-alerts cohttp-posix
158158
DUNE_IU_PACKAGES1+=xapi-rrd xapi-inventory clock xapi-sdk
159-
DUNE_IU_PACKAGES1+=xapi-stdext-date xapi-stdext-encodings xapi-stdext-pervasives xapi-stdext-std xapi-stdext-threads xapi-stdext-unix xapi-stdext-zerocheck xapi-tools
159+
DUNE_IU_PACKAGES1+=xapi-stdext-encodings xapi-stdext-pervasives xapi-stdext-std xapi-stdext-threads xapi-stdext-unix xapi-stdext-zerocheck xapi-tools
160160

161161

162162
install-dune1:

dune-project

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -669,16 +669,6 @@ This package provides an Lwt compatible interface to the library.")
669669
(name xapi-inventory)
670670
)
671671

672-
(package
673-
(name xapi-stdext-date)
674-
(synopsis "Xapi's standard library extension, Dates")
675-
(authors "Jonathan Ludlam")
676-
(depends
677-
(clock (= :version))
678-
ptime
679-
)
680-
)
681-
682672
(package
683673
(name xapi-stdext-encodings)
684674
(synopsis "Xapi's standard library extension, Encodings")

ocaml/libs/resources/test/dune

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
(action (run %{test} -e))
55
(libraries
66
safe-resources
7+
logs
78
logs.fmt
89
alcotest
910
)

ocaml/libs/xapi-stdext/lib/xapi-stdext-date/date.ml

Lines changed: 0 additions & 35 deletions
This file was deleted.

ocaml/libs/xapi-stdext/lib/xapi-stdext-date/date.mli

Lines changed: 0 additions & 115 deletions
This file was deleted.

ocaml/libs/xapi-stdext/lib/xapi-stdext-date/dune

Lines changed: 0 additions & 6 deletions
This file was deleted.

ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/ipq.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ type 'a t = {default: 'a event; mutable size: int; mutable data: 'a event array}
1919

2020
exception EmptyHeap
2121

22+
exception OutOfBounds of int
23+
2224
let create n default =
2325
if n <= 0 then
2426
invalid_arg "create"
@@ -61,7 +63,7 @@ let maximum h =
6163
let remove h s =
6264
if h.size <= 0 then raise EmptyHeap ;
6365
if s < 0 || s >= h.size then
64-
invalid_arg (Printf.sprintf "%s: index %d out of bounds" __FUNCTION__ s) ;
66+
raise (OutOfBounds s) ;
6567
let n = h.size - 1 in
6668
let d = h.data in
6769
let x = d.(n) in

ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/ipq.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type 'a t
1818

1919
exception EmptyHeap
2020

21+
exception OutOfBounds of int
22+
2123
val create : int -> 'a -> 'a t
2224
(** [create n default] creates an empty Imperative priority queue.
2325
The queue initially is initialized to store [n] elements.

ocaml/libs/xapi-stdext/lib/xapi-stdext-threads/ipq_test.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,9 @@ module Ipq = Xapi_stdext_threads_scheduler.Ipq
1818
let test_out_of_index () =
1919
let q = Ipq.create 10 0 in
2020
Ipq.add q {Ipq.ev= 123; Ipq.time= Mtime_clock.elapsed ()} ;
21-
let is_oob = function
22-
| Invalid_argument s when String.ends_with ~suffix:" out of bounds" s ->
23-
true
24-
| _ ->
25-
false
26-
in
2721
let oob_check n =
28-
(Alcotest.match_raises "out of bound" is_oob @@ fun () -> Ipq.remove q n) ;
22+
let oob = Ipq.OutOfBounds n in
23+
(Alcotest.check_raises "out of bound" oob @@ fun () -> Ipq.remove q n) ;
2924
Alcotest.(check bool) "same value" false (Ipq.is_empty q)
3025
in
3126
oob_check 10 ;

ocaml/tests/test_extauth_plugin_ADwinbind.ml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,106 @@ let test_wbinfo_exception_of_stderr =
499499
in
500500
matrix |> List.map @@ fun (inp, exp) -> ("<omit inp>", `Quick, check inp exp)
501501

502+
let test_add_ipv4_localhost_to_hosts =
503+
let open Extauth_plugin_ADwinbind in
504+
let check inp exp () =
505+
let msg =
506+
Printf.sprintf "%s -> %s" (String.concat "\n" inp) (String.concat "\n" exp)
507+
in
508+
let actual =
509+
HostsConfIPv4.join ~name:"hostname" ~domain:"domain" ~lines:inp
510+
in
511+
Alcotest.(check @@ list string) msg exp actual
512+
in
513+
let matrix =
514+
[
515+
( [
516+
"127.0.0.1 localhost localhost.localdomain localhost4 \
517+
localhost4.localdomain4"
518+
]
519+
, [
520+
"127.0.0.1 localhost localhost.localdomain localhost4 \
521+
localhost4.localdomain4 hostname hostname.domain"
522+
]
523+
)
524+
; ( ["127.0.0.1 localhost hostname hostname.domain localhost.localdomain"]
525+
, ["127.0.0.1 localhost localhost.localdomain hostname hostname.domain"]
526+
)
527+
; ( ["192.168.0.1 some_host"]
528+
, ["127.0.0.1 hostname hostname.domain"; "192.168.0.1 some_host"]
529+
)
530+
; ([], ["127.0.0.1 hostname hostname.domain"])
531+
]
532+
in
533+
matrix |> List.map @@ fun (inp, exp) -> ("<omit inp>", `Quick, check inp exp)
534+
535+
let test_add_ipv4_and_ipv6_localhost_to_hosts =
536+
let open Extauth_plugin_ADwinbind in
537+
let check inp exp () =
538+
let msg =
539+
Printf.sprintf "%s -> %s" (String.concat "\n" inp) (String.concat "\n" exp)
540+
in
541+
let actual =
542+
HostsConfIPv6.join ~name:"hostname" ~domain:"domain" ~lines:inp
543+
|> fun lines ->
544+
HostsConfIPv4.join ~name:"hostname" ~domain:"domain" ~lines
545+
in
546+
Alcotest.(check @@ list string) msg exp actual
547+
in
548+
let matrix =
549+
[
550+
( ["127.0.0.1 localhost"]
551+
, [
552+
"::1 hostname hostname.domain"
553+
; "127.0.0.1 localhost hostname hostname.domain"
554+
]
555+
)
556+
; ( ["127.0.0.1 localhost"; "::1 localhost"]
557+
, [
558+
"127.0.0.1 localhost hostname hostname.domain"
559+
; "::1 localhost hostname hostname.domain"
560+
]
561+
)
562+
; ( []
563+
, ["127.0.0.1 hostname hostname.domain"; "::1 hostname hostname.domain"]
564+
)
565+
]
566+
in
567+
matrix |> List.map @@ fun (inp, exp) -> ("<omit inp>", `Quick, check inp exp)
568+
569+
let test_remove_ipv4_localhost_from_hosts =
570+
let open Extauth_plugin_ADwinbind in
571+
let check inp exp () =
572+
let msg =
573+
Printf.sprintf "%s -> %s" (String.concat "\n" inp) (String.concat "\n" exp)
574+
in
575+
let actual =
576+
HostsConfIPv4.leave ~name:"hostname" ~domain:"domain" ~lines:inp
577+
in
578+
Alcotest.(check @@ list string) msg exp actual
579+
in
580+
let matrix =
581+
[
582+
( [
583+
"127.0.0.1 localhost localhost.localdomain localhost4 \
584+
localhost4.localdomain4"
585+
]
586+
, [
587+
"127.0.0.1 localhost localhost.localdomain localhost4 \
588+
localhost4.localdomain4"
589+
]
590+
)
591+
; ( ["127.0.0.1 localhost hostname hostname.domain localhost.localdomain"]
592+
, ["127.0.0.1 localhost localhost.localdomain"]
593+
)
594+
; (["127.0.0.1 hostname hostname.domain"], [])
595+
; ( ["192.168.0.1 some_host"; "127.0.0.1 localhost hostname"]
596+
, ["192.168.0.1 some_host"; "127.0.0.1 localhost"]
597+
)
598+
]
599+
in
600+
matrix |> List.map @@ fun (inp, exp) -> ("<omit inp>", `Quick, check inp exp)
601+
502602
let tests =
503603
[
504604
("ADwinbind:extract_ou_config", ExtractOuConfig.tests)
@@ -512,4 +612,13 @@ let tests =
512612
; ( "ADwinbind:test_wbinfo_exception_of_stderr"
513613
, test_wbinfo_exception_of_stderr
514614
)
615+
; ( "ADwinbind:test_add_ipv4_localhost_to_hosts"
616+
, test_add_ipv4_localhost_to_hosts
617+
)
618+
; ( "ADwinbind:test_remove_ipv4_localhost_from_hosts"
619+
, test_remove_ipv4_localhost_from_hosts
620+
)
621+
; ( "ADwinbind:test_add_ipv4_and_ipv6_localhost_to_hosts"
622+
, test_add_ipv4_and_ipv6_localhost_to_hosts
623+
)
515624
]

0 commit comments

Comments
 (0)