File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed
Core/Auth/Repositories/TestHelpers
Platform/Application/Extensions Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,7 @@ class MockAuthRepository: AuthRepository { // swiftlint:disable:this type_body_l
57
57
var unlockVaultResult : Result < Void , Error > = . success( ( ) )
58
58
var unlockVaultWithBiometricsResult : Result < Void , Error > = . success( ( ) )
59
59
var unlockVaultWithDeviceKeyResult : Result < Void , Error > = . success( ( ) )
60
+ var unlockVaultWithNeverlockKeyCalled = false
60
61
var unlockVaultWithNeverlockResult : Result < Void , Error > = . success( ( ) )
61
62
var verifyOtpOpt : String ?
62
63
var verifyOtpResult : Result < Void , Error > = . success( ( ) )
@@ -266,7 +267,8 @@ class MockAuthRepository: AuthRepository { // swiftlint:disable:this type_body_l
266
267
}
267
268
268
269
func unlockVaultWithNeverlockKey( ) async throws {
269
- try unlockVaultWithNeverlockResult. get ( )
270
+ unlockVaultWithNeverlockKeyCalled = true
271
+ return try unlockVaultWithNeverlockResult. get ( )
270
272
}
271
273
272
274
/// Attempts to convert a possible user id into a known account id.
Original file line number Diff line number Diff line change @@ -711,6 +711,20 @@ final class AuthRouterTests: BitwardenTestCase { // swiftlint:disable:this type_
711
711
)
712
712
}
713
713
714
+ /// `handleAndRoute(_ :)` redirects `.didStart` to `.complete` and unlocks the vault if the
715
+ /// account never times out with a logout timeout action.
716
+ func test_handleAndRoute_didStart_neverLockLogout( ) async {
717
+ let account = Account . fixtureAccountLogin ( )
718
+ authRepository. activeAccount = account
719
+ authRepository. sessionTimeoutAction [ account. profile. userId] = . logout
720
+ vaultTimeoutService. vaultTimeout [ account. profile. userId] = . never
721
+
722
+ let route = await subject. handleAndRoute ( . didStart)
723
+
724
+ XCTAssertEqual ( route, . complete)
725
+ XCTAssertTrue ( authRepository. unlockVaultWithNeverlockKeyCalled)
726
+ }
727
+
714
728
/// `handleAndRoute(_ :)` redirects `.didStart` to `.landing`
715
729
/// when there are no accounts.
716
730
func test_handleAndRoute_didStart_noAccounts( ) async {
Original file line number Diff line number Diff line change @@ -209,9 +209,9 @@ extension AuthRouter {
209
209
}
210
210
211
211
// Check for a `logout` timeout action.
212
- let timeoutAction = try ? await services . authRepository
213
- . sessionTimeoutAction ( userId: activeAccount . profile . userId)
214
- if timeoutAction == . logout {
212
+ let userId = activeAccount . profile . userId
213
+ if await ( try ? services . authRepository . sessionTimeoutAction ( userId: userId) ) == . logout ,
214
+ await ( try ? services . vaultTimeoutService . sessionTimeoutValue ( userId : userId ) ) != . never {
215
215
return await handleAndRoute ( . didTimeout( userId: activeAccount. profile. userId) )
216
216
}
217
217
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ import XCTest
3
3
4
4
@testable import BitwardenShared
5
5
6
- // MARK: - UITabBarControllerTests
6
+ // MARK: - UITabBarControllerExtensionsTests
7
7
8
- class UITabBarControllerTests : BitwardenTestCase {
8
+ class UITabBarControllerExtensionsTests : BitwardenTestCase {
9
9
var module : MockAppModule !
10
10
var coordinator : TabCoordinator !
11
11
var rootNavigator : MockRootNavigator !
You can’t perform that action at this time.
0 commit comments