@@ -178,6 +178,37 @@ pub async fn test_upgrade_app(ctx: TestContext, rpc: ServiceClient) -> anyhow::R
178
178
Ok ( ( ) )
179
179
}
180
180
181
+ /// Install the app cleanly, failing if the installer doesn't succeed
182
+ /// or if the VPN service is not running afterwards.
183
+ #[ test_function( always_run = true , must_succeed = true , priority = -170 ) ]
184
+ pub async fn test_install_new_app ( _: TestContext , rpc : ServiceClient ) -> anyhow:: Result < ( ) > {
185
+ // verify that daemon is not already running
186
+ if rpc. mullvad_daemon_get_status ( ) . await ? != ServiceStatus :: NotRunning {
187
+ rpc. stop_mullvad_daemon ( ) . await . unwrap ( ) ;
188
+ }
189
+
190
+ // install package
191
+ log:: debug!( "Installing new app" ) ;
192
+ rpc. install_app ( get_package_desc ( & TEST_CONFIG . app_package_filename ) ?)
193
+ . await ?;
194
+
195
+ // verify that daemon is running
196
+ if rpc. mullvad_daemon_get_status ( ) . await ? != ServiceStatus :: Running {
197
+ bail ! ( Error :: DaemonNotRunning ) ;
198
+ }
199
+
200
+ // Set the log level to trace
201
+ rpc. set_daemon_log_level ( test_rpc:: mullvad_daemon:: Verbosity :: Trace )
202
+ . await ?;
203
+
204
+ replace_openvpn_cert ( & rpc) . await ?;
205
+
206
+ // Override env vars
207
+ rpc. set_daemon_environment ( get_app_env ( ) . await ?) . await ?;
208
+
209
+ Ok ( ( ) )
210
+ }
211
+
181
212
/// Uninstall the app version being tested. This verifies
182
213
/// that that the uninstaller works, and also that logs,
183
214
/// application files, system services are removed.
@@ -189,16 +220,24 @@ pub async fn test_upgrade_app(ctx: TestContext, rpc: ServiceClient) -> anyhow::R
189
220
/// Files due to Electron, temporary files, registry
190
221
/// values/keys, and device drivers are not guaranteed
191
222
/// to be deleted.
192
- #[ test_function( priority = -170 , cleanup = false ) ]
223
+ #[ test_function( priority = -160 , cleanup = false ) ]
193
224
pub async fn test_uninstall_app (
194
- _ : TestContext ,
225
+ _ctx : TestContext ,
195
226
rpc : ServiceClient ,
196
227
mut mullvad_client : MullvadProxyClient ,
197
228
) -> anyhow:: Result < ( ) > {
198
229
if rpc. mullvad_daemon_get_status ( ) . await ? != ServiceStatus :: Running {
199
230
bail ! ( Error :: DaemonNotRunning ) ;
200
231
}
201
232
233
+ // Clear devices before logging in
234
+ let device_client = super :: account:: new_device_client ( )
235
+ . await
236
+ . context ( "Failed to create device client" ) ?;
237
+ super :: account:: clear_devices ( & device_client)
238
+ . await
239
+ . context ( "failed to clear devices" ) ?;
240
+
202
241
// Login to test preservation of device/account
203
242
// TODO: Remove once we can login before upgrade above
204
243
mullvad_client
@@ -247,36 +286,8 @@ pub async fn test_uninstall_app(
247
286
uninstalled_device,
248
287
) ;
249
288
250
- Ok ( ( ) )
251
- }
252
-
253
- /// Install the app cleanly, failing if the installer doesn't succeed
254
- /// or if the VPN service is not running afterwards.
255
- #[ test_function( always_run = true , must_succeed = true , priority = -160 ) ]
256
- pub async fn test_install_new_app ( _: TestContext , rpc : ServiceClient ) -> anyhow:: Result < ( ) > {
257
- // verify that daemon is not already running
258
- if rpc. mullvad_daemon_get_status ( ) . await ? != ServiceStatus :: NotRunning {
259
- bail ! ( Error :: DaemonRunning ) ;
260
- }
261
-
262
- // install package
263
- log:: debug!( "Installing new app" ) ;
264
- rpc. install_app ( get_package_desc ( & TEST_CONFIG . app_package_filename ) ?)
265
- . await ?;
266
-
267
- // verify that daemon is running
268
- if rpc. mullvad_daemon_get_status ( ) . await ? != ServiceStatus :: Running {
269
- bail ! ( Error :: DaemonNotRunning ) ;
270
- }
271
-
272
- // Set the log level to trace
273
- rpc. set_daemon_log_level ( test_rpc:: mullvad_daemon:: Verbosity :: Trace )
274
- . await ?;
275
-
276
- replace_openvpn_cert ( & rpc) . await ?;
277
-
278
- // Override env vars
279
- rpc. set_daemon_environment ( get_app_env ( ) . await ?) . await ?;
289
+ // Re-install the app to ensure that the next test can run
290
+ test_install_new_app ( _ctx, rpc) . await ?;
280
291
281
292
Ok ( ( ) )
282
293
}
0 commit comments