diff --git a/enzevalos_iphoneTests/GeneratedMocks.swift b/enzevalos_iphoneTests/GeneratedMocks.swift index db5f7320ce0fa90b95bef8aa82efccd6b6b5fa41..3e87e156603df308e5355f1d538eb978c1c90007 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 2020-03-18 10:30:41 +0000 +// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationModel.swift at 2020-03-18 15:30:35 +0000 // // AuthenticationModel.swift @@ -653,7 +653,7 @@ import Foundation } -// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2020-03-18 10:30:41 +0000 +// MARK: - Mocks generated from file: enzevalos_iphone/AuthenticationViewModel.swift at 2020-03-18 15:30:35 +0000 // // AuthenticationViewModel.swift diff --git a/enzevalos_iphoneTests/PhishingTests.swift b/enzevalos_iphoneTests/PhishingTests.swift new file mode 100644 index 0000000000000000000000000000000000000000..1927629ab39f5730855c63ec88dd606ea83e3870 --- /dev/null +++ b/enzevalos_iphoneTests/PhishingTests.swift @@ -0,0 +1,122 @@ +// +// PhishingTests.swift +// enzevalos_iphoneTests +// +// Created by Viktoria Sorgalla on 02.03.20. +// Copyright © 2020 fu-berlin. All rights reserved. +// + +import XCTest +@testable import enzevalos_iphone + +class PhishingTests: XCTestCase { + +// setup for mail address splitting + var testEMail = "alice.bob@moep.blubb.de" + + var finalTestEMailSplitAddress = ["alice.bob", "moep", "blubb", "de"] + + var finalTestEMailIdentity = "alice.bob" + + var finalTestEMailSubDomains = ["moep", "blubb"] + + var finalTestEMailDomain = "de" + + var TestText = "blabla moep jkjlkj lkjkljknmbjks llhil k. jhkhkih. huhuhj! fsdf bob.alice@zedat.fu-berlin.de dfsf. jhjknjknjkh https://git.imp.fu-berlin.de/enzevalos/enzevalos_iphone/issues/240 hjkhjkhkhn www.google.de kljhl@hjkghgkhj.com nljbjkjk.de url tag html mail <a href='https://www.w3schools.com'>Visit W3Schools</a> hjhkhiuhziu kjhkl <a href=\"https://www.w2schools.com\">Visit W2Schools</a>. lknljnlk. kmm /n lmölmpöl < a href=\"https://www.w8schools.com\">Visit W8Schools</a> gfg fghfghnhg <a href=\"https://www.w33schools.com\">Visit W33Schools</a> nkjhjkhkjn,mn jnmnklmj j <a href=\"https://www.w22schools.com\">Visit W22Schools</ a> hghjcfgh hfgchnvhj vgjcgj cjghcj <a href=\"https://www.w99schools.com\">Visit W99Schools</a >" + +// setup for find mail address in text + var finalMailAddresses = ["bob.alice@zedat.fu-berlin.de", "kljhl@hjkghgkhj.com"] + +// setup for find URLs in text + var finalURLs = ["https://git.imp.fu-berlin.de/enzevalos/enzevalos_iphone/issues/240", "http://www.google.de", "http://nljbjkjk.de", "https://www.w3schools.com", "https://www.w2schools.com", "https://www.w8schools.com", "https://www.w33schools.com", "https://www.w22schools.com", "https://www.w99schools.com"] + +// setup for tag tests + var finalTestTextFindHtmlTags = ["<a href=\'https://www.w3schools.com\'>Visit W3Schools</a>", "<a href=\"https://www.w2schools.com\">Visit W2Schools</a>", "< a href=\"https://www.w8schools.com\">Visit W8Schools</a>", "<a href=\"https://www.w33schools.com\">Visit W33Schools</a>", "<a href=\"https://www.w22schools.com\">Visit W22Schools</ a>", "<a href=\"https://www.w99schools.com\">Visit W99Schools</a >"] + + var finalTestTextHtmlTagURL = ["https://www.w3schools.com", "https://www.w2schools.com", "https://www.w8schools.com", "https://www.w33schools.com", "https://www.w22schools.com", "https://www.w99schools.com"] + + var finalTestTexthttpTagLinkName = ["Visit W3Schools", "Visit W2Schools", "Visit W8Schools", "Visit W33Schools", "Visit W22Schools", "Visit W99Schools"] + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + super.tearDown() + // Put teardown code here. This method is called after the invocation of each test method in the class. + } + + func testSplitMailAddress(){ + let arr = testEMail.splitAddress() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalTestEMailSplitAddress[0]) + XCTAssertEqual(arr[1], finalTestEMailSplitAddress[1]) + XCTAssertEqual(arr[2], finalTestEMailSplitAddress[2]) + XCTAssertEqual(arr[3], finalTestEMailSplitAddress[3]) + } + + func testGetMailIdentity(){ + XCTAssertEqual(testEMail.getLocalMailIdentity(), finalTestEMailIdentity) + } + + func testGetSubdomains(){ + let arr = testEMail.getSubdomains() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalTestEMailSubDomains[0]) + XCTAssertEqual(arr[1], finalTestEMailSubDomains[1]) + } + + func testGetDomain(){ + XCTAssertEqual(testEMail.getDomain(), finalTestEMailDomain) + } + + func testTextFindMailAddress(){ + let arr = TestText.findMailAddress() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalMailAddresses[0]) + XCTAssertEqual(arr[1], finalMailAddresses[1]) + } + + func testTextFindURL(){ + let arr = TestText.findURL() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalURLs[0]) + XCTAssertEqual(arr[1], finalURLs[1]) + XCTAssertEqual(arr[2], finalURLs[2]) + XCTAssertEqual(arr[3], finalURLs[3]) + } + + func testTextFindHlmlTags(){ + let arr = TestText.findHtmlTags() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalTestTextFindHtmlTags[0]) + XCTAssertEqual(arr[1], finalTestTextFindHtmlTags[1]) + XCTAssertEqual(arr[2], finalTestTextFindHtmlTags[2]) + XCTAssertEqual(arr[3], finalTestTextFindHtmlTags[3]) + XCTAssertEqual(arr[4], finalTestTextFindHtmlTags[4]) + XCTAssertEqual(arr[5], finalTestTextFindHtmlTags[5]) + } + + func testTextHtmlTagURL(){ + let arr = TestText.htmlTagURL() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalTestTextHtmlTagURL[0]) + XCTAssertEqual(arr[1], finalTestTextHtmlTagURL[1]) + XCTAssertEqual(arr[2], finalTestTextHtmlTagURL[2]) + XCTAssertEqual(arr[3], finalTestTextHtmlTagURL[3]) + XCTAssertEqual(arr[4], finalTestTextHtmlTagURL[4]) + XCTAssertEqual(arr[5], finalTestTextHtmlTagURL[5]) + } + + func testTextHttpTagLinkName(){ + let arr = TestText.htmlTagLinkName() + XCTAssertNotNil(arr) + XCTAssertEqual(arr[0], finalTestTexthttpTagLinkName[0]) + XCTAssertEqual(arr[1], finalTestTexthttpTagLinkName[1]) + XCTAssertEqual(arr[2], finalTestTexthttpTagLinkName[2]) + XCTAssertEqual(arr[3], finalTestTexthttpTagLinkName[3]) + XCTAssertEqual(arr[4], finalTestTexthttpTagLinkName[4]) + XCTAssertEqual(arr[5], finalTestTexthttpTagLinkName[5]) + } +}