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/client.rs | |
| 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/client.rs')
| -rw-r--r-- | test/test-rpc/src/client.rs | 46 |
1 files changed, 46 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"); |
