Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
enzevalos_iphone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
enzevalos
enzevalos_iphone
Commits
640f43de
Commit
640f43de
authored
6 years ago
by
Oliver Wiese
Browse files
Options
Downloads
Patches
Plain Diff
update onboarding testcases
parent
b6e57a59
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
enzevalos_iphone/MailSession.swift
+1
-0
1 addition, 0 deletions
enzevalos_iphone/MailSession.swift
enzevalos_iphoneTests/MailServerConfigurationTest.swift
+119
-11
119 additions, 11 deletions
enzevalos_iphoneTests/MailServerConfigurationTest.swift
with
120 additions
and
11 deletions
enzevalos_iphone/MailSession.swift
+
1
−
0
View file @
640f43de
...
...
@@ -625,6 +625,7 @@ class MailSession {
return
searchForServerConfig
(
hostFromAdr
:
hostFromAdr
)
}
private
func
searchForServerConfig
(
hostFromAdr
:
Bool
)
->
Bool
{
var
search
=
false
let
(
_
,
host
)
=
MailSession
.
splitAddr
(
userAddr
:
self
.
mailAddr
)
...
...
This diff is collapsed.
Click to expand it.
enzevalos_iphoneTests/MailServerConfigurationTest.swift
+
119
−
11
View file @
640f43de
...
...
@@ -29,6 +29,7 @@ class MailServerConfigurationTest: XCTestCase, MailSessionListener{
let
msg11
=
"2 NO [AUTHENTICATIONFAILED] Invalid credentials (Failure)
\r\n
"
var
result
:
Bool
?
var
expect
:
XCTestExpectation
?
override
func
setUp
()
{
super
.
setUp
()
...
...
@@ -81,31 +82,138 @@ class MailServerConfigurationTest: XCTestCase, MailSessionListener{
}
}
func
testLogin
(){
MailServerConfigurationTest
.
loadAccounts
()
let
session
=
MailSession
(
configSession
:
.
IMAP
,
mailAddress
:
"ullimuelle@web.de"
,
password
:
"dun3bate"
,
username
:
nil
)
/**
Testcase:
pw/name correct: find autoconfig, test input config
name false -> find autoconfig, test iput config
name correct but wrong password -> find autoconfig, test input config
TODO: SMTP?
Test various accounts? Yahoo, gmx
*/
func
testHappyPath
()
{
testJsonFile
(
correctPW
:
true
,
provider
:
"1"
)
}
func
testJsonFileButWrongPW
()
{
testJsonFile
(
correctPW
:
false
,
provider
:
"1"
)
}
func
testJsonFile
(
correctPW
:
Bool
,
provider
:
String
){
var
pw
=
"password"
let
accounts
=
MailServerConfigurationTest
.
loadAccounts
()
guard
let
account
=
accounts
[
provider
]
else
{
XCTFail
(
"No account for testing!"
)
return
}
if
correctPW
{
pw
=
account
.
pw
}
let
session
=
MailSession
(
configSession
:
.
IMAP
,
mailAddress
:
account
.
name
,
password
:
pw
,
username
:
nil
)
session
.
addListener
(
listener
:
self
)
XCTAssertEqual
(
account
.
name
,
session
.
username
)
XCTAssertEqual
(
account
.
name
,
session
.
mailAddr
)
XCTAssertEqual
(
pw
,
session
.
password
)
expect
=
expectation
(
description
:
"Login result"
)
if
!
session
.
loadFromProviderJson
()
{
XCTFail
(
"No provider json file!"
)
}
if
!
session
.
startTestingServerConfig
()
{
XCTFail
(
"No testing of config..."
)
}
if
let
expect
=
expect
{
wait
(
for
:
[
expect
],
timeout
:
30
)
}
if
correctPW
{
XCTAssert
(
result
??
false
)
}
else
{
XCTAssert
(
result
!=
nil
)
XCTAssert
(
!
result
!
)
}
}
func
testNoJson
()
{
let
accounts
=
MailServerConfigurationTest
.
loadAccounts
()
guard
let
account
=
accounts
[
"2"
]
else
{
XCTFail
(
"No account for testing!"
)
return
}
let
session
=
MailSession
(
configSession
:
.
IMAP
,
mailAddress
:
account
.
name
,
password
:
account
.
pw
,
username
:
nil
)
session
.
addListener
(
listener
:
self
)
let
expect
=
expectation
(
description
:
"OK"
)
session
.
startLongSearchOfServerConfig
(
hostFromAdr
:
true
)
wait
(
for
:
[
expect
],
timeout
:
60
)
if
session
.
loadFromProviderJson
()
{
XCTFail
(
"Wrong test case! Found in json file!"
)
}
if
session
.
startTestingServerConfigFromList
()
{
XCTFail
(
"Wrong test case! Json file exists."
)
}
if
!
session
.
startLongSearchOfServerConfig
(
hostFromAdr
:
true
)
{
XCTFail
(
"Could not start."
)
}
expect
=
expectation
(
description
:
"Login result"
)
if
let
expect
=
expect
{
wait
(
for
:
[
expect
],
timeout
:
30
)
}
XCTAssert
(
result
??
false
)
}
func
testDetailOnboarding
()
{
let
accounts
=
MailServerConfigurationTest
.
loadAccounts
()
guard
let
account
=
accounts
[
"1"
]
else
{
XCTFail
(
"No account for testing!"
)
return
}
let
session
=
MailSession
(
configSession
:
.
IMAP
,
mailAddress
:
"text@example.com"
,
password
:
"password"
,
username
:
"user"
)
session
.
addListener
(
listener
:
self
)
session
.
username
=
account
.
name
session
.
mailAddr
=
account
.
name
session
.
password
=
account
.
pw
session
.
setServer
(
hostname
:
"imap.web.de"
,
port
:
993
,
connType
:
MCOConnectionType
.
TLS
.
rawValue
,
authType
:
nil
)
if
!
session
.
startTestingServerConfig
()
{
XCTFail
(
"Could not test config."
)
}
expect
=
expectation
(
description
:
"Login result"
)
if
let
expect
=
expect
{
wait
(
for
:
[
expect
],
timeout
:
30
)
}
XCTAssert
(
result
??
false
)
}
func
testFinish
(
result
:
Bool
)
{
guard
let
expect
=
expect
else
{
XCTFail
(
"No expectation!"
)
return
}
self
.
result
=
result
expect
.
fulfill
()
}
static
func
loadAccounts
()
->
[(
name
:
String
,
pw
:
String
)]
{
private
static
func
loadAccounts
()
->
[
String
:
(
name
:
String
,
pw
:
String
)]
{
let
bundle
=
Bundle
(
for
:
self
)
var
newAccounts
=
[
String
:(
name
:
String
,
pw
:
String
)]()
guard
let
url
=
bundle
.
url
(
forResource
:
"accounts"
,
withExtension
:
"json"
),
let
data
=
try
?
Data
(
contentsOf
:
url
),
let
jsonDic
=
try
?
JSONSerialization
.
jsonObject
(
with
:
data
,
options
:
.
mutableLeaves
)
else
{
XCTFail
()
return
[]
return
[
:
]
}
print
(
jsonDic
)
return
[]
if
let
dic
=
jsonDic
as?
Dictionary
<
String
,
Any
>
{
if
let
accounts
=
dic
[
"accounts"
],
let
array
=
accounts
as?
Array
<
Any
>
{
for
elem
in
array
{
if
let
account
=
elem
as?
Dictionary
<
String
,
String
>
{
if
let
id
=
account
[
"id"
],
let
username
=
account
[
"username"
]
,
let
pw
=
account
[
"password"
]
{
newAccounts
[
id
]
=
(
username
,
pw
)
}
}
}
}
}
return
newAccounts
}
private
static
func
extractProvider
(
adr
:
String
)
->
String
?
{
return
adr
.
components
(
separatedBy
:
"@"
)
.
last
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment