Skip to content

Commit 5fca553

Browse files
committed
Test_event: use Test_common.make_session helper
Signed-off-by: Gabor Igloi <[email protected]>
1 parent 41fc51f commit 5fca553

File tree

1 file changed

+2
-24
lines changed

1 file changed

+2
-24
lines changed

ocaml/xapi/test_event.ml

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,34 +27,12 @@ let start_periodic_scheduler () =
2727
ps_start := true
2828
end
2929

30-
let create_session ~__context =
31-
let session_id = Ref.make () in
32-
let uuid = Uuid.to_string (Uuid.make_uuid ()) in
33-
let user = Ref.null in (* always return a null reference to the deprecated user object *)
34-
let parent = try Context.get_session_id __context with _ -> Ref.null in
35-
(*match uname with (* the user object is deprecated in favor of subject *)
36-
Some uname -> Helpers.get_user ~__context uname
37-
| None -> Ref.null in*)
38-
(* This info line is important for tracking, auditability and client accountability purposes on XenServer *)
39-
(* Never print the session id nor uuid: they are secret values that should be known only to the user that *)
40-
(* has just logged in. Instead, we print a non-invertible hash as the tracking id for the session id *)
41-
(* see also task creation in context.ml *)
42-
(* CP-982: promote tracking debug line to info status *)
43-
(* CP-982: create tracking id in log files to link username to actions *)
44-
Db.Session.create ~__context ~ref:session_id ~uuid
45-
~this_user:user ~this_host:(Helpers.get_localhost ~__context) ~pool:false
46-
~last_active:(Date.of_float (Unix.time ())) ~other_config:[]
47-
~subject:(Ref.null) ~is_local_superuser:true
48-
~auth_user_sid:"" ~validation_time:(Date.of_float (Unix.time ()))
49-
~auth_user_name:"root" ~rbac_permissions:[] ~parent ~originator:"test";
50-
session_id
51-
5230
let parse_event_from rpc = rpc |> Xmlrpc.to_string |> Xmlrpc.of_string |> event_from_of_rpc
5331

5432
let event_setup_common () =
5533
start_periodic_scheduler ();
56-
let c1 = make_test_database () in
57-
let session_id = create_session c1 in
34+
let __context = make_test_database () in
35+
let session_id = Test_common.make_session ~__context () in
5836
let __context = Mock.Context.make ~session_id "session context" in
5937
(__context, session_id)
6038

0 commit comments

Comments
 (0)