summaryrefslogtreecommitdiffhomepage
path: root/test/test-runner/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/test-runner/src')
-rw-r--r--test/test-runner/src/main.rs25
-rw-r--r--test/test-runner/src/sys.rs45
2 files changed, 56 insertions, 14 deletions
diff --git a/test/test-runner/src/main.rs b/test/test-runner/src/main.rs
index fec18255d7..843285eb33 100644
--- a/test/test-runner/src/main.rs
+++ b/test/test-runner/src/main.rs
@@ -319,19 +319,22 @@ impl Service for TestServer {
}
/// Disable the Mullvad VPN system service.
- async fn disable_mullvad_daemon_service(
- self,
- _: context::Context,
- ) -> Result<(), test_rpc::Error> {
- sys::disable_system_service_startup().await
+ async fn disable_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ #[cfg(not(target_os = "windows"))]
+ unimplemented!("disable_mullvad_daemon is only implemented on Windows");
+ #[cfg(target_os = "windows")]
+ {
+ sys::disable_system_service_startup().await
+ }
}
- /// Enable the Mullvad VPN system service.
- async fn enable_mullvad_daemon_service(
- self,
- _: context::Context,
- ) -> Result<(), test_rpc::Error> {
- sys::enable_system_service_startup().await
+ async fn enable_mullvad_daemon(self, _: context::Context) -> Result<(), test_rpc::Error> {
+ #[cfg(not(target_os = "windows"))]
+ unimplemented!("enable_mullvad_daemon is only implemented on Windows");
+ #[cfg(target_os = "windows")]
+ {
+ sys::enable_system_service_startup().await
+ }
}
async fn set_daemon_log_level(
diff --git a/test/test-runner/src/sys.rs b/test/test-runner/src/sys.rs
index 44ac2803ce..3490353b55 100644
--- a/test/test-runner/src/sys.rs
+++ b/test/test-runner/src/sys.rs
@@ -284,10 +284,49 @@ pub async fn start_app() -> Result<(), test_rpc::Error> {
Ok(())
}
-/// Disable the Mullvad VPN system service.
+/// Disable the Mullvad VPN system service startup. This will not trigger the service to stop
+/// immediately, but it will prevent it from starting on the next system boot.
#[cfg(target_os = "windows")]
-pub async fn disable_system_service() -> Result<(), test_rpc::Error> {
- todo!("sc.exe disable?")
+pub async fn disable_system_service_startup() -> Result<(), test_rpc::Error> {
+ let status = tokio::process::Command::new("powershell")
+ .args([
+ "-NoProfile",
+ "-Command",
+ "Set-Service -Name MullvadVPN -StartupType Disabled",
+ ])
+ .status()
+ .await
+ .map_err(|e| test_rpc::Error::ServiceChange(e.to_string()))?;
+
+ if !status.success() {
+ return Err(test_rpc::Error::ServiceChange(
+ "Failed to disable MullvadVPN service".to_string(),
+ ));
+ }
+
+ Ok(())
+}
+
+/// Enable the Mullvad VPN system service startup. This will configure the service to start automatically on system boot.
+#[cfg(target_os = "windows")]
+pub async fn enable_system_service_startup() -> Result<(), test_rpc::Error> {
+ let status = tokio::process::Command::new("powershell")
+ .args([
+ "-NoProfile",
+ "-Command",
+ "Set-Service -Name MullvadVPN -StartupType Automatic",
+ ])
+ .status()
+ .await
+ .map_err(|e| test_rpc::Error::ServiceChange(e.to_string()))?;
+
+ if !status.success() {
+ return Err(test_rpc::Error::ServiceChange(
+ "Failed to enable MullvadVPN service".to_string(),
+ ));
+ }
+
+ Ok(())
}
/// Restart the Mullvad VPN application.