@@ -180,7 +180,7 @@ ExecStart=/usr/bin/mullvad-daemon --disable-stdout-timestamps {verbosity}"#
180
180
if let Some ( parent) = override_path. parent ( ) {
181
181
tokio:: fs:: create_dir_all ( parent)
182
182
. await
183
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
183
+ . map_err ( |e| test_rpc:: Error :: ServiceChange ( e. to_string ( ) ) ) ?;
184
184
}
185
185
186
186
let mut file = tokio:: fs:: OpenOptions :: new ( )
@@ -189,17 +189,17 @@ ExecStart=/usr/bin/mullvad-daemon --disable-stdout-timestamps {verbosity}"#
189
189
. write ( true )
190
190
. open ( override_path)
191
191
. await
192
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
192
+ . map_err ( |e| test_rpc:: Error :: ServiceChange ( e. to_string ( ) ) ) ?;
193
193
194
194
file. write_all ( systemd_service_file_content. as_bytes ( ) )
195
195
. await
196
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
196
+ . map_err ( |e| test_rpc:: Error :: ServiceChange ( e. to_string ( ) ) ) ?;
197
197
198
198
tokio:: process:: Command :: new ( "systemctl" )
199
199
. args ( [ "daemon-reload" ] )
200
200
. status ( )
201
201
. await
202
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
202
+ . map_err ( |e| test_rpc:: Error :: ServiceStart ( e. to_string ( ) ) ) ?;
203
203
204
204
restart_app ( ) . await ?;
205
205
Ok ( ( ) )
@@ -214,7 +214,7 @@ pub async fn restart_app() -> Result<(), test_rpc::Error> {
214
214
. args ( [ "restart" , "mullvad-daemon" ] )
215
215
. status ( )
216
216
. await
217
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
217
+ . map_err ( |e| test_rpc:: Error :: ServiceStart ( e. to_string ( ) ) ) ?;
218
218
wait_for_service_state ( ServiceState :: Running ) . await ?;
219
219
Ok ( ( ) )
220
220
}
@@ -228,7 +228,7 @@ pub async fn stop_app() -> Result<(), test_rpc::Error> {
228
228
. args ( [ "stop" , "mullvad-daemon" ] )
229
229
. status ( )
230
230
. await
231
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
231
+ . map_err ( |e| test_rpc:: Error :: ServiceStop ( e. to_string ( ) ) ) ?;
232
232
wait_for_service_state ( ServiceState :: Inactive ) . await ?;
233
233
234
234
Ok ( ( ) )
@@ -243,7 +243,7 @@ pub async fn start_app() -> Result<(), test_rpc::Error> {
243
243
. args ( [ "start" , "mullvad-daemon" ] )
244
244
. status ( )
245
245
. await
246
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
246
+ . map_err ( |e| test_rpc:: Error :: ServiceStart ( e. to_string ( ) ) ) ?;
247
247
wait_for_service_state ( ServiceState :: Running ) . await ?;
248
248
Ok ( ( ) )
249
249
}
@@ -267,7 +267,7 @@ pub async fn stop_app() -> Result<(), test_rpc::Error> {
267
267
. args ( [ "stop" , "mullvadvpn" ] )
268
268
. status ( )
269
269
. await
270
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
270
+ . map_err ( |e| test_rpc:: Error :: ServiceStop ( e. to_string ( ) ) ) ?;
271
271
Ok ( ( ) )
272
272
}
273
273
@@ -280,7 +280,7 @@ pub async fn start_app() -> Result<(), test_rpc::Error> {
280
280
. args ( [ "start" , "mullvadvpn" ] )
281
281
. status ( )
282
282
. await
283
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
283
+ . map_err ( |e| test_rpc:: Error :: ServiceStart ( e. to_string ( ) ) ) ?;
284
284
Ok ( ( ) )
285
285
}
286
286
@@ -325,7 +325,7 @@ pub async fn set_daemon_log_level(verbosity_level: Verbosity) -> Result<(), test
325
325
} ;
326
326
327
327
let manager = ServiceManager :: local_computer ( None :: < & str > , ServiceManagerAccess :: CONNECT )
328
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
328
+ . map_err ( |e| test_rpc:: Error :: ServiceNotFound ( e. to_string ( ) ) ) ?;
329
329
let service = manager
330
330
. open_service (
331
331
"mullvadvpn" ,
@@ -334,23 +334,23 @@ pub async fn set_daemon_log_level(verbosity_level: Verbosity) -> Result<(), test
334
334
| ServiceAccess :: START
335
335
| ServiceAccess :: STOP ,
336
336
)
337
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
337
+ . map_err ( |e| test_rpc:: Error :: ServiceNotFound ( e. to_string ( ) ) ) ?;
338
338
339
339
// Stop the service
340
340
// TODO: Extract to separate function.
341
341
service
342
342
. stop ( )
343
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
343
+ . map_err ( |e| test_rpc:: Error :: ServiceStop ( e. to_string ( ) ) ) ?;
344
344
tokio:: process:: Command :: new ( "net" )
345
345
. args ( [ "stop" , "mullvadvpn" ] )
346
346
. status ( )
347
347
. await
348
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
348
+ . map_err ( |e| test_rpc:: Error :: ServiceStop ( e. to_string ( ) ) ) ?;
349
349
350
350
// Get the current service configuration
351
351
let config = service
352
352
. query_config ( )
353
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
353
+ . map_err ( |e| test_rpc:: Error :: ServiceNotFound ( e. to_string ( ) ) ) ?;
354
354
355
355
let executable_path = "C:\\ Program Files\\ Mullvad VPN\\ resources\\ mullvad-daemon.exe" ;
356
356
let launch_arguments = vec ! [
@@ -375,13 +375,13 @@ pub async fn set_daemon_log_level(verbosity_level: Verbosity) -> Result<(), test
375
375
// Apply the updated configuration
376
376
service
377
377
. change_config ( & updated_config)
378
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
378
+ . map_err ( |e| test_rpc:: Error :: ServiceChange ( e. to_string ( ) ) ) ?;
379
379
380
380
// Start the service
381
381
// TODO: Extract to separate function.
382
382
service
383
383
. start :: < String > ( & [ ] )
384
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
384
+ . map_err ( |e| test_rpc:: Error :: ServiceNotFound ( e. to_string ( ) ) ) ?;
385
385
386
386
Ok ( ( ) )
387
387
}
@@ -445,19 +445,19 @@ pub async fn set_daemon_environment(env: HashMap<String, String>) -> Result<(),
445
445
. map ( |env_var| env_var. to_systemd_string ( ) )
446
446
{
447
447
writeln ! ( & mut override_content, "{env_var}" )
448
- . map_err ( |err| test_rpc:: Error :: Service ( err. to_string ( ) ) ) ?;
448
+ . map_err ( |err| test_rpc:: Error :: ServiceChange ( err. to_string ( ) ) ) ?;
449
449
}
450
450
451
451
let override_path = std:: path:: Path :: new ( SYSTEMD_OVERRIDE_FILE ) ;
452
452
if let Some ( parent) = override_path. parent ( ) {
453
453
tokio:: fs:: create_dir_all ( parent)
454
454
. await
455
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
455
+ . map_err ( |e| test_rpc:: Error :: ServiceChange ( e. to_string ( ) ) ) ?;
456
456
}
457
457
458
458
tokio:: fs:: write ( override_path, override_content)
459
459
. await
460
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?;
460
+ . map_err ( |e| test_rpc:: Error :: ServiceChange ( e. to_string ( ) ) ) ?;
461
461
462
462
if tokio:: process:: Command :: new ( "systemctl" )
463
463
. args ( [ "daemon-reload" ] )
@@ -467,7 +467,7 @@ pub async fn set_daemon_environment(env: HashMap<String, String>) -> Result<(),
467
467
. success ( )
468
468
. not ( )
469
469
{
470
- return Err ( test_rpc:: Error :: Service (
470
+ return Err ( test_rpc:: Error :: ServiceChange (
471
471
"Daemon service could not be reloaded" . to_owned ( ) ,
472
472
) ) ;
473
473
} ;
@@ -480,7 +480,7 @@ pub async fn set_daemon_environment(env: HashMap<String, String>) -> Result<(),
480
480
. success ( )
481
481
. not ( )
482
482
{
483
- return Err ( test_rpc:: Error :: Service (
483
+ return Err ( test_rpc:: Error :: ServiceStart (
484
484
"Daemon service could not be restarted" . to_owned ( ) ,
485
485
) ) ;
486
486
} ;
@@ -707,7 +707,7 @@ async fn wait_for_service_state(awaited_state: ServiceState) -> Result<(), test_
707
707
loop {
708
708
attempt += 1 ;
709
709
if attempt > RETRY_ATTEMPTS {
710
- return Err ( test_rpc:: Error :: Service ( String :: from (
710
+ return Err ( test_rpc:: Error :: ServiceStart ( String :: from (
711
711
"Awaiting new service state timed out" ,
712
712
) ) ) ;
713
713
}
@@ -716,7 +716,7 @@ async fn wait_for_service_state(awaited_state: ServiceState) -> Result<(), test_
716
716
. args ( [ "status" , "mullvad-daemon" ] )
717
717
. output ( )
718
718
. await
719
- . map_err ( |e| test_rpc:: Error :: Service ( e. to_string ( ) ) ) ?
719
+ . map_err ( |e| test_rpc:: Error :: ServiceNotFound ( e. to_string ( ) ) ) ?
720
720
. stdout ;
721
721
let output = String :: from_utf8_lossy ( & output) ;
722
722
0 commit comments