From 10d1ce0fa759720ad39be238ecc9fb5e658863f2 Mon Sep 17 00:00:00 2001
From: Oliver Wiese <oliver.wiese@fu-berlin.de>
Date: Sat, 10 Apr 2021 13:14:02 +0200
Subject: [PATCH] fix and clean  test cases

---
 enzevalos_iphoneTests/CoreMailTest.swift               | 10 +++++-----
 enzevalos_iphoneTests/CryptoTests.swift                |  4 ++--
 enzevalos_iphoneTests/GeneratedMocks.swift             |  4 ++--
 enzevalos_iphoneTests/MailTest.swift                   |  1 -
 enzevalos_iphoneTests/SMIMETests.swift                 |  3 +--
 .../phishing/MailComparisonTests.swift                 |  2 +-
 6 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/enzevalos_iphoneTests/CoreMailTest.swift b/enzevalos_iphoneTests/CoreMailTest.swift
index 64954e7a..57eb5edc 100644
--- a/enzevalos_iphoneTests/CoreMailTest.swift
+++ b/enzevalos_iphoneTests/CoreMailTest.swift
@@ -51,7 +51,7 @@ class CoreMailTest: XCTestCase {
     func testImportMail(){
         let addr = "vic@example.com"
         let addr1 = AddressProperties(email: addr)
-        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
+        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil, flags: 0)
         
         let importExpectation = expectation(description: "Import new msg!")
 
@@ -89,7 +89,7 @@ class CoreMailTest: XCTestCase {
     
     func testDuplicateMails() {
         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 folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil, flags: 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)
@@ -121,7 +121,7 @@ class CoreMailTest: XCTestCase {
     
     func testDuplicateMails2() {
         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 folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil, flags: 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)
@@ -171,7 +171,7 @@ class CoreMailTest: XCTestCase {
         let addr1 = AddressProperties(email: "vic@example.com")
         let addr2 = AddressProperties(email: "alex@example.com")
         let addrs = [addr1, addr2]
-        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
+        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil, flags: 0)
 
         
         var msgs = [MailProperties]()
@@ -218,7 +218,7 @@ class CoreMailTest: XCTestCase {
         let addr1 = AddressProperties(email: "vic@example.com")
         let addr2 = AddressProperties(email: "alex@example.com")
         let addrs = [addr1, addr2]
-        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
+        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil, flags: 0)
         var expectations = [XCTestExpectation]()
         
         var res = 0
diff --git a/enzevalos_iphoneTests/CryptoTests.swift b/enzevalos_iphoneTests/CryptoTests.swift
index a1fe06a0..4b8d3575 100644
--- a/enzevalos_iphoneTests/CryptoTests.swift
+++ b/enzevalos_iphoneTests/CryptoTests.swift
@@ -533,7 +533,7 @@ class CryptoTests: XCTestCase {
     func testEncSignedMail() {
         let body = "signed text"
         let (senderAddress, senderID) = createPGPUser()
-        let (userAddr, id2) = createPGPUser()
+        let (_, id2) = createPGPUser()
 
         let senderPGP = SwiftPGP()
         let encObject = senderPGP.encrypt(plaintext: body, ids: [userKeyID], myId: senderID)
@@ -609,7 +609,7 @@ class CryptoTests: XCTestCase {
     func testMail(from: AddressProperties, to: [AddressProperties], body: String, encState: EncryptionState, sigState: SignatureState) -> MailProperties {
 
         let subject = "Test mail"
-        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil)
+        let folder = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Testfolder", parent: nil, children: nil, flags: 0)
         
         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: [])
         
diff --git a/enzevalos_iphoneTests/GeneratedMocks.swift b/enzevalos_iphoneTests/GeneratedMocks.swift
index 58152279..7c8e9c91 100644
--- a/enzevalos_iphoneTests/GeneratedMocks.swift
+++ b/enzevalos_iphoneTests/GeneratedMocks.swift
@@ -1,4 +1,4 @@
-// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2021-04-08 09:17:40 +0000
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2021-04-10 11:01:02 +0000
 
 //
 //  AuthenticationModel.swift
@@ -654,7 +654,7 @@ import Foundation
 }
 
 
-// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2021-04-08 09:17:40 +0000
+// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2021-04-10 11:01:02 +0000
 
 //
 //  AuthenticationViewModel.swift
diff --git a/enzevalos_iphoneTests/MailTest.swift b/enzevalos_iphoneTests/MailTest.swift
index 30ad8070..8172340f 100644
--- a/enzevalos_iphoneTests/MailTest.swift
+++ b/enzevalos_iphoneTests/MailTest.swift
@@ -115,7 +115,6 @@ n1O3czuVl7rPXrJn0A/MVI2ReKOQeIAYMg==
     }
 
     private func storeAndTestMail(mails: [IncomingMail], testFunc: (_ mail: MailRecord) -> ()) {
-        let oldmails = dataprovider.fetchedMailResultsController.fetchedObjects?.count ?? 0
         let importExpectation = expectation(description: "Import new email!")
         dataprovider.importNewData(from: mails.map({$0.export()}), completionHandler: { error in
             if let error = error {
diff --git a/enzevalos_iphoneTests/SMIMETests.swift b/enzevalos_iphoneTests/SMIMETests.swift
index 033b57fa..dffc5790 100644
--- a/enzevalos_iphoneTests/SMIMETests.swift
+++ b/enzevalos_iphoneTests/SMIMETests.swift
@@ -433,8 +433,7 @@ PkfA6mR7rtcyIbHi34tfkCv/qolV3QivMHov0IJpRyNO
             XCTFail("Could not sign!")
         }
         
-        //if let signedData = signObj?.chiphertext {
-        if let signedData = signObj?.chiphertext, let signedText = signObj?.chiperString {
+        if let _ = signObj?.chiphertext, let signedText = signObj?.chiperString {
             let text = signedText
             let verifiedObj = smimeObj.verify(data: nil, string: text, email: ourAddr!, isMailNew: true)
 
diff --git a/enzevalos_iphoneTests/phishing/MailComparisonTests.swift b/enzevalos_iphoneTests/phishing/MailComparisonTests.swift
index 0dcb8f8d..2d54cdaa 100644
--- a/enzevalos_iphoneTests/phishing/MailComparisonTests.swift
+++ b/enzevalos_iphoneTests/phishing/MailComparisonTests.swift
@@ -51,7 +51,7 @@ class MailComparisonTests: XCTestCase {
         super.tearDown()
     }
     
-    func testMail(from: AddressProperties, to: [AddressProperties], cc: [AddressProperties], bcc: [AddressProperties], flags: MCOMessageFlag = MCOMessageFlag.init(rawValue: 0), folder: FolderProperties = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Inbox", parent: nil, children: nil), date: Date = Date(timeIntervalSince1970: TimeInterval(arc4random())), cryptoObject: CryptoObject? = nil, body: String = String.random(length: 20)) -> MailProperties {
+    func testMail(from: AddressProperties, to: [AddressProperties], cc: [AddressProperties], bcc: [AddressProperties], flags: MCOMessageFlag = MCOMessageFlag.init(rawValue: 0), folder: FolderProperties = FolderProperties(delimiter: nil, uidValidity: nil, lastUpdate: nil, maxUID: nil, minUID: nil, path: "Inbox", parent: nil, children: nil, flags: 0), date: Date = Date(timeIntervalSince1970: TimeInterval(arc4random())), cryptoObject: CryptoObject? = nil, body: String = String.random(length: 20)) -> MailProperties {
 
         let subject = String.random(length: 20)
         let id = UInt64(arc4random())
-- 
GitLab