@@ -2,8 +2,8 @@ use anyhow::Result;
22use assert_cmd:: cargo:: cargo_bin;
33use camino:: { Utf8Path , Utf8PathBuf } ;
44use robotmk:: config:: {
5- Config , EnvironmentConfig , ExecutionConfig , RCCConfig , RCCEnvironmentConfig , RetryStrategy ,
6- RobotFrameworkConfig , SessionConfig , SuiteConfig , UserSessionConfig ,
5+ Config , EnvironmentConfig , ExecutionConfig , RCCConfig , RCCEnvironmentConfig , RCCProfileConfig ,
6+ RetryStrategy , RobotFrameworkConfig , SessionConfig , SuiteConfig , UserSessionConfig ,
77 WorkingDirectoryCleanupConfig ,
88} ;
99use robotmk:: section:: Host ;
@@ -26,7 +26,10 @@ async fn test_scheduler() -> Result<()> {
2626 & Utf8PathBuf :: from ( var ( "CARGO_MANIFEST_DIR" ) ?)
2727 . join ( "tests" )
2828 . join ( "minimal_suite" ) ,
29- var ( "RCC_BINARY_PATH" ) ?,
29+ RCCConfig {
30+ binary_path : var ( "RCC_BINARY_PATH" ) ?. into ( ) ,
31+ profile_config : Some ( create_rcc_profile ( & test_dir) ?) ,
32+ } ,
3033 & current_user_name,
3134 ) ;
3235
@@ -39,18 +42,35 @@ async fn test_scheduler() -> Result<()> {
3942 Ok ( ( ) )
4043}
4144
45+ fn create_rcc_profile ( test_dir : & Utf8Path ) -> Result < RCCProfileConfig > {
46+ let rcc_profile_path = test_dir. join ( "rcc_profile.yaml" ) ;
47+ write (
48+ & rcc_profile_path,
49+ "name: Robotmk
50+ description: Robotmk RCC profile
51+ settings:
52+ meta:
53+ name: Robotmk
54+ description: Robotmk RCC profile
55+ source: Robotmk
56+ " ,
57+ ) ?;
58+ Ok ( RCCProfileConfig {
59+ name : "Robotmk" . into ( ) ,
60+ path : rcc_profile_path,
61+ } )
62+ }
63+
4264fn create_config (
4365 test_dir : & Utf8Path ,
4466 suite_dir : & Utf8Path ,
45- rcc_binary_path : impl Into < Utf8PathBuf > ,
67+ rcc_config : RCCConfig ,
4668 user_name_headed : & str ,
4769) -> Config {
4870 Config {
4971 working_directory : test_dir. join ( "working" ) ,
5072 results_directory : test_dir. join ( "results" ) ,
51- rcc_config : RCCConfig {
52- binary_path : rcc_binary_path. into ( ) ,
53- } ,
73+ rcc_config,
5474 suites : [
5575 (
5676 String :: from ( "rcc_headless" ) ,
@@ -165,7 +185,7 @@ async fn assert_working_directory(
165185 working_directory : & Utf8Path ,
166186 headed_user_name : & str ,
167187) -> Result < ( ) > {
168- assert_working_directory_permissions ( & working_directory) . await ?;
188+ assert_permissions ( & working_directory, "BUILTIN \\ Users:(OI)(CI)(F)" ) . await ?;
169189 assert ! ( working_directory. is_dir( ) ) ;
170190 assert_eq ! (
171191 directory_entries( working_directory, 1 ) ,
@@ -184,6 +204,22 @@ async fn assert_working_directory(
184204 & format!( "holotree_initialization_user_{headed_user_name}.stdout" ) ,
185205 "long_path_support_enabling.stderr" ,
186206 "long_path_support_enabling.stdout" ,
207+ "profile_import_current_user.stderr" ,
208+ "profile_import_current_user.stdout" ,
209+ & format!( "profile_import_user_{headed_user_name}.bat" ) ,
210+ & format!( "profile_import_user_{headed_user_name}.exit_code" ) ,
211+ & format!( "profile_import_user_{headed_user_name}.pid" ) ,
212+ & format!( "profile_import_user_{headed_user_name}.run_flag" ) ,
213+ & format!( "profile_import_user_{headed_user_name}.stderr" ) ,
214+ & format!( "profile_import_user_{headed_user_name}.stdout" ) ,
215+ "profile_switch_current_user.stderr" ,
216+ "profile_switch_current_user.stdout" ,
217+ & format!( "profile_switch_user_{headed_user_name}.bat" ) ,
218+ & format!( "profile_switch_user_{headed_user_name}.exit_code" ) ,
219+ & format!( "profile_switch_user_{headed_user_name}.pid" ) ,
220+ & format!( "profile_switch_user_{headed_user_name}.run_flag" ) ,
221+ & format!( "profile_switch_user_{headed_user_name}.stderr" ) ,
222+ & format!( "profile_switch_user_{headed_user_name}.stdout" ) ,
187223 "shared_holotree_init.stderr" ,
188224 "shared_holotree_init.stdout" ,
189225 "telemetry_disabling_current_user.stderr" ,
@@ -227,11 +263,10 @@ async fn assert_working_directory(
227263 Ok ( ( ) )
228264}
229265
230- async fn assert_working_directory_permissions ( working_directory : & impl AsRef < OsStr > ) -> Result < ( ) > {
266+ async fn assert_permissions ( path : impl AsRef < OsStr > , permissions : & str ) -> Result < ( ) > {
231267 let mut icacls_command = Command :: new ( "icacls.exe" ) ;
232- icacls_command. arg ( working_directory) ;
233- let stdout = String :: from_utf8 ( icacls_command. output ( ) . await ?. stdout ) ?;
234- assert ! ( stdout. contains( "BUILTIN\\ Users:(OI)(CI)(F)" ) ) ;
268+ icacls_command. arg ( path) ;
269+ assert ! ( String :: from_utf8( icacls_command. output( ) . await ?. stdout) ?. contains( permissions) ) ;
235270 Ok ( ( ) )
236271}
237272
@@ -252,28 +287,34 @@ fn assert_results_directory(results_directory: &Utf8Path) {
252287}
253288
254289async fn assert_rcc ( rcc_config : & RCCConfig ) -> Result < ( ) > {
255- assert_rcc_binary_permissions ( & rcc_config. binary_path ) . await ?;
256- assert_rcc_configuration ( & rcc_config. binary_path ) . await ?;
290+ assert_rcc_files_permissions ( rcc_config) . await ?;
291+ assert_rcc_configuration ( rcc_config) . await ?;
257292 assert_rcc_longpath_support_enabled ( & rcc_config. binary_path ) . await
258293}
259294
260- async fn assert_rcc_binary_permissions ( rcc_binary_path : impl AsRef < OsStr > ) -> Result < ( ) > {
261- let mut icacls_command = Command :: new ( "icacls.exe" ) ;
262- icacls_command . arg ( rcc_binary_path ) ;
263- let stdout = String :: from_utf8 ( icacls_command . output ( ) . await ? . stdout ) ? ;
264- assert ! ( stdout . contains ( "BUILTIN \\ Users:(RX)" ) ) ;
265- Ok ( ( ) )
295+ async fn assert_rcc_files_permissions ( rcc_config : & RCCConfig ) -> Result < ( ) > {
296+ assert_permissions ( & rcc_config . binary_path , "BUILTIN \\ Users:(RX)" ) . await ? ;
297+ let Some ( rcc_profile_config ) = & rcc_config . profile_config else {
298+ return Ok ( ( ) ) ;
299+ } ;
300+ assert_permissions ( & rcc_profile_config . path , "BUILTIN \\ Users:(R)" ) . await
266301}
267302
268- async fn assert_rcc_configuration ( rcc_binary_path : impl AsRef < OsStr > ) -> Result < ( ) > {
269- let mut rcc_config_diag_command = Command :: new ( rcc_binary_path ) ;
303+ async fn assert_rcc_configuration ( rcc_config : & RCCConfig ) -> Result < ( ) > {
304+ let mut rcc_config_diag_command = Command :: new ( & rcc_config . binary_path ) ;
270305 rcc_config_diag_command
271306 . arg ( "configuration" )
272307 . arg ( "diagnostics" ) ;
273308 let stdout = String :: from_utf8 ( rcc_config_diag_command. output ( ) . await ?. stdout ) ?;
274309 assert ! ( stdout. contains( "telemetry-enabled ... \" false\" " ) ) ;
275310 assert ! ( stdout. contains( "holotree-shared ... \" true\" " ) ) ;
276311 assert ! ( stdout. contains( "holotree-global-shared ... \" true\" " ) ) ;
312+ if let Some ( rcc_profile_config) = & rcc_config. profile_config {
313+ assert ! ( stdout. contains( & format!(
314+ "config-active-profile ... \" {}\" " ,
315+ rcc_profile_config. name
316+ ) ) ) ;
317+ }
277318 Ok ( ( ) )
278319}
279320
0 commit comments