Skip to content
Snippets Groups Projects
Commit 1cb56b0f authored by muellek95's avatar muellek95
Browse files

Merge branch 'dev'

Conflicts:
	enzevalos_iphone.xcodeproj/project.pbxproj
parents c45acc11 2c777910
No related branches found
No related tags found
No related merge requests found
......@@ -143,6 +143,8 @@
47EABF0A241A9C8700774A93 /* AuthenticationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF07241A9C8700774A93 /* AuthenticationViewModel.swift */; };
47EABF0B241A9C8700774A93 /* AuthenticationScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF08241A9C8700774A93 /* AuthenticationScreen.swift */; };
47EABF0D241A9CA800774A93 /* MailAccount.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47EABF0C241A9CA800774A93 /* MailAccount.swift */; };
47EABF0E2420C63600774A93 /* GeneratedMocks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C527A0241AA4090030BBC9 /* GeneratedMocks.swift */; };
47EABF0F2420C63600774A93 /* AuthenticationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 97C5279E241A9F7B0030BBC9 /* AuthenticationTests.swift */; };
47F0376E22A7278A0005C9DE /* accounts.json in Resources */ = {isa = PBXBuildFile; fileRef = 47F0376D22A7278A0005C9DE /* accounts.json */; };
47F79240203492E3005E7DB6 /* KeyRecord+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F7923E203492E3005E7DB6 /* KeyRecord+CoreDataClass.swift */; };
47F79241203492E3005E7DB6 /* KeyRecord+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47F7923F203492E3005E7DB6 /* KeyRecord+CoreDataProperties.swift */; };
......@@ -576,6 +578,8 @@
94EE54279AB591E0CAB8EFD8 /* Pods_enzevalos_iphone.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_enzevalos_iphone.framework; sourceTree = BUILT_PRODUCTS_DIR; };
9771AA8B241161190023A096 /* MailAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MailAccount.swift; sourceTree = "<group>"; };
97AACD2324178C230078A68E /* AuthenticationModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationModel.swift; sourceTree = "<group>"; };
97C5279E241A9F7B0030BBC9 /* AuthenticationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthenticationTests.swift; sourceTree = "<group>"; };
97C527A0241AA4090030BBC9 /* GeneratedMocks.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GeneratedMocks.swift; path = enzevalos_iphoneTests/GeneratedMocks.swift; sourceTree = SOURCE_ROOT; };
988C9C5C240D507A006213F0 /* PhishingTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhishingTests.swift; sourceTree = "<group>"; };
9A132EDE8BCA06ACDB505C22 /* Pods-enzevalos_iphoneUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphoneUITests.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphoneUITests/Pods-enzevalos_iphoneUITests.debug.xcconfig"; sourceTree = "<group>"; };
9B3D62838C729BAC6832270A /* Pods-enzevalos_iphone-AdHoc.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-enzevalos_iphone-AdHoc.debug.xcconfig"; path = "../enzevalos_iphone_workspace/Pods/Target Support Files/Pods-enzevalos_iphone-AdHoc/Pods-enzevalos_iphone-AdHoc.debug.xcconfig"; sourceTree = "<group>"; };
......@@ -1237,6 +1241,15 @@
name = Data;
sourceTree = "<group>";
};
97C5279D241A9F690030BBC9 /* authentication */ = {
isa = PBXGroup;
children = (
97C527A0241AA4090030BBC9 /* GeneratedMocks.swift */,
97C5279E241A9F7B0030BBC9 /* AuthenticationTests.swift */,
);
path = authentication;
sourceTree = "<group>";
};
A10DE41E1EFAA140005E8189 /* folders */ = {
isa = PBXGroup;
children = (
......@@ -1350,6 +1363,8 @@
isa = PBXGroup;
children = (
71497EC1240FF7FC00B6210F /* phishing */,
97C5279D241A9F690030BBC9 /* authentication */,
988C9C5C240D507A006213F0 /* PhishingTests.swift */,
47F0376C22A7278A0005C9DE /* private */,
470709202189C24800DF71A3 /* testKeys */,
470709112189BB4A00DF71A3 /* testMails */,
......@@ -1626,9 +1641,11 @@
buildConfigurationList = A13526A31D955BE000D3BFE1 /* Build configuration list for PBXNativeTarget "enzevalos_iphoneTests" */;
buildPhases = (
D6F0EB205D61EA8C8A045390 /* [CP] Check Pods Manifest.lock */,
47EABF01241A99DA00774A93 /* Cockoo run script */,
A13526881D955BE000D3BFE1 /* Sources */,
A13526891D955BE000D3BFE1 /* Frameworks */,
A135268A1D955BE000D3BFE1 /* Resources */,
0811D368D52F1D9B243500D4 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
......@@ -1800,6 +1817,24 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
0811D368D52F1D9B243500D4 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests-frameworks.sh",
"${BUILT_PRODUCTS_DIR}/Cuckoo/Cuckoo.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Cuckoo.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-enzevalos_iphoneTests/Pods-enzevalos_iphoneTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3992B0CB6412E8526773B814 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
......@@ -1836,6 +1871,24 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-enzevalos_iphone/Pods-enzevalos_iphone-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
47EABF01241A99DA00774A93 /* Cockoo run script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Cockoo run script";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Define output file. Change \"${PROJECT_DIR}/${PROJECT_NAME}Tests\" to your test's root source folder, if it's not the default name.\nOUTPUT_FILE=\"${PROJECT_DIR}/${PROJECT_NAME}Tests/GeneratedMocks.swift\"\necho \"Generated Mocks File = ${OUTPUT_FILE}\"\n\n# Define input directory. Change \"${PROJECT_DIR}/${PROJECT_NAME}\" to your project's root source folder, if it's not the default name.\nINPUT_DIR=\"${PROJECT_DIR}/${PROJECT_NAME}\"\necho \"Mocks Input Directory = ${INPUT_DIR}\"\n\n# Generate mock files, include as many input files as you'd like to create mocks for.\n\"${PODS_ROOT}/Cuckoo/run\" generate --testable \"${PROJECT_NAME}\" \\\n--output \"${OUTPUT_FILE}\" \\\n\"${INPUT_DIR}/AuthenticationModel.swift\" \\\n\"${INPUT_DIR}/AuthenticationViewModel.swift\" \n# ... and so forth, the last line should never end with a backslash\n\n# After running once, locate `GeneratedMocks.swift` and drag it into your Xcode test target group.\n";
};
47F867E52052B4B500AA832F /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 8;
......@@ -2090,10 +2143,12 @@
71497EC3240FF82700B6210F /* MailComparisonTests.swift in Sources */,
479B5977206914BE00B3944D /* CryptoTests.swift in Sources */,
A15D215F223BE6E4003E0CE0 /* MailTest.swift in Sources */,
47EABF0F2420C63600774A93 /* AuthenticationTests.swift in Sources */,
988C9C5D240D507A006213F0 /* PhishingTests.swift in Sources */,
4715F637202A0248001BFFD0 /* CoreDataTests.swift in Sources */,
47C22281218AFD6300BD2C2B /* AutocryptTest.swift in Sources */,
478154AE2200641900A931EC /* StudyTest.swift in Sources */,
47EABF0E2420C63600774A93 /* GeneratedMocks.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......
This diff is collapsed.
//
// AuthenticationTests.swift
// enzevalos_iphoneTests
//
// Created by Cezary Pilaszewicz on 12.03.20.
// Copyright © 2020 fu-berlin. All rights reserved.
//
import Cuckoo
import XCTest
import Combine
@testable import enzevalos_iphone
class AuthenticationTests: XCTestCase {
let login = "test_login"
let password = "test_password"
let username = "test_uesrname"
let imapServer = "test.imap.server.de"
let imapPort = 997
let imapEncryption = MCOConnectionType.startTLS.rawValue
let smtpServer = "test.smtp.server.com"
let smtpPort = 1234
let smtpEncryption = MCOConnectionType.startTLS.rawValue
//Test whether correct arguments are passed to the model
func testValidate() {
let model = MockAuthenticationModel().withEnabledSuperclassSpy()
let viewModel = MockAuthenticationViewModel(authenticationModel: model).withEnabledSuperclassSpy()
let future: Future<AuthenticationModel.AuthenticationResult, Never> = Future {
promise in promise(.success(AuthenticationModel.AuthenticationResult.Success))
}
stub(model) { stub in
when(stub.checkConfig(mailAccount: any(), extendedValidation: false)).thenReturn(future)
}
viewModel.validate(self.login, self.password)
let argumentCaptor = ArgumentCaptor<MailAccount>()
verify(model).checkConfig(mailAccount: argumentCaptor.capture(), extendedValidation: false)
let passedMailAccount = argumentCaptor.value
XCTAssertEqual(passedMailAccount?.emailAddress, self.login)
XCTAssertEqual(passedMailAccount?.password, self.password)
}
func testDetailValidate() {
let model = MockAuthenticationModel().withEnabledSuperclassSpy()
let viewModel = MockAuthenticationViewModel(authenticationModel: model).withEnabledSuperclassSpy()
let future: Future<AuthenticationModel.AuthenticationResult, Never> = Future {
promise in promise(.success(AuthenticationModel.AuthenticationResult.Success))
}
stub(model) { stub in
when(stub.checkConfig(mailAccount: any(), extendedValidation: true)).thenReturn(future)
}
viewModel.detailValidation(login, password, username, imapServer, String(imapPort), imapEncryption, smtpServer, String(smtpPort), smtpEncryption)
let argumentCaptor = ArgumentCaptor<MailAccount>()
verify(model).checkConfig(mailAccount: argumentCaptor.capture(), extendedValidation: true)
let passedMailAccount = argumentCaptor.value
XCTAssertEqual(passedMailAccount?.emailAddress, self.login)
XCTAssertEqual(passedMailAccount?.password, self.password)
XCTAssertEqual(passedMailAccount?.username, self.username)
XCTAssertEqual(passedMailAccount?.imapServer, self.imapServer)
XCTAssertEqual(passedMailAccount?.imapPort, self.imapPort)
XCTAssertEqual(passedMailAccount?.imapEncryption, self.imapEncryption)
XCTAssertEqual(passedMailAccount?.smtpServer, self.smtpServer)
XCTAssertEqual(passedMailAccount?.smtpPort, self.smtpPort)
XCTAssertEqual(passedMailAccount?.smtpEncryption, self.smtpEncryption)
}
//Test authentification results
func testAuthenticationSuccessful() {
let model = MockAuthenticationModel().withEnabledSuperclassSpy()
let viewModel = MockAuthenticationViewModel(authenticationModel: model).withEnabledSuperclassSpy()
let future: Future<AuthenticationModel.AuthenticationResult, Never> = Future {
promise in promise(.success(AuthenticationModel.AuthenticationResult.Success))
}
stub(model) { stub in
when(stub.checkConfig(mailAccount: any(), extendedValidation: false)).thenReturn(future)
}
viewModel.validate(self.login, self.password)
verify(viewModel).authenticationSucceed()
}
func testAuthenticationFailed() {
let model = MockAuthenticationModel().withEnabledSuperclassSpy()
let viewModel = MockAuthenticationViewModel(authenticationModel: model).withEnabledSuperclassSpy()
let future: Future<AuthenticationModel.AuthenticationResult, Never> = Future {
promise in promise(.success(AuthenticationModel.AuthenticationResult.Error(value: MailServerConnectionError.AuthenticationError)))
}
stub(model) { stub in
when(stub.checkConfig(mailAccount: any(), extendedValidation: false)).thenReturn(future)
}
viewModel.validate(self.login, self.password)
let argumentCaptor = ArgumentCaptor<MailServerConnectionError>()
verify(viewModel).authenticationFailed(error: argumentCaptor.capture())
XCTAssertEqual(argumentCaptor.value, MailServerConnectionError.AuthenticationError)
}
func testAuthenticationTimeout() {
let model = MockAuthenticationModel().withEnabledSuperclassSpy()
let viewModel = MockAuthenticationViewModel(authenticationModel: model).withEnabledSuperclassSpy()
let future: Future<AuthenticationModel.AuthenticationResult, Never> = Future {
promise in promise(.success(AuthenticationModel.AuthenticationResult.Timeout))
}
stub(model) { stub in
when(stub.checkConfig(mailAccount: any(), extendedValidation: false)).thenReturn(future)
}
viewModel.validate(self.login, self.password)
verify(viewModel).timeoutNotification()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment