IOS-1740 add test for account password not updating in keychain IOS-1740
authorAlejandro Gelos <agp@pep.security>
Mon, 19 Aug 2019 13:42:48 +0200
branchIOS-1740
changeset 97232da4ad6faab3
parent 9721 0e4de3e65a40
child 9724 23a57a9beeb1
IOS-1740 add test for account password not updating in keychain
pEpForiOSTests/Models/Settings/AccountSettingsViewModelTest.swift
     1.1 --- a/pEpForiOSTests/Models/Settings/AccountSettingsViewModelTest.swift	Fri Aug 16 14:38:14 2019 +0200
     1.2 +++ b/pEpForiOSTests/Models/Settings/AccountSettingsViewModelTest.swift	Mon Aug 19 13:42:48 2019 +0200
     1.3 @@ -135,6 +135,24 @@
     1.4          waitForExpectations(timeout: UnitTestUtils.waitTime)
     1.5      }
     1.6  
     1.7 +    public func testSavePasswordAfterEndVerification() {
     1.8 +        // GIVEN
     1.9 +        setUpViewModel()
    1.10 +        let successResult: Result<Void, Error> = .success(())
    1.11 +        let expectedPassword = "passwordChanged"
    1.12 +        let imap = AccountSettingsViewModel.ServerViewModel(address: nil, port: nil, transport: nil)
    1.13 +        let smtp = AccountSettingsViewModel.ServerViewModel(address: nil, port: nil, transport: nil)
    1.14 +        viewModel.update(loginName: "", name: "", password: expectedPassword, imap: imap, smtp: smtp)
    1.15 +
    1.16 +        // WHEN
    1.17 +        viewModel.didEndVerification(result: successResult)
    1.18 +
    1.19 +        // THEN
    1.20 +        let connectionInfo = account.cdObject.imapConnectInfo
    1.21 +        let actualPassword = connectionInfo?.loginPassword
    1.22 +        XCTAssertEqual(actualPassword, expectedPassword)
    1.23 +    }
    1.24 +
    1.25  
    1.26      private func setUpViewModel() {
    1.27          account.save()