forked from trustwallet/trust-wallet-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug/fix for lock bruteforce (trustwallet#878)
* Add UI fix for lock. Add fix for bruteforcing lock screen. * Remove responsibility of displaying and hiding keyboard of LockController from Coordinators. Adjust wrok of lock screen. * Add tests * Adjust tests for LockEnterPasscodeViewController * Remove optional type
- Loading branch information
Showing
10 changed files
with
102 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
TrustTests/Lock/ViewControllers/LockEnterPasscodeViewControllerTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// Copyright DApps Platform Inc. All rights reserved. | ||
|
||
import XCTest | ||
import KeychainSwift | ||
@testable import Trust | ||
|
||
class LockEnterPasscodeViewControllerTests: XCTestCase { | ||
|
||
let passcode = "123456" | ||
let incorrectPasscode = "111111" | ||
|
||
func testCorrectPasscodeInput() { | ||
let lock = Lock(keychain: KeychainSwift(keyPrefix: Constants.keychainTestsKeyPrefix)) | ||
let lockViewModel = LockEnterPasscodeViewModel(lock: lock) | ||
let vc = LockEnterPasscodeViewController(model: lockViewModel, lock: lock) | ||
vc.configureLockView() | ||
vc.configureInvisiblePasscodeField() | ||
|
||
lock.setPasscode(passcode: passcode) | ||
|
||
vc.enteredPasscode(passcode) | ||
|
||
XCTAssertTrue(lock.numberOfAttempts() == 0) | ||
} | ||
|
||
func testIncorrectPasscodeInput() { | ||
let lock = Lock(keychain: KeychainSwift(keyPrefix: Constants.keychainTestsKeyPrefix)) | ||
let lockViewModel = LockEnterPasscodeViewModel(lock: lock) | ||
let vc = LockEnterPasscodeViewController(model: lockViewModel, lock: lock) | ||
vc.configureLockView() | ||
vc.configureInvisiblePasscodeField() | ||
|
||
lock.setPasscode(passcode: passcode) | ||
|
||
vc.enteredPasscode(incorrectPasscode) | ||
|
||
XCTAssertTrue(lock.numberOfAttempts() > 0) | ||
} | ||
|
||
func testIncorrectPasscodeLimitInput() { | ||
let lock = Lock(keychain: KeychainSwift(keyPrefix: Constants.keychainTestsKeyPrefix)) | ||
|
||
XCTAssertFalse(lock.incorrectMaxAttemptTimeIsSet()) | ||
|
||
let lockViewModel = LockEnterPasscodeViewModel(lock: lock) | ||
let vc = LockEnterPasscodeViewController(model: lockViewModel, lock: lock) | ||
vc.configureLockView() | ||
vc.configureInvisiblePasscodeField() | ||
|
||
lock.setPasscode(passcode: passcode) | ||
|
||
while lock.numberOfAttempts() <= lockViewModel.passcodeAttemptLimit() { | ||
vc.enteredPasscode(incorrectPasscode) | ||
} | ||
|
||
XCTAssertTrue(lock.incorrectMaxAttemptTimeIsSet()) | ||
} | ||
|
||
} |