Commit cf580ef7 authored by Oliver Wiese's avatar Oliver Wiese
Browse files

fix testcases, add new testcase for moving mails, fix bug move mail

parent b84383ee
......@@ -534,7 +534,7 @@
}
if let uidValidity = fromFolder.uidValidity as? UInt32 {
self.moveOnServer(uidValidity: uidValidity, mails: mails, fromPath: fromPath, toPath: toPath, completionHandler: {error in
print("Move mails from \(fromFolder) to \(toPath) complete with error \(error)")})
print("Move mails from \(fromFolder) to \(toPath) complete with error \(String(describing: error))")})
// 4. Move mail in core data
self.dataProvider.moveMails(with: mails, from: fromPath, to: toPath)
}
......
......@@ -490,6 +490,7 @@ class PersistentDataProvider {
}
guard let toFolder = generateFetchedFolderResultsController(folderpath: to, moc: rfc.managedObjectContext).fetchedObjects?.first else {
importNewData(from: [FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: to, parent: nil, children: nil)], completionHandler: {_ in self.moveMails(with: uids, from: from, to: to)})
moveMails(with: uids, from: from, to: to)
return
}
if let mails = rfc.fetchedObjects as? [MailRecord] {
......
......@@ -67,7 +67,7 @@ class AutocryptTest: XCTestCase {
super.setUp()
pgp.resetKeychains()
let deleteExpectation = expectation(description: "Delete all data!")
PersitentDataProvider.dataProvider.deleteAll(completionHandler: {error in
PersistentDataProvider.dataProvider.deleteAll(completionHandler: {error in
if let error = error {
XCTFail("Error while importing addresses! \(error)")
}
......@@ -138,7 +138,7 @@ class AutocryptTest: XCTestCase {
}
func testAutocryptHeader(){
let outmail = OutgoingMail(toEntrys: ["alice@example.com"], ccEntrys: [], bccEntrys: [], subject: "subject", textContent: "Body", htmlContent: nil)
let outmail = OutgoingMail(toAddresses: ["alice@example.com"], ccAddresses: [], bccAddresses: [], subject: "subject", textContent: "Body", htmlContent: nil)
if let parser = MCOMessageParser(data: outmail.plainData), let _ = pgp.exportKey(id: userKeyID, isSecretkey: false, autocrypt: false) {
let autocrypt = Autocrypt.init(header: parser.header)
XCTAssertEqual(autocrypt.addr, userAdr)
......
......@@ -10,10 +10,10 @@ import XCTest
@testable import enzevalos_iphone
class CoreAddressTest: XCTestCase {
var provider = PersitentDataProvider()
var provider = PersistentDataProvider()
private func deleteAll() {
provider = PersitentDataProvider()
provider = PersistentDataProvider()
let deleteExpectation = expectation(description: "Delete all data!")
provider.deleteAll(completionHandler: {error in
if let error = error {
......@@ -25,7 +25,7 @@ class CoreAddressTest: XCTestCase {
provider.reset()
let frc = provider.fetchedAddressResultController
XCTAssertEqual(frc.fetchedObjects?.count ?? 0, 0)
provider = PersitentDataProvider()
provider = PersistentDataProvider()
}
override func setUpWithError() throws {
......
......@@ -11,11 +11,11 @@ import XCTest
@testable import enzevalos_iphone
class CoreKeysTest: XCTestCase {
var provider = PersitentDataProvider()
var provider = PersistentDataProvider()
let email = "vic@example.com"
private func deleteAll() {
provider = PersitentDataProvider()
provider = PersistentDataProvider()
let deleteExpectation = expectation(description: "Delete all data!")
provider.deleteAll(completionHandler: {error in
if let error = error {
......@@ -27,7 +27,7 @@ class CoreKeysTest: XCTestCase {
provider.reset()
let frc = provider.fetchedMailResultsController
XCTAssertEqual(frc.fetchedObjects?.count ?? 0, 0)
provider = PersitentDataProvider()
provider = PersistentDataProvider()
}
override func setUpWithError() throws {
......
......@@ -17,12 +17,12 @@ import XCTest
@testable import enzevalos_iphone
class CoreMailTest: XCTestCase {
var provider = PersitentDataProvider()
var provider = PersistentDataProvider()
let path = "Testfolder"
private func deleteAll() {
provider = PersitentDataProvider()
provider = PersistentDataProvider()
let deleteExpectation = expectation(description: "Delete all data!")
provider.deleteAll(completionHandler: {error in
if let error = error {
......@@ -34,7 +34,7 @@ class CoreMailTest: XCTestCase {
provider.reset()
let frc = provider.fetchedMailResultsController
XCTAssertEqual(frc.fetchedObjects?.count ?? 0, 0)
provider = PersitentDataProvider()
provider = PersistentDataProvider()
}
override func setUpWithError() throws {
......@@ -56,8 +56,8 @@ class CoreMailTest: XCTestCase {
let importExpectation = expectation(description: "Import new msg!")
let m1 = MailProperties(messageID: "1", subject: "MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0, attachedPublicKeys: [], attachedSecretKeys: [])
let m2 = MailProperties(messageID: "2", subject: "MSG2", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m1 = MailProperties(messageID: "1", uid: UInt64(arc4random()), subject: "MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0, attachedPublicKeys: [], attachedSecretKeys: [])
let m2 = MailProperties(messageID: "2", uid: UInt64(arc4random()), subject: "MSG2", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
provider.importNewData(from: [m1,m2], completionHandler: {error in
if let error = error {
......@@ -91,8 +91,8 @@ class CoreMailTest: XCTestCase {
let addr1 = AddressProperties(email: "vic@example.com")
let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
let m1 = MailProperties(messageID: "1", subject: "MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m2 = MailProperties(messageID: "1", subject: "Second MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m1 = MailProperties(messageID: "1", uid: UInt64(arc4random()), subject: "MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m2 = MailProperties(messageID: "1", uid: UInt64(arc4random()), subject: "Second MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
provider.reset()
let frc = provider.fetchedMailResultsController
......@@ -123,8 +123,8 @@ class CoreMailTest: XCTestCase {
let addr1 = AddressProperties(email: "vic@example.com")
let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
let m1 = MailProperties(messageID: "1", subject: "MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m2 = MailProperties(messageID: "1", subject: "Second MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m1 = MailProperties(messageID: "1", uid: UInt64(arc4random()), subject: "MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
let m2 = MailProperties(messageID: "1", uid: UInt64(arc4random()), subject: "Second MSG1", date: Date(), flags: 0, from: addr1, folder: folder, signatureState: 0, encryptionState: 0)
provider.reset()
let frc = provider.fetchedMailResultsController
......@@ -177,7 +177,7 @@ class CoreMailTest: XCTestCase {
var msgs = [MailProperties]()
for i in 1...n {
let a = addrs[i%addrs.count]
let m = MailProperties(messageID: "\(i)", subject: "MSG\(i)", date: Date(), flags: 0, from: a, folder: folder, signatureState: 0, encryptionState: 0)
let m = MailProperties(messageID: "\(i)", uid: UInt64(arc4random()), subject: "MSG\(i)", date: Date(), flags: 0, from: a, folder: folder, signatureState: 0, encryptionState: 0)
msgs.append(m)
}
......@@ -212,9 +212,7 @@ class CoreMailTest: XCTestCase {
}
private func generateMails() -> Int {
let n = 100
let m = 10
private func generateMails(n: Int = 100, m: Int = 10) -> Int {
var k = 1
let addr1 = AddressProperties(email: "vic@example.com")
......@@ -228,7 +226,7 @@ class CoreMailTest: XCTestCase {
var msgs = [MailProperties]()
for i in 1...n {
let a = addrs[i%addrs.count]
let msg = MailProperties(messageID: "\(k)", subject: "MSG\(k)", date: Date(), flags: 0, from: a, folder: folder, signatureState: 0, encryptionState: 0)
let msg = MailProperties(messageID: "\(k)", uid: UInt64(arc4random()), subject: "MSG\(k)", date: Date(), flags: 0, from: a, folder: folder, signatureState: 0, encryptionState: 0)
k = k + 1
res = res + 1
msgs.append(msg)
......@@ -279,8 +277,8 @@ class CoreMailTest: XCTestCase {
var n = generateMails()
let genMails = n
// CONSIDER FETCHLIMIT!
if n > PersitentDataProvider.FETCHLIMIT {
n = PersitentDataProvider.FETCHLIMIT
if n > PersistentDataProvider.FETCHLIMIT {
n = PersistentDataProvider.FETCHLIMIT
}
let frc = provider.generateFetchedMailsInFolderResultsController(folderpath: path)
try? frc.performFetch()
......@@ -302,4 +300,25 @@ class CoreMailTest: XCTestCase {
XCTAssertEqual(folder.mailsInFolder?.count ?? -1, genMails)
}
}
func testMoveMail() {
let n = generateMails(n: 100, m: 1)
let folderPath2 = "Testfolder2"
let frc = provider.generateFetchedMailsInFolderResultsController(folderpath: path)
try? frc.performFetch()
if let mails = frc.fetchedObjects {
XCTAssertEqual(mails.count, n)
if let mail = mails.first {
provider.moveMails(with: [UInt64(mail.uID)], from: path, to: folderPath2)
try? frc.performFetch()
XCTAssertEqual(frc.fetchedObjects?.count ?? 0,( n - 1))
let frc2 = provider.generateFetchedMailsInFolderResultsController(folderpath: folderPath2)
XCTAssertEqual(frc2.fetchedObjects?.count ?? 0, 1)
}
}
else {
XCTFail("No mails...")
}
}
}
......@@ -390,7 +390,7 @@ class CryptoTests: XCTestCase {
"""
private func deleteAll() {
let provider = PersitentDataProvider()
let provider = PersistentDataProvider()
let deleteExpectation = expectation(description: "Delete all data!")
provider.deleteAll(completionHandler: {error in
if let error = error {
......@@ -575,7 +575,7 @@ class CryptoTests: XCTestCase {
SecretKeyProperties(fingerprint: $0, cryptoProtocol: .PGP, usedAddresses: [AddressProperties(email: userAdr)])
})
let importExpectation = expectation(description: "Import secret keys")
PersitentDataProvider.dataProvider.importNewData(from: properties, completionHandler: {error in
PersistentDataProvider.dataProvider.importNewData(from: properties, completionHandler: {error in
if let error = error {
XCTFail("Error while importing addresses! \(error)")
}
......@@ -584,7 +584,7 @@ class CryptoTests: XCTestCase {
wait(for: [importExpectation], timeout: TimeInterval(20))
if let newPrefId = keys.first {
UserManager.storeUserValue(newPrefId as AnyObject, attribute: .prefSecretKeyID)
XCTAssertEqual(PersitentDataProvider.prefKeyID, newPrefId)
XCTAssertEqual(PersistentDataProvider.prefKeyID, newPrefId)
}
else {
XCTFail("No pref. sk!")
......@@ -611,10 +611,10 @@ class CryptoTests: XCTestCase {
let subject = "Test mail"
let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
let mail = MailProperties(messageID: "dasdads", subject: subject, date: Date(), flags: 0, from: from, to: to, cc: [], bcc: [], folder: folder, body: body, attachments: [], signatureState: sigState.rawValue, encryptionState: encState.rawValue, signatureKey: nil, decryptionKey: nil, autocryptHeaderKey: [], attachedPublicKeys: [], attachedSecretKeys: [])
let mail = MailProperties(messageID: "dasdads", uid: UInt64(arc4random()), subject: subject, date: Date(), flags: 0, from: from, to: to, cc: [], bcc: [], folder: folder, body: body, attachments: [], signatureState: sigState.rawValue, encryptionState: encState.rawValue, signatureKey: nil, decryptionKey: nil, autocryptHeaderKey: [], attachedPublicKeys: [], attachedSecretKeys: [])
let importExpectation = expectation(description: "Import email")
PersitentDataProvider.dataProvider.importNewData(from: [mail], completionHandler: {error in
PersistentDataProvider.dataProvider.importNewData(from: [mail], completionHandler: {error in
if let error = error {
XCTFail("Error while importing addresses! \(error)")
}
......@@ -650,7 +650,7 @@ class CryptoTests: XCTestCase {
// Create test Mail
_ = testMail(from: AddressProperties(email: "sender@example.com"),to: [user], body: cipher, encState: .UnableToDecrypt, sigState: .NoSignature)
let controller = PersitentDataProvider.dataProvider.generateFetchedUnableToDecryptMailsResultsController()
let controller = PersistentDataProvider.dataProvider.generateFetchedUnableToDecryptMailsResultsController()
do {
try controller.performFetch()
}
......@@ -770,7 +770,7 @@ class CryptoTests: XCTestCase {
}
let model = KeyManagementModel()
XCTAssertEqual(model.storedKeys.count, 1)
let skController = PersitentDataProvider.dataProvider.fetchedSecretKeyResultsController
let skController = PersistentDataProvider.dataProvider.fetchedSecretKeyResultsController
XCTAssertEqual(skController.fetchedObjects?.count, 0)
for key in model.storedKeys {
key.password = CryptoTests.importPW
......
// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2021-03-15 16:18:38 +0000
// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2021-04-08 09:17:40 +0000
//
// AuthenticationModel.swift
......@@ -654,7 +654,7 @@ import Foundation
}
// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2021-03-15 16:18:38 +0000
// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2021-04-08 09:17:40 +0000
//
// AuthenticationViewModel.swift
......
......@@ -50,7 +50,7 @@ What about errors and special cases?
@testable import enzevalos_iphone
class MailTest: XCTestCase {
let dataprovider = PersitentDataProvider.dataProvider
let dataprovider = PersistentDataProvider.dataProvider
let mailHandler = LetterboxModel.instance.mailHandler
let pgp = SwiftPGP()
let userAdr = "bob@enzevalos.de"
......@@ -86,7 +86,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
"""
private func deleteAll() {
let provider = PersitentDataProvider()
let provider = PersistentDataProvider()
let deleteExpectation = expectation(description: "Delete all data!")
provider.deleteAll(completionHandler: {error in
if let error = error {
......@@ -143,7 +143,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
let bccs = ["bcc1@example.com"]
let subject = "subject"
let body = "This is the body"
let outMail = OutgoingMail(toEntrys: tos, ccEntrys: ccs, bccEntrys: bccs, subject: subject, textContent: body, htmlContent: nil)
let outMail = OutgoingMail(toAddresses: tos, ccAddresses: ccs, bccAddresses: bccs, subject: subject, textContent: body, htmlContent: nil)
if let data = outMail.plainData {
// Test parsing!
let incMail = IncomingMail(rawData: data, uID: 0, folderPath: "INBOX", flags: MCOMessageFlag.init(rawValue: 0))
......@@ -182,7 +182,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
https certs will be valid – Microsoft signed.
"""
body = body.replacingOccurrences(of: "\n", with: "\r\n")
let outMail = OutgoingMail(toEntrys: tos, ccEntrys: ccs, bccEntrys: bccs, subject: subject, textContent: body, htmlContent: nil)
let outMail = OutgoingMail(toAddresses: tos, ccAddresses: ccs, bccAddresses: bccs, subject: subject, textContent: body, htmlContent: nil)
if let data = outMail.plainData {
// Test parsing!
let incMail = IncomingMail(rawData: data, uID: 0, folderPath: "INBOX", flags: MCOMessageFlag.init(rawValue: 0))
......@@ -200,7 +200,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
let subject = "subject"
let body = "body"
_ = createPGPUser(adr: encAdr, name: encAdr)
let outMail = OutgoingMail(toEntrys: [userAdr], ccEntrys: [], bccEntrys: [], subject: subject, textContent: body, htmlContent: nil)
let outMail = OutgoingMail(toAddresses: [userAdr], ccAddresses: [], bccAddresses: [], subject: subject, textContent: body, htmlContent: nil)
if let data = outMail.pgpData{
let incMail = IncomingMail(rawData: data, uID: 1, folderPath: "INBOX", flags: MCOMessageFlag.init(rawValue: 0))
let b = incMail.export().body
......@@ -222,7 +222,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
let subject = "subject"
let body = "body"
_ = createPGPUser(adr: encAdr, name: encAdr)
let outMail = OutgoingMail(toEntrys: [plainAdr, userAdr], ccEntrys: [], bccEntrys: [], subject: subject, textContent: body, htmlContent: nil)
let outMail = OutgoingMail(toAddresses: [plainAdr, userAdr], ccAddresses: [], bccAddresses: [], subject: subject, textContent: body, htmlContent: nil)
if let data = outMail.pgpData {
let incMail = IncomingMail(rawData: data, uID: 2, folderPath: "INBOX", flags: MCOMessageFlag.init(rawValue: 0))
storeAndTestMail(mails: [incMail], testFunc: {mail in
......@@ -275,11 +275,11 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
func receiveImportKeyMail(file: String, keyID: String, pw: String?, encMail: Bool, attached: Bool = false){
let bundle = Bundle(for: type(of: self))
if let url = bundle.url(forResource: file, withExtension: "asc"), let keyData = try? Data(contentsOf: url), let body = String(data: keyData, encoding: .utf8) {
var mail = OutgoingMail(toEntrys: [userAdr], ccEntrys: [], bccEntrys: [], subject: "New secret key", textContent: body, htmlContent: nil)
var mail = OutgoingMail(toAddresses: [userAdr], ccAddresses: [], bccAddresses: [], subject: "New secret key", textContent: body, htmlContent: nil)
if attached, let attachment = MCOAttachment(data: keyData, filename: "secretKey.asc") {
attachment.mimeType = ""
attachment.charset = "UTF-8"
mail = OutgoingMail(toEntrys: [userAdr], ccEntrys: [], bccEntrys: [], subject: "New attached secret key", textContent: MailTest.body, htmlContent: nil, textparts: 0, sendEncryptedIfPossible: false, attachments: [attachment])
mail = OutgoingMail(toAddresses: [userAdr], ccAddresses: [], bccAddresses: [], subject: "New attached secret key", textContent: MailTest.body, htmlContent: nil, textparts: 0, sendEncryptedIfPossible: false, attachments: [attachment])
}
var data = mail.plainData
if encMail {
......@@ -401,7 +401,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
let mailData = MailTest.loadMail(name: "signedSMIMEfromMac")
let incMail = IncomingMail(rawData: mailData, uID: 4, folderPath: "INBOX", flags: MCOMessageFlag.init(rawValue: 0))
storeAndTestMail(mails: [incMail], testFunc: {mail in
print("\(mail.subject) \(mail.encryptionState) \(mail.signatureState) keyid: \(mail.signatureKeyID)")
print("\(mail.subject) \(mail.encryptionState) \(mail.signatureState) keyid: \(String(describing: mail.signatureKeyID))")
XCTAssertEqual(mail.encryptionState, .NoEncryption)
XCTAssertEqual(mail.signatureState, .ValidSignature)
})
......@@ -428,7 +428,7 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
}
let incMail = IncomingMail(rawData: mailData, uID: 4, folderPath: "INBOX", flags: MCOMessageFlag.init(rawValue: 0))
storeAndTestMail(mails: [incMail], testFunc: {mail in
print("\(mail.subject) \(mail.encryptionState) \(mail.signatureState) keyid: \(mail.signatureKeyID)")
print("\(mail.subject) \(mail.encryptionState) \(mail.signatureState) keyid: \(String(describing: mail.signatureKeyID))")
if let sig = sigState, sig == .ValidSignature{
XCTAssertEqual(mail.signatureKey?.fingerprint, alice)
}
......
......@@ -334,7 +334,7 @@ OxeGuSvQoBUdP50ZspBBrf2+simuJLKMQ8kVXx8TuJqXe1FQPvFWDX5lBAf57BET
PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
-----END ENCRYPTED PRIVATE KEY-----
"""
let provider = PersitentDataProvider()
let provider = PersistentDataProvider()
var userAdr = "bob@enzevalos.de"
......@@ -401,7 +401,7 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
let fp = smimeObj.importCertForAddress(cert: test_key_other, addr: otherAddr)
let createExpectation = expectation(description: "Create public key record!")
let property = PublicKeyProperties(fingerprint: fp, cryptoProtocol: .SMIME, origin: .FileTransfer, preferEncryption: nil, lastSeenInAutocryptHeader: nil, lastSeenSignedMail: nil, secretKeyProperty: nil, usedAddresses: [AddressProperties(email: otherAddr)])
PersitentDataProvider.dataProvider.importNewData(from: [property], completionHandler: {error in
PersistentDataProvider.dataProvider.importNewData(from: [property], completionHandler: {error in
if let error = error {
XCTFail("Error while creating a new key: \(error)")
}
......@@ -412,7 +412,7 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
}
func testCreateEncSMIMEMail() {
let mail = OutgoingMail(toEntrys: [userAdr], ccEntrys: [], bccEntrys: [], subject: "encrypted smime mail", textContent: "Hello world", htmlContent: nil)
let mail = OutgoingMail(toAddresses: [userAdr], ccAddresses: [], bccAddresses: [], subject: "encrypted smime mail", textContent: "Hello world", htmlContent: nil)
guard let data = mail.createEncSMIMEData() else {
XCTFail("No signed mail...")
return
......@@ -429,7 +429,7 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
func testCreateSignedSMIMEMail() {
let mail = OutgoingMail(toEntrys: [otherAddr], ccEntrys: [], bccEntrys: [], subject: "signed smime mail", textContent: "Hello world", htmlContent: nil)
let mail = OutgoingMail(toAddresses: [otherAddr], ccAddresses: [], bccAddresses: [], subject: "signed smime mail", textContent: "Hello world", htmlContent: nil)
guard let data = mail.createSignedSMIMEData() else {
XCTFail("No signed mail...")
return
......
......@@ -26,7 +26,7 @@ class MailComparisonTests: XCTestCase {
var user_3_2 = AddressProperties(email: "david@1234.com", name: "david")
private func deleteAll() {
let provider = PersitentDataProvider()
let provider = PersistentDataProvider()
let deleteExpectation = expectation(description: "Delete all data!")
provider.deleteAll(completionHandler: {error in
if let error = error {
......@@ -66,9 +66,9 @@ class MailComparisonTests: XCTestCase {
if let decryptedBody = cryptoObject?.decryptedText {
body = decryptedBody
}
let mail = MailProperties(messageID: "\(id)", subject: subject, date: date, flags: Int16(flags.rawValue), from: from, to: to, cc: cc, bcc: bcc, folder: folder, body: body, attachments: [], signatureState: sigState.rawValue, encryptionState: encState.rawValue, signatureKey: nil, decryptionKey: nil, autocryptHeaderKey: [], attachedPublicKeys: [], attachedSecretKeys: [])
let mail = MailProperties(messageID: "\(id)", uid: UInt64(arc4random()), subject: subject, date: date, flags: Int16(flags.rawValue), from: from, to: to, cc: cc, bcc: bcc, folder: folder, body: body, attachments: [], signatureState: sigState.rawValue, encryptionState: encState.rawValue, signatureKey: nil, decryptionKey: nil, autocryptHeaderKey: [], attachedPublicKeys: [], attachedSecretKeys: [])
PersitentDataProvider.dataProvider.importNewData(from: [mail], completionHandler: {
PersistentDataProvider.dataProvider.importNewData(from: [mail], completionHandler: {
error in
print("Done!")
})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment