Skip to content

Commit

Permalink
account.plist used to specify mail account data
Browse files Browse the repository at this point in the history
Instead of hardcoding it. Excluded from the repository via .gitignore. Also adding TestData to the project, compiled into the Test bundle.

Pushing the iOS deployment target down to 4.3, and ensuring that all projects have the same value there.
  • Loading branch information
scottnonnenberg committed Dec 21, 2012
1 parent 9c6c77e commit d3bf550
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@ xcuserdata
.DS_Store
include/
.idea
TestData/account.plist
10 changes: 8 additions & 2 deletions MailCore.xcodeproj/project.pbxproj
Expand Up @@ -117,6 +117,7 @@
F8EC5B0514C37F60006AF4D3 /* CTMIME_HtmlPart.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0214C37F60006AF4D3 /* CTMIME_HtmlPart.m */; };
F8EC5B0514C37F60006AF4D5 /* CTConnectedTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0514C37F60006AF4D4 /* CTConnectedTest.m */; };
F8EC5B0514C37F60006AF4D8 /* CTCoreFolderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F8EC5B0514C37F60006AF4D7 /* CTCoreFolderTests.m */; };
F9FC3A731683FC07004B2D1E /* TestData in Resources */ = {isa = PBXBuildFile; fileRef = F9FC3A721683FC07004B2D1E /* TestData */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -298,6 +299,7 @@
F8EC5B0514C37F60006AF4D6 /* CTConnectedTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTConnectedTest.h; path = Tests/CTConnectedTest.h; sourceTree = "<group>"; };
F8EC5B0514C37F60006AF4D7 /* CTCoreFolderTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTCoreFolderTests.m; path = Tests/CTCoreFolderTests.m; sourceTree = "<group>"; };
F8EC5B0514C37F60006AF4D9 /* CTCoreFolderTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTCoreFolderTests.h; path = Tests/CTCoreFolderTests.h; sourceTree = "<group>"; };
F9FC3A721683FC07004B2D1E /* TestData */ = {isa = PBXFileReference; lastKnownFileType = folder; path = TestData; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -359,6 +361,7 @@
F888632D158102F50088CF38 /* Cyrus SASL.xcodeproj */,
F890D38D10CEECD50039817C /* libetpan.xcodeproj */,
F85A18AF09C7D8F200305C06 /* Tests */,
F9FC3A721683FC07004B2D1E /* TestData */,
08FB77AEFE84172EC02AAC07 /* Classes */,
32C88DFF0371C24200C91783 /* Other Sources */,
089C1665FE841158C02AAC07 /* Resources */,
Expand Down Expand Up @@ -784,6 +787,7 @@
buildActionMask = 2147483647;
files = (
F8DFCF5615801A5000C01975 /* InfoPlist.strings in Resources */,
F9FC3A731683FC07004B2D1E /* TestData in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1033,6 +1037,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "libetpan/build-mac/include/**";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
LIBRARY_SEARCH_PATHS = "";
SDKROOT = macosx;
};
Expand All @@ -1049,6 +1054,7 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
HEADER_SEARCH_PATHS = "libetpan/build-mac/include/**";
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
LIBRARY_SEARCH_PATHS = "";
SDKROOT = macosx;
};
Expand Down Expand Up @@ -1111,7 +1117,7 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
INFOPLIST_FILE = "Tests/Tests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/iOSPorts/ports/security/cyrus-sasl/build/Debug-iphoneos\"",
Expand All @@ -1138,7 +1144,7 @@
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
INFOPLIST_FILE = "Tests/Tests-Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 5.1;
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/iOSPorts/ports/security/cyrus-sasl/build/Debug-iphoneos\"",
Expand Down
1 change: 1 addition & 0 deletions Tests/CTConnectedTest.h
Expand Up @@ -38,4 +38,5 @@
@interface CTConnectedTest : SenTestCase
@property (nonatomic, strong) CTCoreAccount *account;
@property (nonatomic, strong) CTCoreFolder *folder;
@property (nonatomic, strong) NSDictionary *credentials;
@end
57 changes: 49 additions & 8 deletions Tests/CTConnectedTest.m
Expand Up @@ -35,15 +35,41 @@

@implementation CTConnectedTest {
}
@synthesize account, folder;
NSString *SERVER = @"imap.gmail.com";
NSString *USERNAME = @"mailcoretests@gmail.com";
NSString *PASSWORD = @"MailCoreRockz";
@synthesize account, folder, credentials;

/* Create a TestData/account.plist file to make these tests work. Start with this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>username</key>
<string>username</string>
<key>password</key>
<string>password</string>
<key>server</key>
<string>server</string>
<key>port</key>
<integer>993</integer>
<key>path</key>
<string>MailCoreTests</string>
</dict>
</plist>
Because account.plist is included in the .gitignore file, your credentials won't be added
to source control.
*/

- (void)setUp {
NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"TestData/account" ofType:@"plist"];
self.credentials = [NSDictionary dictionaryWithContentsOfFile:filePath];

STAssertNotNil(self.credentials, @"These tests will fail anyway if they can't connect");

self.account = [[CTCoreAccount alloc] init];
[self connect];
self.folder = [self.account folderWithPath:@"Test"];
self.folder = [self.account folderWithPath:[self.credentials valueForKey:@"path"]];
[self.folder connect];
}

Expand All @@ -60,12 +86,27 @@ - (void)dealloc {
}

- (void)connect {
[self.account connectToServer:SERVER port:993 connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain
login:USERNAME password:PASSWORD];
NSString *server = [self.credentials valueForKey:@"server"];
int port = [[self.credentials objectForKey:@"port"] intValue];
NSString *username = [self.credentials valueForKey:@"username"];
NSString *password = [self.credentials valueForKey:@"password"];

STAssertFalse([server isEqualToString:@"server"], @"You need to provide your own account info");
STAssertFalse([username isEqualToString:@"username"], @"You need to provide your own account info");
STAssertFalse([password isEqualToString:@"password"], @"You need to provide your own account info");
/* Once you've provided your own account info, create a folder with six messages in it.
The path key in the account.plist should point to this directory, and you're ready! */

BOOL success = [self.account connectToServer:server port:port connectionType:CTConnectionTypeTLS authType:CTImapAuthTypePlain login:username password:password];

STAssertTrue(success, @"should successfully connect to email account");
if (!success) {
NSLog(@"!!!!!!! Can't connect to account !!!!!!! Error: %@", [[self.account lastError] localizedDescription]);
}
}

- (void)disconnect {
[self.folder disconnect];
[self.account disconnect];
}
@end
@end

0 comments on commit d3bf550

Please sign in to comment.