Separate parser and helpers from Password class for better testability

This commit is contained in:
Danny Moesch 2018-11-11 18:09:52 +01:00 committed by Bob Sun
parent 2abbceb2e9
commit 7c12263458
17 changed files with 913 additions and 537 deletions

View file

@ -14,7 +14,7 @@ class EditPasswordTableViewController: PasswordEditorTableViewController {
tableData = [
[[.type: PasswordEditorCellType.nameCell, .title: "name", .content: password!.namePath]],
[[.type: PasswordEditorCellType.fillPasswordCell, .title: "password", .content: password!.password]],
[[.type: PasswordEditorCellType.additionsCell, .title: "additions", .content: password!.getAdditionsPlainText()]],
[[.type: PasswordEditorCellType.additionsCell, .title: "additions", .content: password!.additionsPlainText]],
[[.type: PasswordEditorCellType.scanQRCodeCell],
[.type: PasswordEditorCellType.deletePasswordCell]]
]

View file

@ -174,7 +174,7 @@ class GeneralSettingsTableViewController: BasicStaticTableViewController {
}
@objc func tapHideOTPSwitchDetailButton(_ sender: Any?) {
let keywordsString = Password.OTP_KEYWORDS.joined(separator: ",")
let keywordsString = Constants.OTP_KEYWORDS.joined(separator: ",")
let alertMessage = "Turn on this switch to hide the fields related to one time passwords (i.e., \(keywordsString))."
let alertTitle = "Hide One Time Password Fields"
Utils.alert(title: alertTitle, message: alertMessage, controller: self, completion: nil)

View file

@ -185,8 +185,7 @@ class PasswordEditorTableViewController: UITableViewController, FillPasswordTabl
// generate password, copy to pasteboard, and set the cell
// check whether the current password looks like an OTP field
func generateAndCopyPassword() {
if let currentPassword = fillPasswordCell?.getContent(),
Password.LooksLikeOTP(line: currentPassword) {
if let currentPassword = fillPasswordCell?.getContent(), Constants.isOtpRelated(line: currentPassword) {
let alert = UIAlertController(title: "Overwrite?", message: "Overwrite the one-time password configuration?", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Yes", style: UIAlertActionStyle.destructive, handler: {_ in
self.generateAndCopyPasswordNoOtpCheck()