Permalink
Browse files

Refactored Test Target

- Removed OC Mock
- Removed Test Project
- Updated Rake File
  • Loading branch information...
1 parent 9db6277 commit 00b23107c4b169d01a226e6c2cd1b254cdb2c56f @kcharwood kcharwood committed Oct 5, 2015
Showing with 791 additions and 1,006 deletions.
  1. +465 −0 AFNetworking.xcodeproj/project.pbxproj
  2. +56 −0 AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking Mac OS X Tests.xcscheme
  3. +12 −38 ...OS Tests.xcscheme → AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking iOS Tests.xcscheme
  4. +23 −0 AFNetworking.xcodeproj/xcshareddata/xcschemes/AFNetworking iOS.xcscheme
  5. +0 −6 AFNetworking.xcworkspace/contents.xcworkspacedata
  6. +26 −1 AFNetworking/AFSecurityPolicy.h
  7. +18 −10 AFNetworking/AFSecurityPolicy.m
  8. +14 −0 Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/OS X Example.xcscheme
  9. +17 −3 Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/Today Extension Example.xcscheme
  10. +14 −0 Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/iOS Example.xcscheme
  11. +14 −0 Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/tvOS Example.xcscheme
  12. +14 −0 Example/AFNetworking Example.xcodeproj/xcshareddata/xcschemes/watchOS Example.xcscheme
  13. +5 −5 Rakefile
  14. +0 −771 Tests/AFNetworking Tests.xcodeproj/project.pbxproj
  15. +0 −22 Tests/AFNetworkingTests-Info.plist
  16. +0 −2 Tests/OS X Tests/en.lproj/InfoPlist.strings
  17. +0 −22 Tests/Podfile
  18. +0 −83 Tests/Schemes/OS X Tests.xcscheme
  19. +1 −1 Tests/Tests/AFAutoPurgingImageCacheTests.m
  20. +1 −1 Tests/Tests/AFHTTPRequestSerializationTests.m
  21. +1 −1 Tests/Tests/AFImageDownloaderTests.m
  22. +4 −2 Tests/Tests/AFSecurityPolicyTests.m
  23. +0 −2 Tests/Tests/AFTestCase.h
  24. +2 −2 Tests/Tests/AFUIActivityIndicatorViewTests.m
  25. +102 −30 Tests/Tests/AFUIImageViewTests.m
  26. +2 −2 Tests/Tests/AFUIRefreshControlTests.m
  27. +0 −2 Tests/iOS Tests/en.lproj/InfoPlist.strings
Oops, something went wrong.
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+ LastUpgradeVersion = "0700"
+ version = "1.3">
+ <BuildAction
+ parallelizeBuildables = "YES"
+ buildImplicitDependencies = "YES">
+ </BuildAction>
+ <TestAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ shouldUseLaunchSchemeArgsEnv = "YES">
+ <Testables>
+ <TestableReference
+ skipped = "NO">
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "298D7C491BC2C7B200FD3B3E"
+ BuildableName = "AFNetworking Mac OS X Tests.xctest"
+ BlueprintName = "AFNetworking Mac OS X Tests"
+ ReferencedContainer = "container:AFNetworking.xcodeproj">
+ </BuildableReference>
+ </TestableReference>
+ </Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </TestAction>
+ <LaunchAction
+ buildConfiguration = "Debug"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+ selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+ launchStyle = "0"
+ useCustomWorkingDirectory = "NO"
+ ignoresPersistentStateOnLaunch = "NO"
+ debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
+ allowLocationSimulation = "YES">
+ <AdditionalOptions>
+ </AdditionalOptions>
+ </LaunchAction>
+ <ProfileAction
+ buildConfiguration = "Release"
+ shouldUseLaunchSchemeArgsEnv = "YES"
+ savedToolIdentifier = ""
+ useCustomWorkingDirectory = "NO"
+ debugDocumentVersioning = "YES">
+ </ProfileAction>
+ <AnalyzeAction
+ buildConfiguration = "Debug">
+ </AnalyzeAction>
+ <ArchiveAction
+ buildConfiguration = "Release"
+ revealArchiveInOrganizer = "YES">
+ </ArchiveAction>
+</Scheme>
@@ -1,76 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
- LastUpgradeVersion = "0460"
+ LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
- <BuildActionEntries>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "YES"
- buildForArchiving = "YES"
- buildForAnalyzing = "YES">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "FFF3BD339AD244DFA4115EC4"
- BuildableName = "libPods-ios.a"
- BlueprintName = "Pods-ios"
- ReferencedContainer = "container:Pods/Pods.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- <BuildActionEntry
- buildForTesting = "YES"
- buildForRunning = "YES"
- buildForProfiling = "NO"
- buildForArchiving = "NO"
- buildForAnalyzing = "NO">
- <BuildableReference
- BuildableIdentifier = "primary"
- BlueprintIdentifier = "2902D27717DF4E1100C81C5A"
- BuildableName = "iOS Tests.xctest"
- BlueprintName = "iOS Tests"
- ReferencedContainer = "container:AFNetworking Tests.xcodeproj">
- </BuildableReference>
- </BuildActionEntry>
- </BuildActionEntries>
</BuildAction>
<TestAction
+ buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
- buildConfiguration = "Debug">
+ codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
- BlueprintIdentifier = "2902D27717DF4E1100C81C5A"
- BuildableName = "iOS Tests.xctest"
- BlueprintName = "iOS Tests"
- ReferencedContainer = "container:AFNetworking Tests.xcodeproj">
+ BlueprintIdentifier = "298D7C3A1BC2C79500FD3B3E"
+ BuildableName = "AFNetworking iOS Tests.xctest"
+ BlueprintName = "AFNetworking iOS Tests"
+ ReferencedContainer = "container:AFNetworking.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
+ <AdditionalOptions>
+ </AdditionalOptions>
</TestAction>
<LaunchAction
+ buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
- buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
+ debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
+ buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
- buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
@@ -14,6 +14,20 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
+ BlueprintIdentifier = "298D7C3A1BC2C79500FD3B3E"
+ BuildableName = "AFNetworking iOS Tests.xctest"
+ BlueprintName = "AFNetworking iOS Tests"
+ ReferencedContainer = "container:AFNetworking.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
BlueprintIdentifier = "299522381BBF104D00859F49"
BuildableName = "AFNetworking.framework"
BlueprintName = "AFNetworking iOS"
@@ -29,6 +43,15 @@
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
+ <MacroExpansion>
+ <BuildableReference
+ BuildableIdentifier = "primary"
+ BlueprintIdentifier = "299522381BBF104D00859F49"
+ BuildableName = "AFNetworking.framework"
+ BlueprintName = "AFNetworking iOS"
+ ReferencedContainer = "container:AFNetworking.xcodeproj">
+ </BuildableReference>
+ </MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
@@ -7,10 +7,4 @@
<FileRef
location = "group:Example/AFNetworking Example.xcodeproj">
</FileRef>
- <FileRef
- location = "group:Tests/AFNetworking Tests.xcodeproj">
- </FileRef>
- <FileRef
- location = "group:Tests/Pods/Pods.xcodeproj">
- </FileRef>
</Workspace>
@@ -44,7 +44,11 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode;
/**
- The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
+ The certificates used to evaluate server trust according to the SSL pinning mode.
+
+ By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`.
+
+ Note that if you create an array with duplicate certificates, the duplicate certificates will be removed. Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches.
*/
@property (nonatomic, strong, nullable) NSArray *pinnedCertificates;
@@ -59,6 +63,17 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL validatesDomainName;
///-----------------------------------------
+/// @name Getting Certificates from the Bundle
+///-----------------------------------------
+
+/**
+ Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`.
+
+ @return The default security policy.
+ */
++ (NSArray *)certificatesInBundle:(NSBundle *)bundle;
+
+///-----------------------------------------
/// @name Getting Specific Security Policies
///-----------------------------------------
@@ -82,6 +97,16 @@ NS_ASSUME_NONNULL_BEGIN
*/
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode;
+/**
+ Creates and returns a security policy with the specified pinning mode.
+
+ @param pinningMode The SSL pinning mode.
+ @param pinnedCertificates The certificates to pin against.
+
+ @return A new security policy.
+ */
++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSArray *)pinnedCertificates;
+
///------------------------------
/// @name Evaluating Server Trust
///------------------------------
@@ -155,20 +155,24 @@ @interface AFSecurityPolicy()
@implementation AFSecurityPolicy
++ (NSArray *)certificatesInBundle:(NSBundle *)bundle {
+ NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
+
+ NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]];
+ for (NSString *path in paths) {
+ NSData *certificateData = [NSData dataWithContentsOfFile:path];
+ [certificates addObject:certificateData];
+ }
+
+ return [[NSArray alloc] initWithArray:certificates];
+}
+
+ (NSArray *)defaultPinnedCertificates {
static NSArray *_defaultPinnedCertificates = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
- NSArray *paths = [bundle pathsForResourcesOfType:@"cer" inDirectory:@"."];
-
- NSMutableArray *certificates = [NSMutableArray arrayWithCapacity:[paths count]];
- for (NSString *path in paths) {
- NSData *certificateData = [NSData dataWithContentsOfFile:path];
- [certificates addObject:certificateData];
- }
-
- _defaultPinnedCertificates = [[NSArray alloc] initWithArray:certificates];
+ _defaultPinnedCertificates = [self certificatesInBundle:bundle];
});
return _defaultPinnedCertificates;
@@ -182,10 +186,14 @@ + (instancetype)defaultPolicy {
}
+ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode {
+ return [self policyWithPinningMode:pinningMode withPinnedCertificates:[self defaultPinnedCertificates]];
+}
+
++ (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSArray *)pinnedCertificates {
AFSecurityPolicy *securityPolicy = [[self alloc] init];
securityPolicy.SSLPinningMode = pinningMode;
- [securityPolicy setPinnedCertificates:[self defaultPinnedCertificates]];
+ [securityPolicy setPinnedCertificates:pinnedCertificates];
return securityPolicy;
}
@@ -14,6 +14,20 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
+ BlueprintIdentifier = "298D7C491BC2C7B200FD3B3E"
+ BuildableName = "AFNetworking Mac OS X Tests.xctest"
+ BlueprintName = "AFNetworking Mac OS X Tests"
+ ReferencedContainer = "container:../AFNetworking.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
BlueprintIdentifier = "291BFDE61BB9E8C700FFB029"
BuildableName = "OS X Example.app"
BlueprintName = "OS X Example"
@@ -15,6 +15,20 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
+ BlueprintIdentifier = "298D7C3A1BC2C79500FD3B3E"
+ BuildableName = "AFNetworking iOS Tests.xctest"
+ BlueprintName = "AFNetworking iOS Tests"
+ ReferencedContainer = "container:../AFNetworking.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
BlueprintIdentifier = "29E6F1E51BB9E37200A4466C"
BuildableName = "Today Extension Example.appex"
BlueprintName = "Today Extension Example"
@@ -47,9 +61,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
- BlueprintIdentifier = "29E6F1E51BB9E37200A4466C"
- BuildableName = "Today Extension Example.appex"
- BlueprintName = "Today Extension Example"
+ BlueprintIdentifier = "29E6F1741BB9DCB500A4466C"
+ BuildableName = "iOS Example.app"
+ BlueprintName = "iOS Example"
ReferencedContainer = "container:AFNetworking Example.xcodeproj">
</BuildableReference>
</MacroExpansion>
@@ -14,6 +14,20 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
+ BlueprintIdentifier = "298D7C3A1BC2C79500FD3B3E"
+ BuildableName = "AFNetworking iOS Tests.xctest"
+ BlueprintName = "AFNetworking iOS Tests"
+ ReferencedContainer = "container:../AFNetworking.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
BlueprintIdentifier = "29E6F1741BB9DCB500A4466C"
BuildableName = "iOS Example.app"
BlueprintName = "iOS Example"
@@ -14,6 +14,20 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
+ BlueprintIdentifier = "298D7C3A1BC2C79500FD3B3E"
+ BuildableName = "AFNetworking iOS Tests.xctest"
+ BlueprintName = "AFNetworking iOS Tests"
+ ReferencedContainer = "container:../AFNetworking.xcodeproj">
+ </BuildableReference>
+ </BuildActionEntry>
+ <BuildActionEntry
+ buildForTesting = "YES"
+ buildForRunning = "YES"
+ buildForProfiling = "YES"
+ buildForArchiving = "YES"
+ buildForAnalyzing = "YES">
+ <BuildableReference
+ BuildableIdentifier = "primary"
BlueprintIdentifier = "291BFE141BB9ECEE00FFB029"
BuildableName = "tvOS Example.app"
BlueprintName = "tvOS Example"
Oops, something went wrong.

0 comments on commit 00b2310

Please sign in to comment.