Commit d89ff9f8 authored by Martin's avatar Martin
Browse files

IOS-2885 - change some tests to accept imap and smtp password

parent 9d2f468d
......@@ -36,7 +36,8 @@ class TestDataBase {
var imapServerType: Server.ServerType = .imap
var imapServerTransport: Server.Transport = .startTls
var imapServerPort: UInt16 = 993
var password: String?
var imapPassword: String?
var smtpPassword: String?
init(accountName: String,
idAddress: String,
......@@ -51,7 +52,8 @@ class TestDataBase {
smtpServerType: Server.ServerType,
smtpServerTransport: Server.Transport,
smtpServerPort: UInt16,
password: String) {
imapPassword: String,
smtpPassword: String) {
self.accountName = accountName
self.idAddress = idAddress
self.idUserName = idUserName
......@@ -65,7 +67,8 @@ class TestDataBase {
self.imapServerType = imapServerType
self.imapServerTransport = imapServerTransport
self.imapServerPort = imapServerPort
self.password = password
self.imapPassword = imapPassword
self.smtpPassword = smtpPassword
}
func cdAccount(context: NSManagedObjectContext = Stack.shared.mainContext) -> CdAccount {
......@@ -86,7 +89,7 @@ class TestDataBase {
smtp.transport = smtpServerTransport
let keySmtp = UUID().uuidString
CdServerCredentials.add(password: password, forKey: keySmtp)
CdServerCredentials.add(password: smtpPassword, forKey: keySmtp)
let credSmtp = CdServerCredentials(context: context)
credSmtp.loginName = smtpLoginName ?? id.address
credSmtp.key = keySmtp
......@@ -99,7 +102,7 @@ class TestDataBase {
imap.transport = imapServerTransport
let keyImap = UUID().uuidString
CdServerCredentials.add(password: password, forKey: keyImap)
CdServerCredentials.add(password: imapPassword, forKey: keyImap)
let credImap = CdServerCredentials(context: context)
credImap.loginName = imapLoginName ?? id.address
credImap.key = keyImap
......@@ -209,7 +212,8 @@ class TestDataBase {
smtpServerTransport: Server.Transport.tls,
smtpServerPort: 465,
password: "whatever_you_want"))
imapPassword: "whatever_you_want",
smtpPassword: "whatever_you_want"))
fatalError("Abstract method. Must be overridden")
}
......@@ -233,7 +237,8 @@ class TestDataBase {
smtpServerTransport: Server.Transport.plain,
smtpServerPort: 3025,
password: "pwd"))
imapPassword: "pwd",
smtpPassword: "pwd"))
}
/**
......
......@@ -87,7 +87,12 @@ class LoginViewModelTests: XCTestCase {
func testBasic() {
let td = TestData()
let accountSettings = td.createVerifiableAccountSettings()
guard let passw = accountSettings.password else {
guard let imapPassword = accountSettings.imapPassword else {
XCTFail("expecting password for account")
return
}
guard let smtpPassword = accountSettings.smtpPassword else {
XCTFail("expecting password for account")
return
}
......@@ -108,7 +113,7 @@ class LoginViewModelTests: XCTestCase {
vm.loginViewModelLoginErrorDelegate = errorHandler
vm.login(emailAddress: accountSettings.idAddress,
displayName: "User Name",
password: passw)
password: imapPassword)
waitForExpectations(timeout: TestUtil.waitTime, handler: { error in
XCTAssertNil(error)
......
......@@ -31,7 +31,8 @@ class TestData: TestDataBase {
smtpServerTransport: Server.Transport.plain,
smtpServerPort: 3025,
password: "pwd"))
imapPassword: "pwd",
smtpPassword: "pwd"))
/*
//#########
......@@ -115,21 +116,22 @@ class TestData: TestDataBase {
func addVerifiablePepTestAccount(address: String) {
append(verifiableAccountSettings: AccountSettings(
accountName: "Unit Test \(address)",
idAddress: address,
idUserName: "User \(address)",
imapServerAddress: "peptest.ch",
imapServerType: Server.ServerType.imap,
imapServerTransport: Server.Transport.tls,
imapServerPort: 993,
smtpServerAddress: "peptest.ch",
smtpServerType: Server.ServerType.smtp,
smtpServerTransport: Server.Transport.startTls,
smtpServerPort: 587,
password: "pEpdichauf5MailPassword"))
accountName: "Unit Test \(address)",
idAddress: address,
idUserName: "User \(address)",
imapServerAddress: "peptest.ch",
imapServerType: Server.ServerType.imap,
imapServerTransport: Server.Transport.tls,
imapServerPort: 993,
smtpServerAddress: "peptest.ch",
smtpServerType: Server.ServerType.smtp,
smtpServerTransport: Server.Transport.startTls,
smtpServerPort: 587,
imapPassword: "pEpdichauf5MailPassword",
smtpPassword: "pEpdichauf5MailPassword"))
}
}
......
......@@ -34,7 +34,8 @@ class TestDataBase {
var imapServerType: Server.ServerType = .imap
var imapServerTransport: Server.Transport = .startTls
var imapServerPort: UInt16 = 993
var password: String?
var imapPassword: String?
var smtpPassword: String?
init(accountName: String,
idAddress: String,
......@@ -49,7 +50,8 @@ class TestDataBase {
smtpServerType: Server.ServerType,
smtpServerTransport: Server.Transport,
smtpServerPort: UInt16,
password: String) {
imapPassword: String,
smtpPassword: String) {
self.accountName = accountName
self.idAddress = idAddress
self.idUserName = idUserName
......@@ -58,12 +60,14 @@ class TestDataBase {
self.smtpServerType = smtpServerType
self.smtpServerTransport = smtpServerTransport
self.smtpServerPort = smtpServerPort
self.smtpPassword = smtpPassword
self.imapLoginName = imapLoginName
self.imapServerAddress = imapServerAddress
self.imapServerType = imapServerType
self.imapServerTransport = imapServerTransport
self.imapServerPort = imapServerPort
self.password = password
self.imapPassword = imapPassword
}
/// Creates a partner identity, that is, a non-myself identity without an
......@@ -87,7 +91,7 @@ class TestDataBase {
let credSmtp = ServerCredentials(loginName: id.address,
key: nil,
clientCertificate: nil)
credSmtp.password = password
credSmtp.password = smtpPassword
let smtp = Server.create(serverType: .smtp,
port: smtpServerPort,
address: smtpServerAddress,
......@@ -97,7 +101,7 @@ class TestDataBase {
let credImap = ServerCredentials(loginName: id.address,
key: nil,
clientCertificate: nil)
credImap.password = password
credImap.password = imapPassword
let imap = Server.create(serverType: .imap,
port: imapServerPort,
address: imapServerAddress,
......@@ -118,8 +122,8 @@ class TestDataBase {
verifiableAccount.loginNameIMAP = imapLoginName
verifiableAccount.loginNameSMTP = smtpLoginName
verifiableAccount.accessToken = nil
verifiableAccount.imapPassword = password
verifiableAccount.smtpPassword = password
verifiableAccount.imapPassword = imapPassword
verifiableAccount.smtpPassword = smtpPassword
verifiableAccount.serverIMAP = imapServerAddress
verifiableAccount.portIMAP = imapServerPort
......@@ -181,7 +185,8 @@ class TestDataBase {
smtpServerTransport: Server.Transport.tls,
smtpServerPort: 465,
password: "whatever_you_want"))
imapPassword: "whatever_you_want",
smtpPassword: "whatever_you_want"))
fatalError("Abstract method. Must be overridden")
}
......@@ -205,7 +210,8 @@ class TestDataBase {
smtpServerTransport: Server.Transport.plain,
smtpServerPort: 3025,
password: "pwd"))
imapPassword: "pwd",
smtpPassword: "pwd"))
}
/**
......
Markdown is supported
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