merge "default" into my branch

LAS-10
Roker 6 years ago
commit 5a49f837a1

@ -96,7 +96,7 @@ const AccountSettings* get_account_settings(const char* accountName, const char*
if( dyn_as->status != AS_OK && (flags & AS_FLAG_USE_DNS_SRV) )
{
get_settings_from_srv(dyn_as, accountName, domain, provider );
get_settings_from_srv(dyn_as, accountName, domain, (provider?provider:"") );
}
if( dyn_as->status != AS_OK && (flags & AS_FLAG_USE_HEURISTICS) )

@ -14,12 +14,15 @@
43018BEA1EB99FF1004ABF26 /* stringpool.cc in Sources */ = {isa = PBXBuildFile; fileRef = 43018BE31EB99FF1004ABF26 /* stringpool.cc */; };
43018BEB1EB99FF1004ABF26 /* tinyxml2.cc in Sources */ = {isa = PBXBuildFile; fileRef = 43018BE41EB99FF1004ABF26 /* tinyxml2.cc */; };
43018BEC1EB99FF1004ABF26 /* xml2cxx.cc in Sources */ = {isa = PBXBuildFile; fileRef = 43018BE51EB99FF1004ABF26 /* xml2cxx.cc */; };
4344E4371FCC4EA700EEEA90 /* from_srv.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4344E4361FCC4EA700EEEA90 /* from_srv.cc */; };
43754AA81FCD61EF009A8E63 /* ldns_xcode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43754AA91FCD61EF009A8E63 /* ldns_xcode.framework */; };
43754AC91FCD9645009A8E63 /* ldns_xcode.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43754ACA1FCD9645009A8E63 /* ldns_xcode.framework */; };
B7089D901EBA2F1A0041F1E5 /* AccountSettingsServer.m in Sources */ = {isa = PBXBuildFile; fileRef = B7089D8F1EBA2F1A0041F1E5 /* AccountSettingsServer.m */; };
B72A64DB1EC0525500F71131 /* AccountSettingsAdapterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = B72A64DA1EC0525500F71131 /* AccountSettingsAdapterTests.m */; };
B72A64DD1EC0525500F71131 /* libAccountSettingsAdapter.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B7E0502D1EB2491E006EC1EC /* libAccountSettingsAdapter.a */; };
B72A64E61EC0802B00F71131 /* libc++.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = B72A64E41EC0800F00F71131 /* libc++.1.dylib */; };
B7E050321EB2491E006EC1EC /* ASAccountSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = B7E050311EB2491E006EC1EC /* ASAccountSettings.m */; };
B7E050331EB2491E006EC1EC /* ASAccountSettings.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B7E050301EB2491E006EC1EC /* ASAccountSettings.h */; };
B7E050321EB2491E006EC1EC /* AccountSettings.m in Sources */ = {isa = PBXBuildFile; fileRef = B7E050311EB2491E006EC1EC /* AccountSettings.m */; };
B7E050331EB2491E006EC1EC /* AccountSettings.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B7E050301EB2491E006EC1EC /* AccountSettings.h */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -39,7 +42,7 @@
dstPath = "include/$(PRODUCT_NAME)";
dstSubfolderSpec = 16;
files = (
B7E050331EB2491E006EC1EC /* ASAccountSettings.h in CopyFiles */,
B7E050331EB2491E006EC1EC /* AccountSettings.h in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -59,7 +62,10 @@
43018BF21EB9A05A004ABF26 /* stringpool.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = stringpool.hh; path = ../../src/stringpool.hh; sourceTree = "<group>"; };
43018BF31EB9A05A004ABF26 /* tinyxml2.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = tinyxml2.hh; path = ../../src/tinyxml2.hh; sourceTree = "<group>"; };
43018BF41EB9A05A004ABF26 /* xml2cxx.hh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = xml2cxx.hh; path = ../../src/xml2cxx.hh; sourceTree = "<group>"; };
431C06531ECDF350003C2B29 /* ASProtocols.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASProtocols.h; sourceTree = "<group>"; };
431C06531ECDF350003C2B29 /* AccountSettingsProtocols.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountSettingsProtocols.h; sourceTree = "<group>"; };
4344E4361FCC4EA700EEEA90 /* from_srv.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = from_srv.cc; path = ../../src/from_srv.cc; sourceTree = "<group>"; };
43754AA91FCD61EF009A8E63 /* ldns_xcode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ldns_xcode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
43754ACA1FCD9645009A8E63 /* ldns_xcode.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = ldns_xcode.framework; sourceTree = BUILT_PRODUCTS_DIR; };
43B1F9241EC05AD3002794B9 /* libstdc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libstdc++.tbd"; path = "usr/lib/libstdc++.tbd"; sourceTree = SDKROOT; };
B7089D8F1EBA2F1A0041F1E5 /* AccountSettingsServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AccountSettingsServer.m; sourceTree = "<group>"; };
B72A64D81EC0525500F71131 /* AccountSettingsAdapterTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AccountSettingsAdapterTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
@ -70,8 +76,8 @@
B7582BA51ED5884F003E4184 /* account_settings_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = account_settings_common.h; path = ../../include/account_settings_common.h; sourceTree = "<group>"; };
B781A9461EBC748700519E88 /* AccountSettingsServer+Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AccountSettingsServer+Internal.h"; sourceTree = "<group>"; };
B7E0502D1EB2491E006EC1EC /* libAccountSettingsAdapter.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAccountSettingsAdapter.a; sourceTree = BUILT_PRODUCTS_DIR; };
B7E050301EB2491E006EC1EC /* ASAccountSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ASAccountSettings.h; sourceTree = "<group>"; };
B7E050311EB2491E006EC1EC /* ASAccountSettings.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ASAccountSettings.m; sourceTree = "<group>"; };
B7E050301EB2491E006EC1EC /* AccountSettings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountSettings.h; sourceTree = "<group>"; };
B7E050311EB2491E006EC1EC /* AccountSettings.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AccountSettings.m; sourceTree = "<group>"; };
B7E050501EB25CD7006EC1EC /* AccountSettingsServer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AccountSettingsServer.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
@ -80,6 +86,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
43754AC91FCD9645009A8E63 /* ldns_xcode.framework in Frameworks */,
B72A64E61EC0802B00F71131 /* libc++.1.dylib in Frameworks */,
B72A64DD1EC0525500F71131 /* libAccountSettingsAdapter.a in Frameworks */,
);
@ -89,6 +96,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
43754AA81FCD61EF009A8E63 /* ldns_xcode.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -111,6 +119,8 @@
43B1F9231EC05AD3002794B9 /* Frameworks */ = {
isa = PBXGroup;
children = (
43754ACA1FCD9645009A8E63 /* ldns_xcode.framework */,
43754AA91FCD61EF009A8E63 /* ldns_xcode.framework */,
B72A64E41EC0800F00F71131 /* libc++.1.dylib */,
43B1F9241EC05AD3002794B9 /* libstdc++.tbd */,
);
@ -149,9 +159,9 @@
B7E0502F1EB2491E006EC1EC /* AccountSettingsAdapter */ = {
isa = PBXGroup;
children = (
431C06531ECDF350003C2B29 /* ASProtocols.h */,
B7E050301EB2491E006EC1EC /* ASAccountSettings.h */,
B7E050311EB2491E006EC1EC /* ASAccountSettings.m */,
431C06531ECDF350003C2B29 /* AccountSettingsProtocols.h */,
B7E050301EB2491E006EC1EC /* AccountSettings.h */,
B7E050311EB2491E006EC1EC /* AccountSettings.m */,
B7E050501EB25CD7006EC1EC /* AccountSettingsServer.h */,
B781A9461EBC748700519E88 /* AccountSettingsServer+Internal.h */,
B7089D8F1EBA2F1A0041F1E5 /* AccountSettingsServer.m */,
@ -181,6 +191,7 @@
B7E0503C1EB24973006EC1EC /* src */ = {
isa = PBXGroup;
children = (
4344E4361FCC4EA700EEEA90 /* from_srv.cc */,
43018BDF1EB99FF1004ABF26 /* account_settings_internal.cc */,
43018BE01EB99FF1004ABF26 /* accountSettings_test.cc */,
43018BE11EB99FF1004ABF26 /* implementation.cc */,
@ -240,7 +251,7 @@
B7E050251EB2491E006EC1EC /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = "pEp Security";
TargetAttributes = {
B72A64D71EC0525500F71131 = {
@ -355,11 +366,12 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B7E050321EB2491E006EC1EC /* ASAccountSettings.m in Sources */,
B7E050321EB2491E006EC1EC /* AccountSettings.m in Sources */,
B7089D901EBA2F1A0041F1E5 /* AccountSettingsServer.m in Sources */,
43018BE61EB99FF1004ABF26 /* account_settings_internal.cc in Sources */,
43018BEA1EB99FF1004ABF26 /* stringpool.cc in Sources */,
43018BE71EB99FF1004ABF26 /* accountSettings_test.cc in Sources */,
4344E4371FCC4EA700EEEA90 /* from_srv.cc in Sources */,
43018BEC1EB99FF1004ABF26 /* xml2cxx.cc in Sources */,
43018BEB1EB99FF1004ABF26 /* tinyxml2.cc in Sources */,
43018BE81EB99FF1004ABF26 /* implementation.cc in Sources */,
@ -410,7 +422,9 @@
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
@ -418,7 +432,11 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -458,7 +476,9 @@
CLANG_CXX_LIBRARY = "compiler-default";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
@ -466,7 +486,11 @@
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@ -496,6 +520,10 @@
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
CLANG_CXX_LIBRARY = "compiler-default";
DEVELOPMENT_TEAM = SBPJ2E4G5X;
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../../ldns",
"$(SRCROOT)/../../../OpenSSL-for-iPhone/include",
);
MACH_O_TYPE = staticlib;
OTHER_LDFLAGS = (
"-ObjC",
@ -512,6 +540,10 @@
CLANG_CXX_LANGUAGE_STANDARD = "c++14";
CLANG_CXX_LIBRARY = "compiler-default";
DEVELOPMENT_TEAM = SBPJ2E4G5X;
HEADER_SEARCH_PATHS = (
"$(SRCROOT)/../../../ldns",
"$(SRCROOT)/../../../OpenSSL-for-iPhone/include",
);
MACH_O_TYPE = staticlib;
OTHER_LDFLAGS = (
"-ObjC",

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:AccountSettingsAdapter.xcodeproj">
</FileRef>
<FileRef
location = "group:../../../ldns/xcode/ldns-xcode/ldns-xcode.xcodeproj">
</FileRef>
</Workspace>

@ -1,86 +0,0 @@
//
// AccountSettingsAdapter.m
// AccountSettingsAdapter
//
// Created by Xavier Algarra on 27/04/2017.
// Copyright © 2017 pEp Security. All rights reserved.
//
#import "ASAccountSettings.h"
#import "account_settings_c.h"
#import "AccountSettingsServer+Internal.h"
@interface ASAccountSettings ()
@property (nonatomic, nonnull) const struct AccountSettings *accountSettings;
- (instancetype _Nonnull )initWithAccountSettings:(const struct AccountSettings * _Nonnull)accountSettings;
@end
@implementation ASAccountSettings
- (instancetype _Nonnull )initWithAccountName:(NSString * _Nonnull)accountName
provider:(NSString * _Nullable)provider
flags:(AS_FLAGS)flags
credentials:(void * _Nullable)credentials
{
const struct AccountSettings *as =
get_account_settings([[accountName
precomposedStringWithCanonicalMapping] UTF8String],
[[provider precomposedStringWithCanonicalMapping] UTF8String],
flags, credentials);
return [self initWithAccountSettings:as];
}
- (instancetype)initWithAccountSettings:(const struct AccountSettings * _Nonnull)accountSettings
{
if (self = [super init]) {
_accountSettings = accountSettings;
}
return self;
}
- (void)dealloc
{
free_account_settings(self.accountSettings);
}
+ (ASAccountSettings * _Nonnull)accountSettingsWithAccountName:(NSString * _Nonnull)accountName
provider:(NSString * _Nullable)provider
flags:(AS_FLAGS)flags
credentials:(void * _Nullable)credentials
{
const struct AccountSettings *as =
get_account_settings([[accountName
precomposedStringWithCanonicalMapping] UTF8String],
[[provider precomposedStringWithCanonicalMapping] UTF8String],
flags, credentials);
ASAccountSettings *acountsettings = [[ASAccountSettings alloc] initWithAccountSettings:(as)];
return acountsettings;
}
- (AS_STATUS)status
{
return AS_get_status(self.accountSettings);
}
- (AccountSettingsServer *)incoming
{
const struct AS_Server *asIncoming = AS_get_incoming(self.accountSettings);
return [[AccountSettingsServer alloc] initWithAccountServer:asIncoming];
}
- (AccountSettingsServer *)outgoing
{
const struct AS_Server *asOutgoing = AS_get_outgoing(self.accountSettings);
return [[AccountSettingsServer alloc] initWithAccountServer:asOutgoing];
}
@end

@ -1,5 +1,5 @@
//
// AccountSettingsAdapter.h
// AccountSettings.h
// AccountSettingsAdapter
//
// Created by Xavier Algarra on 27/04/2017.
@ -10,9 +10,9 @@
#import "AccountSettingsServer.h"
#import "ASProtocols.h"
#import "AccountSettingsProtocols.h"
@interface ASAccountSettings: NSObject <AccountSettingsProtocol>
@interface AccountSettings: NSObject <AccountSettingsProtocol>
/**
@parameter accountName name of the account that will be configured
@ -26,8 +26,12 @@
flags:(AS_FLAGS)flags
credentials:(void * _Nullable)credentials;
@property (nonatomic, readonly, nonnull) NSString *accountName;
@property (nonatomic, readonly, nullable) NSString *provider;
@property (nonatomic, readonly) AS_FLAGS flags;
@property (nonatomic, readonly) AS_STATUS status;
@property (nonatomic, readonly, nonnull) AccountSettingsServer *incoming;
@property (nonatomic, readonly, nonnull) AccountSettingsServer *outgoing;
@property (nonatomic, readonly, nullable) AccountSettingsServer *incoming;
@property (nonatomic, readonly, nullable) AccountSettingsServer *outgoing;
@end

@ -0,0 +1,99 @@
//
// AccountSettings.m
// AccountSettingsAdapter
//
// Created by Xavier Algarra on 27/04/2017.
// Copyright © 2017 pEp Security. All rights reserved.
//
#import "AccountSettings.h"
#import "account_settings_c.h"
#import "AccountSettingsServer+Internal.h"
@interface AccountSettings ()
@property (nonatomic, nullable) const struct AccountSettings *accountSettings;
@property (nonatomic, nullable) void *credentials;
@property (nonatomic, nonnull) dispatch_queue_t backgroundQueue;
@end
@implementation AccountSettings
- (instancetype _Nonnull )initWithAccountName:(NSString * _Nonnull)accountName
provider:(NSString * _Nullable)provider
flags:(AS_FLAGS)flags
credentials:(void * _Nullable)credentials
{
if (self = [super init]) {
_accountName = accountName;
_provider = provider;
_flags = flags;
_credentials = credentials;
_backgroundQueue = dispatch_queue_create("AccountSettings.backgroundQueue",
DISPATCH_QUEUE_CONCURRENT);
}
return self;
}
- (void)lookup
{
const struct AccountSettings *as =
get_account_settings([[self.accountName
precomposedStringWithCanonicalMapping] UTF8String],
[[self.provider precomposedStringWithCanonicalMapping] UTF8String],
self.flags, self.credentials);
self.accountSettings = as;
}
- (void)lookupCompletion:(AccountSettingsCompletionBlock _Nullable)completionBlock
{
dispatch_async(self.backgroundQueue, ^ {
__weak typeof(self) weakSelf = self;
[weakSelf lookup];
if (weakSelf) {
completionBlock(weakSelf);
}
});
}
- (void)dealloc
{
free_account_settings(self.accountSettings);
}
+ (AccountSettings * _Nonnull)accountSettingsWithAccountName:(NSString * _Nonnull)accountName
provider:(NSString * _Nullable)provider
flags:(AS_FLAGS)flags
credentials:(void * _Nullable)credentials
{
return [[AccountSettings alloc]
initWithAccountName:accountName provider:provider
flags:flags credentials:credentials];
}
- (AS_STATUS)status
{
if (self.accountSettings) {
return AS_get_status(self.accountSettings);
} else {
return AS_ILLEGAL_VALUE;
}
}
- (AccountSettingsServer *)incoming
{
const struct AS_Server *asIncoming = AS_get_incoming(self.accountSettings);
return [[AccountSettingsServer alloc] initWithAccountServer:asIncoming];
}
- (AccountSettingsServer *)outgoing
{
const struct AS_Server *asOutgoing = AS_get_outgoing(self.accountSettings);
return [[AccountSettingsServer alloc] initWithAccountServer:asOutgoing];
}
@end

@ -1,13 +1,13 @@
//
// ASProtocols.h
// AccountSettingsProtocols.h
// AccountSettingsAdapter
//
// Created by Dirk Zimmermann on 18.05.17.
// Copyright © 2017 pEp Security. All rights reserved.
//
#ifndef ASProtocols_h
#define ASProtocols_h
#ifndef AccountSettingsProtocols_h
#define AccountSettingsProtocols_h
#import "account_settings_common.h"
@ -50,10 +50,41 @@ typedef NS_ENUM(NSInteger, AccountSettingsServerAuthMethod)
@protocol AccountSettingsProtocol
/**
Type for completion blocks into this library.
*/
typedef void (^AccountSettingsCompletionBlock)(id<AccountSettingsProtocol> _Nonnull);
@property (nonatomic, readonly, nonnull) NSString *accountName;
@property (nonatomic, readonly, nullable) NSString *provider;
@property (nonatomic, readonly) AS_FLAGS flags;
/**
Defined *after* lookup has finished.
*/
@property (nonatomic, readonly) AS_STATUS status;
@property (nonatomic, readonly, nonnull) id<AccountSettingsServerProtocol> incoming;
@property (nonatomic, readonly, nonnull) id<AccountSettingsServerProtocol> outgoing;
/**
Defined *after* lookup has finished, and status is AS_OK.
*/
@property (nonatomic, readonly, nullable) id<AccountSettingsServerProtocol> incoming;
/**
Defined *after* lookup has finished, and status is AS_OK.
*/
@property (nonatomic, readonly, nullable) id<AccountSettingsServerProtocol> outgoing;
/**
Tries to lookup account data based on the parameters given in init.
@Note This will make blocking network access.
*/
- (void)lookup;
/**
Will make an asynchronous lookup and call the provided block when finished.
*/
- (void)lookupCompletion:(AccountSettingsCompletionBlock _Nullable)completionBlock;
@end
#endif /* ASProtocols_h */
#endif /* AccountSettingsProtocols_h */

@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import "account_settings_common.h"
#import "ASProtocols.h"
#import "AccountSettingsProtocols.h"
@interface AccountSettingsServer: NSObject <AccountSettingsServerProtocol>

@ -7,7 +7,7 @@
//
#import <XCTest/XCTest.h>
#import "ASAccountSettings.h"
#import "AccountSettings.h"
@interface AccountSettingsAdapterTests : XCTestCase
@ -68,38 +68,34 @@
- (void)testNewpEpTestWrongFormatMailAccount
{
id<AccountSettingsProtocol> as = [[ASAccountSettings alloc]
id<AccountSettingsProtocol> as = [[AccountSettings alloc]
initWithAccountName:@" someone@peptest.ch"
provider:nil flags:AS_FLAG_USE_ANY
credentials:nil];
XCTAssertEqual(as.status, AS_OK);
}
- (void)testNewpEpTestWrongFormatMailAccountDomain
{
id<AccountSettingsProtocol> as = [[ASAccountSettings alloc]
initWithAccountName:@"someone@peptest.ch "
provider:nil flags:AS_FLAG_USE_ANY
credentials:nil];
[as lookup];
XCTAssertEqual(as.status, AS_NOT_FOUND);
XCTAssertEqual(as.status, AS_OK);
}
// Is currently crashing, waiting for LAS-14 to get fixed.
#if 0
- (void)testNewpEpTestUnexistentMailAccount
{
id<AccountSettingsProtocol> as = [[ASAccountSettings alloc]
id<AccountSettingsProtocol> as = [[AccountSettings alloc]
initWithAccountName:@"someone@example.com"
provider:nil flags:AS_FLAG_USE_ANY
credentials:nil];
[as lookup];
XCTAssertEqual(as.status, AS_NOT_FOUND);
}
#endif
// MARK: - Helpers
- (void)testServerWithAddress:(NSString *)address
- (void)verifyAccountSettings:(id<AccountSettingsProtocol>)accountSettings
address:(NSString *)address
incomingHostName:(NSString *)incomingHostName
incomingPort:(NSInteger)incomingPort
incomingProtocol:(AccountSettingsServerProtocolType)incomingProtocol
@ -111,26 +107,66 @@
outgoingTransport:(AccountSettingsServerTransport)outgoingTransport
outgoingAuthMethod:(AccountSettingsServerAuthMethod)outgoingAuthMethod
{
id<AccountSettingsProtocol> as = [[ASAccountSettings alloc]
initWithAccountName:address
provider:nil flags:AS_FLAG_USE_ANY
credentials:nil];
XCTAssertEqual(as.status, AS_OK);
XCTAssertEqual(accountSettings.status, AS_OK);
XCTAssertEqualObjects(accountSettings.incoming.username, address);
XCTAssertEqualObjects(accountSettings.incoming.hostname, incomingHostName);
XCTAssertEqual(accountSettings.incoming.port, incomingPort);
XCTAssertEqual(accountSettings.incoming.transport, incomingTransport);
XCTAssertEqual(accountSettings.incoming.authMethod, incomingAuthMethod);
XCTAssertEqual(accountSettings.incoming.protocol, incomingProtocol);
XCTAssertEqualObjects(accountSettings.outgoing.username, address);
XCTAssertEqualObjects(accountSettings.outgoing.hostname, outgoingHostName);
XCTAssertEqual(accountSettings.outgoing.port, outgoingPort);
XCTAssertEqual(accountSettings.outgoing.transport, outgoingTransport);
XCTAssertEqual(accountSettings.outgoing.authMethod, outgoingAuthMethod);
XCTAssertEqual(accountSettings.outgoing.protocol, outgoingProtocol);
}
XCTAssertEqualObjects(as.incoming.username, address);
XCTAssertEqualObjects(as.incoming.hostname, incomingHostName);
XCTAssertEqual(as.incoming.port, incomingPort);
XCTAssertEqual(as.incoming.transport, incomingTransport);
XCTAssertEqual(as.incoming.authMethod, incomingAuthMethod);
XCTAssertEqual(as.incoming.protocol, incomingProtocol);
XCTAssertEqualObjects(as.outgoing.username, address);
XCTAssertEqualObjects(as.outgoing.hostname, outgoingHostName);
XCTAssertEqual(as.outgoing.port, outgoingPort);
XCTAssertEqual(as.outgoing.transport, outgoingTransport);
XCTAssertEqual(as.outgoing.authMethod, outgoingAuthMethod);
XCTAssertEqual(as.outgoing.protocol, outgoingProtocol);
- (void)testServerWithAddress:(NSString *)address
incomingHostName:(NSString *)incomingHostName
incomingPort:(NSInteger)incomingPort
incomingProtocol:(AccountSettingsServerProtocolType)incomingProtocol
incomingTransport:(AccountSettingsServerTransport)incomingTransport
incomingAuthMethod:(AccountSettingsServerAuthMethod)incomingAuthMethod
outgoingHostName:(NSString *)outgoingHostName
outgoingPort:(NSInteger)outgoingPort
outgoingProtocol:(AccountSettingsServerProtocolType)outgoingProtocol
outgoingTransport:(AccountSettingsServerTransport)outgoingTransport
outgoingAuthMethod:(AccountSettingsServerAuthMethod)outgoingAuthMethod
{
for (NSInteger i = 0; i < 2; ++i) {
id<AccountSettingsProtocol> as = [[AccountSettings alloc]
initWithAccountName:address
provider:nil flags:AS_FLAG_USE_ANY
credentials:nil];
if (i == 0) {
[as lookup];
} else {
XCTestExpectation *expLookedUp = [self expectationWithDescription:@"expLookedUp"];
[as lookupCompletion:^(id<AccountSettingsProtocol> asParam) {
XCTAssertEqualObjects(as, asParam);
[self verifyAccountSettings:asParam address:address
incomingHostName:incomingHostName
incomingPort:incomingPort incomingProtocol:incomingProtocol
incomingTransport:incomingTransport incomingAuthMethod:incomingAuthMethod
outgoingHostName:outgoingHostName outgoingPort:outgoingPort
outgoingProtocol:outgoingProtocol outgoingTransport:outgoingTransport
outgoingAuthMethod:outgoingAuthMethod];
[expLookedUp fulfill];
}];
[self waitForExpectations:@[expLookedUp] timeout:30];
}
[self verifyAccountSettings:as address:address incomingHostName:incomingHostName
incomingPort:incomingPort incomingProtocol:incomingProtocol
incomingTransport:incomingTransport incomingAuthMethod:incomingAuthMethod
outgoingHostName:outgoingHostName outgoingPort:outgoingPort
outgoingProtocol:outgoingProtocol outgoingTransport:outgoingTransport
outgoingAuthMethod:outgoingAuthMethod];
}
}
@end

Loading…
Cancel
Save