diff options
| author | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-11-17 15:37:13 +0100 |
|---|---|---|
| committer | Markus Pettersson <markus.pettersson@mullvad.net> | 2023-12-06 14:37:06 +0100 |
| commit | 1b930b893fa3fcb06f5fee4affbfb62887d0e68a (patch) | |
| tree | 21b0836c5b5730f844950a2764aa652832f13849 /test/test-rpc/src | |
| parent | ac3e222d031b0f599561c4c30504de5cd3f871a2 (diff) | |
| download | mullvadvpn-1b930b893fa3fcb06f5fee4affbfb62887d0e68a.tar.xz mullvadvpn-1b930b893fa3fcb06f5fee4affbfb62887d0e68a.zip | |
Implement RPC for reading & writing to app cache file
- Implement RPC for writing to a file in a test runner / guest VM.
- Implement RPC for getting app cache directory
- Implement RPC for restarting the app in a test runner / guest vm
- Implement RPC for starting the app in a test runner / guest vm
- Implement RPC for stopping the app in a test runner / guest vm
- Implement `find_cache_traces` on Window & macOS
Diffstat (limited to 'test/test-rpc/src')
| -rw-r--r-- | test/test-rpc/src/client.rs | 46 | ||||
| -rw-r--r-- | test/test-rpc/src/lib.rs | 14 |
2 files changed, 60 insertions, 0 deletions
diff --git a/test/test-rpc/src/client.rs b/test/test-rpc/src/client.rs index 6be77afb40..acc462dd60 100644 --- a/test/test-rpc/src/client.rs +++ b/test/test-rpc/src/client.rs @@ -151,6 +151,13 @@ impl ServiceClient { .await? } + /// Returns path of Mullvad app cache directorie on the test runner. + pub async fn find_mullvad_app_cache_dir(&self) -> Result<PathBuf, Error> { + self.client + .get_mullvad_app_cache_dir(tarpc::context::current()) + .await? + } + /// Send TCP packet pub async fn send_tcp( &self, @@ -213,6 +220,34 @@ impl ServiceClient { .await? } + pub async fn restart_app(&self) -> Result<(), Error> { + let _ = self.client.restart_app(tarpc::context::current()).await?; + Ok(()) + } + + /// Stop the app. + /// + /// Shuts down a running app, making it disconnect from any current tunnel + /// connection and making it write to caches. + /// + /// # Note + /// This function will return *after* the app has been stopped, thus + /// blocking execution until then. + pub async fn stop_app(&self) -> Result<(), Error> { + let _ = self.client.stop_app(tarpc::context::current()).await?; + Ok(()) + } + + /// Start the app. + /// + /// # Note + /// This function will return *after* the app has been start, thus + /// blocking execution until then. + pub async fn start_app(&self) -> Result<(), Error> { + let _ = self.client.start_app(tarpc::context::current()).await?; + Ok(()) + } + pub async fn set_daemon_log_level( &self, verbosity_level: mullvad_daemon::Verbosity, @@ -247,6 +282,17 @@ impl ServiceClient { .await? } + pub async fn write_file(&self, dest: String, bytes: Vec<u8>) -> Result<(), Error> { + log::debug!( + "Writing {bytes} bytes to \"{file}\"", + bytes = bytes.len(), + file = dest + ); + self.client + .write_file(tarpc::context::current(), dest, bytes) + .await? + } + pub async fn reboot(&mut self) -> Result<(), Error> { log::debug!("Rebooting server"); diff --git a/test/test-rpc/src/lib.rs b/test/test-rpc/src/lib.rs index 6968a3c613..65ccb2fb7a 100644 --- a/test/test-rpc/src/lib.rs +++ b/test/test-rpc/src/lib.rs @@ -120,6 +120,8 @@ mod service { /// Returns all Mullvad app files, directories, and other data found on the system. async fn find_mullvad_app_traces() -> Result<Vec<AppTrace>, Error>; + async fn get_mullvad_app_cache_dir() -> Result<PathBuf, Error>; + /// Send TCP packet async fn send_tcp( interface: Option<String>, @@ -149,6 +151,15 @@ mod service { /// Perform DNS resolution. async fn resolve_hostname(hostname: String) -> Result<Vec<SocketAddr>, Error>; + /// Restart the Mullvad VPN application. + async fn restart_app() -> Result<(), Error>; + + /// Stop the Mullvad VPN application. + async fn stop_app() -> Result<(), Error>; + + /// Start the Mullvad VPN application. + async fn start_app() -> Result<(), Error>; + /// Sets the log level of the daemon service, the verbosity level represents the number of /// `-v`s passed on the command line. This will restart the daemon system service. async fn set_daemon_log_level( @@ -161,6 +172,9 @@ mod service { /// Copy a file from `src` to `dest` on the test runner. async fn copy_file(src: String, dest: String) -> Result<(), Error>; + /// Write arbitrary bytes to some file `dest` on the test runner. + async fn write_file(dest: String, bytes: Vec<u8>) -> Result<(), Error>; + async fn reboot() -> Result<(), Error>; async fn set_mullvad_daemon_service_state(on: bool) -> Result<(), Error>; |
