IOS-1518 Move DecryptImportedMessagesTests. IOS-1518
authorDirk Zimmermann <dz@pep.security>
Tue, 14 May 2019 16:19:30 +0200
branchIOS-1518
changeset 8604c1a6caacbdcf
parent 8603 b2a9c31628ad
child 8605 08ec251b0223
IOS-1518 Move DecryptImportedMessagesTests.
pEpForiOS.xcodeproj/project.pbxproj
pEpForiOSTests/DecryptImportedMessagesTests.swift
pEpForiOSTests/TestUtils/DecryptionUtil.swift
     1.1 --- a/pEpForiOS.xcodeproj/project.pbxproj	Tue May 14 16:19:30 2019 +0200
     1.2 +++ b/pEpForiOS.xcodeproj/project.pbxproj	Tue May 14 16:19:30 2019 +0200
     1.3 @@ -319,7 +319,6 @@
     1.4  		43C273DD21C9024A002EB4C8 /* LoggerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C273DC21C9024A002EB4C8 /* LoggerTest.swift */; };
     1.5  		43C322051EA89EED005073FB /* HandshakePartnerTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C322041EA89EED005073FB /* HandshakePartnerTableViewCell.swift */; };
     1.6  		43C322091EA90192005073FB /* PEP+UI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C322081EA90192005073FB /* PEP+UI.swift */; };
     1.7 -		43C3B1602003851100ED48A4 /* DecryptImportedMessagesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C3B15F2003851100ED48A4 /* DecryptImportedMessagesTests.swift */; };
     1.8  		43C3B1622003896800ED48A4 /* IOS-884_001_Mail_from_P4A.txt in Resources */ = {isa = PBXBuildFile; fileRef = 43C3B1612003896800ED48A4 /* IOS-884_001_Mail_from_P4A.txt */; };
     1.9  		43C3B16820038B2500ED48A4 /* IOS-884_001_test010@peptest.ch.pub.key in Resources */ = {isa = PBXBuildFile; fileRef = 43C3B16520038B2500ED48A4 /* IOS-884_001_test010@peptest.ch.pub.key */; };
    1.10  		43C7B9D11CEC4DDF007A612F /* MiscTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43C7B9D01CEC4DDF007A612F /* MiscTests.swift */; };
    1.11 @@ -361,7 +360,6 @@
    1.12  		43E74C741E38DE2200A2F7A6 /* ImapFlagsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43E74C731E38DE2200A2F7A6 /* ImapFlagsTests.swift */; };
    1.13  		43EC75AC2164C26100048CFE /* SetOwnKeyViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EC75AB2164C26100048CFE /* SetOwnKeyViewController.swift */; };
    1.14  		43EC75AE2164D03500048CFE /* SetOwnKeyViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EC75AD2164D03500048CFE /* SetOwnKeyViewModel.swift */; };
    1.15 -		43EC75B32164E97800048CFE /* DecryptionUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EC75B22164E97800048CFE /* DecryptionUtil.swift */; };
    1.16  		43EC75B52164F19B00048CFE /* SetOwnKeyViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43EC75B42164F19B00048CFE /* SetOwnKeyViewModelTests.swift */; };
    1.17  		43ED536F1CC77F95006AB156 /* EmailListViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43ED53631CC77F95006AB156 /* EmailListViewCell.swift */; };
    1.18  		43ED53701CC77F95006AB156 /* EmailListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43ED53641CC77F95006AB156 /* EmailListViewController.swift */; };
    1.19 @@ -826,7 +824,6 @@
    1.20  		43C273DC21C9024A002EB4C8 /* LoggerTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoggerTest.swift; sourceTree = "<group>"; };
    1.21  		43C322041EA89EED005073FB /* HandshakePartnerTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HandshakePartnerTableViewCell.swift; sourceTree = "<group>"; };
    1.22  		43C322081EA90192005073FB /* PEP+UI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "PEP+UI.swift"; sourceTree = "<group>"; };
    1.23 -		43C3B15F2003851100ED48A4 /* DecryptImportedMessagesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecryptImportedMessagesTests.swift; sourceTree = "<group>"; };
    1.24  		43C3B1612003896800ED48A4 /* IOS-884_001_Mail_from_P4A.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "IOS-884_001_Mail_from_P4A.txt"; sourceTree = "<group>"; };
    1.25  		43C3B16520038B2500ED48A4 /* IOS-884_001_test010@peptest.ch.pub.key */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "IOS-884_001_test010@peptest.ch.pub.key"; sourceTree = "<group>"; };
    1.26  		43C7B9D01CEC4DDF007A612F /* MiscTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MiscTests.swift; sourceTree = "<group>"; };
    1.27 @@ -866,7 +863,6 @@
    1.28  		43E74C731E38DE2200A2F7A6 /* ImapFlagsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImapFlagsTests.swift; sourceTree = "<group>"; };
    1.29  		43EC75AB2164C26100048CFE /* SetOwnKeyViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetOwnKeyViewController.swift; sourceTree = "<group>"; };
    1.30  		43EC75AD2164D03500048CFE /* SetOwnKeyViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetOwnKeyViewModel.swift; sourceTree = "<group>"; };
    1.31 -		43EC75B22164E97800048CFE /* DecryptionUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DecryptionUtil.swift; sourceTree = "<group>"; };
    1.32  		43EC75B42164F19B00048CFE /* SetOwnKeyViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SetOwnKeyViewModelTests.swift; sourceTree = "<group>"; };
    1.33  		43ED53631CC77F95006AB156 /* EmailListViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailListViewCell.swift; sourceTree = "<group>"; };
    1.34  		43ED53641CC77F95006AB156 /* EmailListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmailListViewController.swift; sourceTree = "<group>"; };
    1.35 @@ -1057,7 +1053,6 @@
    1.36  				495F689921E6600500A10C63 /* ScreenshotTestUtil.swift */,
    1.37  				43D3378F21A3F32500E40114 /* ImapUtil.swift */,
    1.38  				49A6114D2179F3A1006BA3C5 /* UnitTestUtils.swift */,
    1.39 -				43EC75B22164E97800048CFE /* DecryptionUtil.swift */,
    1.40  				437795C72154D6FD00CC62C2 /* PEPMessage+TestExtension.swift */,
    1.41  				15D439A6216FB77600EB3933 /* UnitTestUtils.swift */,
    1.42  				15410D1E2199CA1100BBF65F /* XCTTestCase+Utils.swift */,
    1.43 @@ -1775,7 +1770,6 @@
    1.44  				43EE994D1E4392530060EACE /* FlagImageTests.swift */,
    1.45  				438281821E891B7E00087343 /* DateTests.swift */,
    1.46  				43FAA0D31EC9CBC0005BFC4B /* DecryptionTestsInternal.swift */,
    1.47 -				43C3B15F2003851100ED48A4 /* DecryptImportedMessagesTests.swift */,
    1.48  				431E58FB1ED5926B00EFA77F /* AccountVerificationServiceTests.swift */,
    1.49  				436795F71EE98B9A00B03E23 /* MessageReevalutionTests.swift */,
    1.50  				43F7F0791F6AD44600BDF151 /* HandshakeTests.swift */,
    1.51 @@ -2959,7 +2953,6 @@
    1.52  				1526597D21637759006A78DF /* SuggestViewModelTest.swift in Sources */,
    1.53  				43FAA0D41EC9CBC0005BFC4B /* DecryptionTestsInternal.swift in Sources */,
    1.54  				F73E4F72217F238300CCFFED /* FolderSectionViewModelTests.swift in Sources */,
    1.55 -				43EC75B32164E97800048CFE /* DecryptionUtil.swift in Sources */,
    1.56  				43C7B9D11CEC4DDF007A612F /* MiscTests.swift in Sources */,
    1.57  				434DDC2B20D10F9A00755F44 /* EncryptionTests.swift in Sources */,
    1.58  				151F71FA202A06760057C74D /* DecryptionAttemptCounterDelegate.swift in Sources */,
    1.59 @@ -2983,7 +2976,6 @@
    1.60  				B7F4A793212DDFC500507B76 /* EmailListViewModelTest.swift in Sources */,
    1.61  				151F71FC202A06760057C74D /* CoreDataDrivenTestBase.swift in Sources */,
    1.62  				151F71FF202A06760057C74D /* Message+TestUtils.swift in Sources */,
    1.63 -				43C3B1602003851100ED48A4 /* DecryptImportedMessagesTests.swift in Sources */,
    1.64  				432F7D611D2102F10094F097 /* PEPSessionTest.swift in Sources */,
    1.65  				49DCCD2821E8ABDF00ABE487 /* ScreenshotTestUtil.swift in Sources */,
    1.66  				157743B8217885EA0007222C /* RecipientTextViewModelTest.swift in Sources */,
     2.1 --- a/pEpForiOSTests/DecryptImportedMessagesTests.swift	Tue May 14 16:19:30 2019 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,247 +0,0 @@
     2.4 -//
     2.5 -//  DecryptImportedMessagesTests.swift
     2.6 -//  pEpForiOSTests
     2.7 -//
     2.8 -//  Created by Dirk Zimmermann on 08.01.18.
     2.9 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    2.10 -//
    2.11 -
    2.12 -import XCTest
    2.13 -
    2.14 -@testable import pEpForiOS
    2.15 -@testable import MessageModel
    2.16 -import PEPObjCAdapterFramework
    2.17 -
    2.18 -class DecryptImportedMessagesTests: XCTestCase {
    2.19 -    var persistentSetup: PersistentSetup!
    2.20 -    var session: PEPSession {
    2.21 -        return PEPSession()
    2.22 -    }
    2.23 -    var backgroundQueue: OperationQueue!
    2.24 -
    2.25 -    // MARK: - setUp, tearDown
    2.26 -
    2.27 -    override func setUp() {
    2.28 -        super.setUp()
    2.29 -
    2.30 -        XCTAssertTrue(PEPUtil.pEpClean())
    2.31 -
    2.32 -        persistentSetup = PersistentSetup()
    2.33 -
    2.34 -        self.backgroundQueue = OperationQueue()
    2.35 -    }
    2.36 -
    2.37 -    override func tearDown() {
    2.38 -        persistentSetup = nil
    2.39 -        backgroundQueue.cancelAllOperations()
    2.40 -        backgroundQueue = nil
    2.41 -        PEPSession.cleanup()
    2.42 -        super.tearDown()
    2.43 -    }
    2.44 -
    2.45 -    // MARK: - Tests
    2.46 -
    2.47 -    /**
    2.48 -     IOS-1300
    2.49 -     */
    2.50 -    func testDecrypt002() {
    2.51 -        let cdOwnAccount = DecryptionUtil.createLocalAccount(ownUserName: "Someonei",
    2.52 -                                                             ownUserID: "User_Someonei",
    2.53 -                                                             ownEmailAddress: "someone@gmx.de")
    2.54 -        self.backgroundQueue = OperationQueue()
    2.55 -        let cdMessage = DecryptionUtil.decryptTheMessage(
    2.56 -            testCase: self,
    2.57 -            backgroundQueue: backgroundQueue,
    2.58 -            cdOwnAccount: cdOwnAccount,
    2.59 -            fileName: "IOS-1300_odt_attachment.txt")
    2.60 -
    2.61 -        guard let theCdMessage = cdMessage else {
    2.62 -            XCTFail()
    2.63 -            return
    2.64 -        }
    2.65 -
    2.66 -        XCTAssertEqual(theCdMessage.pEpRating, Int16(PEPRating.unencrypted.rawValue))
    2.67 -        XCTAssertEqual(theCdMessage.shortMessage, "needed")
    2.68 -
    2.69 -        let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
    2.70 -        XCTAssertEqual(attachments.count, 1)
    2.71 -
    2.72 -        let attachment1 = attachments[0]
    2.73 -        XCTAssertEqual(attachment1.mimeType, "application/vnd.oasis.opendocument.text")
    2.74 -        XCTAssertEqual(attachment1.fileName, "cid://253d226f-4e3a-b37f-4809-16cdc02f39e1@yahoo.com")
    2.75 -    }
    2.76 -
    2.77 -    /**
    2.78 -     IOS-1364
    2.79 -     */
    2.80 -    func testDecryptUndisplayedAttachedJpegMessage() {
    2.81 -        let cdOwnAccount = DecryptionUtil.createLocalAccount(
    2.82 -            ownUserName: "ThisIsMe",
    2.83 -            ownUserID: "User_Me",
    2.84 -            ownEmailAddress: "iostest001@peptest.ch")
    2.85 -
    2.86 -        self.backgroundQueue = OperationQueue()
    2.87 -        let cdMessage = DecryptionUtil.decryptTheMessage(
    2.88 -            testCase: self,
    2.89 -            backgroundQueue: backgroundQueue,
    2.90 -            cdOwnAccount: cdOwnAccount,
    2.91 -            fileName: "1364_Mail_missing_attached_image.txt")
    2.92 -
    2.93 -        guard let theCdMessage = cdMessage else {
    2.94 -            XCTFail()
    2.95 -            return
    2.96 -        }
    2.97 -
    2.98 -        XCTAssertEqual(theCdMessage.pEpRating, Int16(PEPRating.unencrypted.rawValue))
    2.99 -        XCTAssertEqual(theCdMessage.shortMessage, "blah")
   2.100 -        XCTAssertEqual(theCdMessage.longMessage, "\n\n")
   2.101 -
   2.102 -        let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
   2.103 -        XCTAssertEqual(attachments.count, 2)
   2.104 -        check(attachments: attachments)
   2.105 -    }
   2.106 -
   2.107 -    /**
   2.108 -     IOS-1378
   2.109 -     - Note: If you need to manually verify something:
   2.110 -       * The public/secret key pair of Leon Kowalski (subject)
   2.111 -         is in `Leon Kowalski (19B9EE3B) – Private.asc`.
   2.112 -       * The public/secret key pair of Harry Bryant (sender) is in
   2.113 -         `Harry Bryant iostest002@peptest.ch (0x5716EA2D9AE32468) pub-sec.asc`.
   2.114 -     */
   2.115 -    func testSetOwnKey() {
   2.116 -        let cdOwnAccount = DecryptionUtil.createLocalAccount(
   2.117 -            ownUserName: "Rick Deckard",
   2.118 -            ownUserID: "rick_deckard_uid",
   2.119 -            ownEmailAddress: "iostest001@peptest.ch")
   2.120 -
   2.121 -        try! TestUtil.importKeyByFileName(fileName: "Rick Deckard (EB50C250) – Private.asc")
   2.122 -
   2.123 -        try! session.setOwnKey(cdOwnAccount.pEpIdentity(),
   2.124 -                               fingerprint: "456B937ED6D5806935F63CE5548738CCEB50C250")
   2.125 -
   2.126 -        self.backgroundQueue = OperationQueue()
   2.127 -        let cdMessage = DecryptionUtil.decryptTheMessage(
   2.128 -            testCase: self,
   2.129 -            backgroundQueue: backgroundQueue,
   2.130 -            cdOwnAccount: cdOwnAccount,
   2.131 -            fileName: "SimplifiedKeyImport_Harry_To_Rick_with_Leon.txt")
   2.132 -
   2.133 -        guard let theCdMessage = cdMessage else {
   2.134 -            XCTFail()
   2.135 -            return
   2.136 -        }
   2.137 -
   2.138 -        // After ENGINE-465 is done, this should be .reliable
   2.139 -        XCTAssertEqual(theCdMessage.pEpRating, Int16(PEPRating.unreliable.rawValue))
   2.140 -
   2.141 -        XCTAssertEqual(theCdMessage.shortMessage, "Simplified Key Import")
   2.142 -        XCTAssertEqual(
   2.143 -            theCdMessage.longMessage,
   2.144 -            "iostest003@peptest.ch\nLeon Kowalski\n63FC29205A57EB3AEB780E846F239B0F19B9EE3B\n\nSee the key of Leon attached.\n")
   2.145 -
   2.146 -        let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
   2.147 -        XCTAssertEqual(attachments.count, 0)
   2.148 -
   2.149 -        let leon = PEPIdentity(address: "iostest002@peptest.ch",
   2.150 -                               userID: CdIdentity.pEpOwnUserID,
   2.151 -                               userName: "Leon Kowalski",
   2.152 -                               isOwn: true)
   2.153 -        try! session.update(leon)
   2.154 -
   2.155 -        try! session.setOwnKey(leon, fingerprint: "63FC29205A57EB3AEB780E846F239B0F19B9EE3B")
   2.156 -    }
   2.157 -
   2.158 -    // ENGINE-505
   2.159 -    /*
   2.160 -    func testNullInnerMimeType() {
   2.161 -        let cdOwnAccount = DecryptionUtil.createLocalAccount(
   2.162 -            ownUserName: "ThisIsMe",
   2.163 -            ownUserID: "User_Me",
   2.164 -            ownEmailAddress: "guile-user@gnu.org")
   2.165 -
   2.166 -        self.backgroundQueue = OperationQueue()
   2.167 -        let cdMessage = DecryptionUtil.decryptTheMessage(
   2.168 -            testCase: self,
   2.169 -            backgroundQueue: backgroundQueue,
   2.170 -            cdOwnAccount: cdOwnAccount,
   2.171 -            fileName: "ENGINE-505_Mail_NullInnerMimeType.txt")
   2.172 -
   2.173 -        guard let theCdMessage = cdMessage else {
   2.174 -            XCTFail()
   2.175 -            return
   2.176 -        }
   2.177 -
   2.178 -        XCTAssertEqual(theCdMessage.pEpRating, Int16(.unencrypted.rawValue))
   2.179 -        XCTAssertEqual(theCdMessage.shortMessage,
   2.180 -                       "Re: Help needed debugging segfault with Guile 1.8.7")
   2.181 -        XCTAssertNil(theCdMessage.longMessage)
   2.182 -
   2.183 -        let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
   2.184 -        XCTAssertEqual(attachments.count, 2)
   2.185 -
   2.186 -        guard let msg = theCdMessage.message() else {
   2.187 -            XCTFail()
   2.188 -            return
   2.189 -        }
   2.190 -
   2.191 -        XCTAssertEqual(msg.attachments.count, 1)
   2.192 -    }
   2.193 -     */
   2.194 -
   2.195 -    // ENGINE-456 / IOS-1258
   2.196 -    /*
   2.197 -    func test_ENGINE_459() {
   2.198 -        let cdOwnAccount = DecryptionUtil.createLocalAccount(
   2.199 -            ownUserName: "ThisIsMe",
   2.200 -            ownUserID: "User_Me",
   2.201 -            ownEmailAddress: "iostest010@peptest.ch")
   2.202 -
   2.203 -        self.backgroundQueue = OperationQueue()
   2.204 -        let cdMessage = DecryptionUtil.decryptTheMessage(
   2.205 -            testCase: self,
   2.206 -            backgroundQueue: backgroundQueue,
   2.207 -            cdOwnAccount: cdOwnAccount,
   2.208 -            fileName: "ENGINE-456_Mail_PEP_OUT_OF_MEMORY.txt")
   2.209 -
   2.210 -        guard let theCdMessage = cdMessage else {
   2.211 -            XCTFail()
   2.212 -            return
   2.213 -        }
   2.214 -
   2.215 -        XCTAssertEqual(theCdMessage.pEpRating, Int16(.unencrypted.rawValue))
   2.216 -        XCTAssertEqual(theCdMessage.shortMessage,
   2.217 -                       "Re: Help needed debugging segfault with Guile 1.8.7")
   2.218 -        XCTAssertNil(theCdMessage.longMessage)
   2.219 -
   2.220 -        let attachments = theCdMessage.attachments?.array as? [CdAttachment] ?? []
   2.221 -        XCTAssertEqual(attachments.count, 2)
   2.222 -
   2.223 -        guard let msg = theCdMessage.message() else {
   2.224 -            XCTFail()
   2.225 -            return
   2.226 -        }
   2.227 -
   2.228 -        XCTAssertEqual(msg.attachments.count, 1)
   2.229 -    }
   2.230 -     */
   2.231 -
   2.232 -    // MARK: - Helpers
   2.233 -
   2.234 -    func check(attachments: [CdAttachment]) {
   2.235 -        for i in 0..<attachments.count {
   2.236 -            let theAttachment = attachments[i]
   2.237 -            if i == 0 {
   2.238 -                XCTAssertEqual(theAttachment.mimeType, "image/jpeg")
   2.239 -            } else if i == 1 {
   2.240 -                XCTAssertEqual(theAttachment.mimeType, "text/plain")
   2.241 -                guard let theData = theAttachment.data,
   2.242 -                    let dataString = String(data: theData, encoding: .utf8)  else {
   2.243 -                        XCTFail()
   2.244 -                        continue
   2.245 -                }
   2.246 -                XCTAssertEqual(dataString, "\n\nSent from my iPhone")
   2.247 -            }
   2.248 -        }
   2.249 -    }
   2.250 -}
     3.1 --- a/pEpForiOSTests/TestUtils/DecryptionUtil.swift	Tue May 14 16:19:30 2019 +0200
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,86 +0,0 @@
     3.4 -//
     3.5 -//  DecryptionUtil.swift
     3.6 -//  pEpForiOSTests
     3.7 -//
     3.8 -//  Created by Dirk Zimmermann on 03.10.18.
     3.9 -//  Copyright © 2018 p≡p Security S.A. All rights reserved.
    3.10 -//
    3.11 -
    3.12 -import Foundation
    3.13 -import XCTest
    3.14 -
    3.15 -@testable import pEpForiOS
    3.16 -@testable import MessageModel
    3.17 -
    3.18 -class DecryptionUtil {
    3.19 -    public static func decryptTheMessage(
    3.20 -        testCase: XCTestCase,
    3.21 -        backgroundQueue: OperationQueue,
    3.22 -        cdOwnAccount: CdAccount,
    3.23 -        fileName: String,
    3.24 -        checkCdMessage: ((CdMessage) -> ())? = nil) -> CdMessage? {
    3.25 -        guard let cdMessage = TestUtil.cdMessage(
    3.26 -            fileName: fileName,
    3.27 -            cdOwnAccount: cdOwnAccount) else {
    3.28 -                XCTFail()
    3.29 -                return nil
    3.30 -        }
    3.31 -
    3.32 -        if let theChecker = checkCdMessage {
    3.33 -            theChecker(cdMessage)
    3.34 -        }
    3.35 -
    3.36 -        let expDecrypted = testCase.expectation(description: "expDecrypted")
    3.37 -        let errorContainer = ErrorContainer()
    3.38 -        let decryptOperation = DecryptMessagesOperation(
    3.39 -            parentName: #function, errorContainer: errorContainer)
    3.40 -        decryptOperation.completionBlock = {
    3.41 -            decryptOperation.completionBlock = nil
    3.42 -            expDecrypted.fulfill()
    3.43 -        }
    3.44 -        let decryptDelegate = DecryptionAttemptCounterDelegate()
    3.45 -        decryptOperation.delegate = decryptDelegate
    3.46 -        backgroundQueue.addOperation(decryptOperation)
    3.47 -
    3.48 -        testCase.waitForExpectations(timeout: TestUtil.waitTime) { error in
    3.49 -            XCTAssertNil(error)
    3.50 -        }
    3.51 -
    3.52 -        XCTAssertEqual(decryptDelegate.numberOfMessageDecryptAttempts, 1)
    3.53 -        Record.Context.main.refreshAllObjects()
    3.54 -
    3.55 -        guard
    3.56 -            let cdRecipients = cdMessage.to?.array as? [CdIdentity],
    3.57 -            cdRecipients.count == 1,
    3.58 -            let recipientIdentity = cdRecipients[0].identity()
    3.59 -            else {
    3.60 -                XCTFail()
    3.61 -                return cdMessage
    3.62 -        }
    3.63 -        XCTAssertTrue(recipientIdentity.isMySelf)
    3.64 -
    3.65 -        guard let theSenderIdentity = cdMessage.from?.identity() else {
    3.66 -            XCTFail()
    3.67 -            return cdMessage
    3.68 -        }
    3.69 -        XCTAssertFalse(theSenderIdentity.isMySelf)
    3.70 -
    3.71 -        return cdMessage
    3.72 -    }
    3.73 -
    3.74 -    public static func createLocalAccount(ownUserName: String, ownUserID: String,
    3.75 -                                          ownEmailAddress: String) -> CdAccount {
    3.76 -        let cdOwnAccount = SecretTestData().createWorkingCdAccount(number: 0)
    3.77 -        cdOwnAccount.identity?.userName = ownUserName
    3.78 -        cdOwnAccount.identity?.userID = ownUserID
    3.79 -        cdOwnAccount.identity?.address = ownEmailAddress
    3.80 -
    3.81 -        let cdInbox = CdFolder.create()
    3.82 -        cdInbox.name = ImapSync.defaultImapInboxName
    3.83 -        cdInbox.uuid = MessageID.generate()
    3.84 -        cdInbox.account = cdOwnAccount
    3.85 -        Record.saveAndWait()
    3.86 -
    3.87 -        return cdOwnAccount
    3.88 -    }
    3.89 -}