diff --git a/.gitignore b/.gitignore index 06bf202544f..9b9d51278e1 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,4 @@ AWS*.framework credentials.json Pods Podfile.lock +Documentation diff --git a/AWSCore/Authentication/AWSCredentialsProvider.h b/AWSCore/Authentication/AWSCredentialsProvider.h index 134d48796eb..b00caae89eb 100644 --- a/AWSCore/Authentication/AWSCredentialsProvider.h +++ b/AWSCore/Authentication/AWSCredentialsProvider.h @@ -134,7 +134,7 @@ typedef NS_ENUM(NSInteger, AWSCognitoLoginProviderKey) { /** * Refreshes the locally stored credentials. The SDK automatically calls this method when necessary, and you do not need to call this method manually. * - * @return <#return value description#> + * @return BFTask */ - (BFTask *)refresh; diff --git a/AWSCore/Authentication/AWSSignature.m b/AWSCore/Authentication/AWSSignature.m index 35250bec74f..ff1a51bd2d3 100644 --- a/AWSCore/Authentication/AWSSignature.m +++ b/AWSCore/Authentication/AWSSignature.m @@ -486,7 +486,7 @@ + (NSString *)getV2StringToSign:(NSMutableURLRequest *)request canonicalizedQuer @end -#pragma mark - AWSSignatureV2BodySigner +#pragma mark - AWSSignatureV2Signer @interface AWSSignatureV2Signer() @@ -587,6 +587,8 @@ @interface AWSS3ChunkedEncodingInputStream() @implementation AWSS3ChunkedEncodingInputStream +@synthesize delegate = _delegate; + - (instancetype)initWithInputStream:(NSInputStream *)stream date:(NSDate *)date scope:(NSString *)scope diff --git a/AWSCore/CognitoIdentityService/AWSCognitoIdentityService.m b/AWSCore/CognitoIdentityService/AWSCognitoIdentityService.m index 6e0524dfd3a..dc9df43bea7 100644 --- a/AWSCore/CognitoIdentityService/AWSCognitoIdentityService.m +++ b/AWSCore/CognitoIdentityService/AWSCognitoIdentityService.m @@ -104,7 +104,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSCognitoIdentityServiceErrorDomain]) { + && [error.domain isEqualToString:AWSCognitoIdentityServiceErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSCognitoIdentityServiceErrorIncompleteSignature: case AWSCognitoIdentityServiceErrorInvalidClientTokenId: diff --git a/AWSCore/EventRecorderService/AWSEventRecorderService.m b/AWSCore/EventRecorderService/AWSEventRecorderService.m index 2ebf1ebd544..3cd01389cda 100644 --- a/AWSCore/EventRecorderService/AWSEventRecorderService.m +++ b/AWSCore/EventRecorderService/AWSEventRecorderService.m @@ -146,7 +146,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSEventRecorderServiceErrorDomain]) { + && [error.domain isEqualToString:AWSEventRecorderServiceErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSEventRecorderServiceErrorIncompleteSignature: case AWSEventRecorderServiceErrorInvalidClientTokenId: diff --git a/AWSCore/MobileAnalytics/ThirdParty/reachability/AIReachability.h b/AWSCore/MobileAnalytics/ThirdParty/reachability/AIReachability.h deleted file mode 100644 index a2f5ddd6525..00000000000 --- a/AWSCore/MobileAnalytics/ThirdParty/reachability/AIReachability.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - Copyright (c) 2011, Tony Million. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - - -#import - -#import -#import -#import -#import -#import -#import - -/** - * Does ARC support support GCD objects? - * It does if the minimum deployment target is iOS 6+ or Mac OS X 8+ - **/ -#if TARGET_OS_IPHONE - -// Compiling for iOS - -#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 60000 // iOS 6.0 or later -#define NEEDS_DISPATCH_RETAIN_RELEASE 0 -#else // iOS 5.X or earlier -#define NEEDS_DISPATCH_RETAIN_RELEASE 1 -#endif - -#else - -// Compiling for Mac OS X - -#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1080 // Mac OS X 10.8 or later -#define NEEDS_DISPATCH_RETAIN_RELEASE 0 -#else -#define NEEDS_DISPATCH_RETAIN_RELEASE 1 // Mac OS X 10.7 or earlier -#endif - -#endif - -typedef enum -{ - // Apple NetworkStatus Compatible Names. - NotReachable = 0, - ReachableViaWiFi = 2, - ReachableViaWWAN = 1 -} NetworkStatus; - -@class AIReachability; - -typedef void (^NetworkReachable)(AIReachability * reachability); -typedef void (^NetworkUnreachable)(AIReachability * reachability); - -@interface AIReachability : NSObject - -@property (nonatomic, copy) NetworkReachable reachableBlock; -@property (nonatomic, copy) NetworkUnreachable unreachableBlock; - - -@property (nonatomic, assign) BOOL reachableOnWWAN; - -+(AIReachability*)reachabilityWithHostname:(NSString*)hostname; -+(AIReachability*)reachabilityForInternetConnection; -+(AIReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress; -+(AIReachability*)reachabilityForLocalWiFi; - --(AIReachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref; - -+(NSString*)AIReachabilityDidChangeNotificationName; - --(BOOL)startNotifier; --(void)stopNotifier; - --(BOOL)isReachable; --(BOOL)isReachableViaWWAN; --(BOOL)isReachableViaWiFi; - -// WWAN may be available, but not active until a connection has been established. -// WiFi may require a connection for VPN on Demand. --(BOOL)isConnectionRequired; // Identical DDG variant. --(BOOL)connectionRequired; // Apple's routine. -// Dynamic, on demand connection? --(BOOL)isConnectionOnDemand; -// Is user intervention required? --(BOOL)isInterventionRequired; - --(NetworkStatus)currentReachabilityStatus; --(SCNetworkReachabilityFlags)reachabilityFlags; --(NSString*)currentReachabilityString; --(NSString*)currentReachabilityFlags; - -@end diff --git a/AWSCore/MobileAnalytics/ThirdParty/reachability/AIReachability.m b/AWSCore/MobileAnalytics/ThirdParty/reachability/AIReachability.m deleted file mode 100644 index 2e99b011766..00000000000 --- a/AWSCore/MobileAnalytics/ThirdParty/reachability/AIReachability.m +++ /dev/null @@ -1,513 +0,0 @@ -/* - Copyright (c) 2011, Tony Million. - All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ - -#import "AIReachability.h" - -@interface AIReachability () - -@property (nonatomic, assign) SCNetworkReachabilityRef reachabilityRef; - - -#if NEEDS_DISPATCH_RETAIN_RELEASE -@property (nonatomic, assign) dispatch_queue_t reachabilitySerialQueue; -#else -@property (nonatomic, strong) dispatch_queue_t reachabilitySerialQueue; -#endif - - -@property (nonatomic, strong) id reachabilityObject; - --(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags; --(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags; - -@end - -static NSString *reachabilityFlags(SCNetworkReachabilityFlags flags) -{ - return [NSString stringWithFormat:@"%c%c %c%c%c%c%c%c%c", -#if TARGET_OS_IPHONE - (flags & kSCNetworkReachabilityFlagsIsWWAN) ? 'W' : '-', -#else - 'X', -#endif - (flags & kSCNetworkReachabilityFlagsReachable) ? 'R' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionRequired) ? 'c' : '-', - (flags & kSCNetworkReachabilityFlagsTransientConnection) ? 't' : '-', - (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) ? 'C' : '-', - (flags & kSCNetworkReachabilityFlagsConnectionOnDemand) ? 'D' : '-', - (flags & kSCNetworkReachabilityFlagsIsLocalAddress) ? 'l' : '-', - (flags & kSCNetworkReachabilityFlagsIsDirect) ? 'd' : '-']; -} - -//Start listening for reachability notifications on the current run loop -static void TMReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info) -{ -#pragma unused (target) -#if __has_feature(objc_arc) - AIReachability *reachability = ((__bridge AIReachability*)info); -#else - AIReachability *reachability = ((AIReachability*)info); -#endif - - // we probably dont need an autoreleasepool here as GCD docs state each queue has its own autorelease pool - // but what the heck eh? - @autoreleasepool - { - [reachability reachabilityChanged:flags]; - } -} - - -@implementation AIReachability - -@synthesize reachabilityRef; -@synthesize reachabilitySerialQueue; - -@synthesize reachableOnWWAN; - -@synthesize reachableBlock; -@synthesize unreachableBlock; - -@synthesize reachabilityObject; - -#pragma mark - class constructor methods -+(AIReachability*)reachabilityWithHostname:(NSString*)hostname -{ - SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithName(NULL, [hostname UTF8String]); - if (ref) - { - id reachability = [[self alloc] initWithReachabilityRef:ref]; - -#if __has_feature(objc_arc) - return reachability; -#else - return [reachability autorelease]; -#endif - - } - - return nil; -} - -+(AIReachability *)reachabilityWithAddress:(const struct sockaddr_in *)hostAddress -{ - SCNetworkReachabilityRef ref = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress); - if (ref) - { - id reachability = [[self alloc] initWithReachabilityRef:ref]; - -#if __has_feature(objc_arc) - return reachability; -#else - return [reachability autorelease]; -#endif - } - - return nil; -} - -+(AIReachability *)reachabilityForInternetConnection -{ - struct sockaddr_in zeroAddress; - bzero(&zeroAddress, sizeof(zeroAddress)); - zeroAddress.sin_len = sizeof(zeroAddress); - zeroAddress.sin_family = AF_INET; - - return [self reachabilityWithAddress:&zeroAddress]; -} - -+(AIReachability*)reachabilityForLocalWiFi -{ - struct sockaddr_in localWifiAddress; - bzero(&localWifiAddress, sizeof(localWifiAddress)); - localWifiAddress.sin_len = sizeof(localWifiAddress); - localWifiAddress.sin_family = AF_INET; - // IN_LINKLOCALNETNUM is defined in as 169.254.0.0 - localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM); - - return [self reachabilityWithAddress:&localWifiAddress]; -} - - -// initialization methods - --(AIReachability *)initWithReachabilityRef:(SCNetworkReachabilityRef)ref -{ - self = [super init]; - if (self != nil) - { - self.reachableOnWWAN = YES; - self.reachabilityRef = ref; - } - - return self; -} - --(void)dealloc -{ - [self stopNotifier]; - - if(self.reachabilityRef) - { - CFRelease(self.reachabilityRef); - self.reachabilityRef = nil; - } - - self.reachableBlock = nil; - self.unreachableBlock = nil; - -#if !(__has_feature(objc_arc)) - [super dealloc]; -#endif - - -} - -+(NSString*)AIReachabilityDidChangeNotificationName{ - return @"AIReachabilityDidChangeNotification"; -} - -#pragma mark - notifier methods - -// Notifier -// NOTE: this uses GCD to trigger the blocks - they *WILL NOT* be called on THE MAIN THREAD -// - In other words DO NOT DO ANY UI UPDATES IN THE BLOCKS. -// INSTEAD USE dispatch_async(dispatch_get_main_queue(), ^{UISTUFF}) (or dispatch_sync if you want) - --(BOOL)startNotifier -{ - SCNetworkReachabilityContext context = { 0, NULL, NULL, NULL, NULL }; - - // this should do a retain on ourself, so as long as we're in notifier mode we shouldn't disappear out from under ourselves - // woah - self.reachabilityObject = self; - - - - // first we need to create a serial queue - // we allocate this once for the lifetime of the notifier - self.reachabilitySerialQueue = dispatch_queue_create("com.tonymillion.reachability", NULL); - if(!self.reachabilitySerialQueue) - { - return NO; - } - -#if __has_feature(objc_arc) - context.info = (__bridge void *)self; -#else - context.info = (void *)self; -#endif - - if (!SCNetworkReachabilitySetCallback(self.reachabilityRef, TMReachabilityCallback, &context)) - { -#ifdef DEBUG - NSLog(@"SCNetworkReachabilitySetCallback() failed: %s", SCErrorString(SCError())); -#endif - - //clear out the dispatch queue - if(self.reachabilitySerialQueue) - { -#if NEEDS_DISPATCH_RETAIN_RELEASE - dispatch_release(self.reachabilitySerialQueue); -#endif - self.reachabilitySerialQueue = nil; - } - - self.reachabilityObject = nil; - - return NO; - } - - // set it as our reachability queue which will retain the queue - if(!SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, self.reachabilitySerialQueue)) - { -#ifdef DEBUG - NSLog(@"SCNetworkReachabilitySetDispatchQueue() failed: %s", SCErrorString(SCError())); -#endif - - //UH OH - FAILURE! - - // first stop any callbacks! - SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL); - - // then clear out the dispatch queue - if(self.reachabilitySerialQueue) - { -#if NEEDS_DISPATCH_RETAIN_RELEASE - dispatch_release(self.reachabilitySerialQueue); -#endif - self.reachabilitySerialQueue = nil; - } - - self.reachabilityObject = nil; - - return NO; - } - - return YES; -} - --(void)stopNotifier -{ - // first stop any callbacks! - SCNetworkReachabilitySetCallback(self.reachabilityRef, NULL, NULL); - - // unregister target from the GCD serial dispatch queue - SCNetworkReachabilitySetDispatchQueue(self.reachabilityRef, NULL); - - if(self.reachabilitySerialQueue) - { -#if NEEDS_DISPATCH_RETAIN_RELEASE - dispatch_release(self.reachabilitySerialQueue); -#endif - self.reachabilitySerialQueue = nil; - } - - self.reachabilityObject = nil; -} - -#pragma mark - reachability tests - -// this is for the case where you flick the airplane mode -// you end up getting something like this: -//Reachability: WR ct----- -//Reachability: -- ------- -//Reachability: WR ct----- -//Reachability: -- ------- -// we treat this as 4 UNREACHABLE triggers - really apple should do better than this - -#define testcase (kSCNetworkReachabilityFlagsConnectionRequired | kSCNetworkReachabilityFlagsTransientConnection) - --(BOOL)isReachableWithFlags:(SCNetworkReachabilityFlags)flags -{ - BOOL connectionUP = YES; - - if(!(flags & kSCNetworkReachabilityFlagsReachable)) - connectionUP = NO; - - if( (flags & testcase) == testcase ) - connectionUP = NO; - -#if TARGET_OS_IPHONE - if(flags & kSCNetworkReachabilityFlagsIsWWAN) - { - // we're on 3G - if(!self.reachableOnWWAN) - { - // we dont want to connect when on 3G - connectionUP = NO; - } - } -#endif - - return connectionUP; -} - --(BOOL)isReachable -{ - SCNetworkReachabilityFlags flags; - - if(!SCNetworkReachabilityGetFlags(self.reachabilityRef, &flags)) - return NO; - - return [self isReachableWithFlags:flags]; -} - --(BOOL)isReachableViaWWAN -{ -#if TARGET_OS_IPHONE - - SCNetworkReachabilityFlags flags = 0; - - if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - // check we're REACHABLE - if(flags & kSCNetworkReachabilityFlagsReachable) - { - // now, check we're on WWAN - if(flags & kSCNetworkReachabilityFlagsIsWWAN) - { - return YES; - } - } - } -#endif - - return NO; -} - --(BOOL)isReachableViaWiFi -{ - SCNetworkReachabilityFlags flags = 0; - - if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - // check we're reachable - if((flags & kSCNetworkReachabilityFlagsReachable)) - { -#if TARGET_OS_IPHONE - // check we're NOT on WWAN - if((flags & kSCNetworkReachabilityFlagsIsWWAN)) - { - return NO; - } -#endif - return YES; - } - } - - return NO; -} - - -// WWAN may be available, but not active until a connection has been established. -// WiFi may require a connection for VPN on Demand. --(BOOL)isConnectionRequired -{ - return [self connectionRequired]; -} - --(BOOL)connectionRequired -{ - SCNetworkReachabilityFlags flags; - - if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - return (flags & kSCNetworkReachabilityFlagsConnectionRequired); - } - - return NO; -} - -// Dynamic, on demand connection? --(BOOL)isConnectionOnDemand -{ - SCNetworkReachabilityFlags flags; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) && - (flags & (kSCNetworkReachabilityFlagsConnectionOnTraffic | kSCNetworkReachabilityFlagsConnectionOnDemand))); - } - - return NO; -} - -// Is user intervention required? --(BOOL)isInterventionRequired -{ - SCNetworkReachabilityFlags flags; - - if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - return ((flags & kSCNetworkReachabilityFlagsConnectionRequired) && - (flags & kSCNetworkReachabilityFlagsInterventionRequired)); - } - - return NO; -} - - -#pragma mark - reachability status stuff - --(NetworkStatus)currentReachabilityStatus -{ - if([self isReachable]) - { - if([self isReachableViaWiFi]) - return ReachableViaWiFi; - -#if TARGET_OS_IPHONE - return ReachableViaWWAN; -#endif - } - - return NotReachable; -} - --(SCNetworkReachabilityFlags)reachabilityFlags -{ - SCNetworkReachabilityFlags flags = 0; - - if(SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) - { - return flags; - } - - return 0; -} - --(NSString*)currentReachabilityString -{ - NetworkStatus temp = [self currentReachabilityStatus]; - - if(temp == reachableOnWWAN) - { - // updated for the fact we have CDMA phones now! - return NSLocalizedString(@"Cellular", @""); - } - if (temp == ReachableViaWiFi) - { - return NSLocalizedString(@"WiFi", @""); - } - - return NSLocalizedString(@"No Connection", @""); -} - --(NSString*)currentReachabilityFlags -{ - return reachabilityFlags([self reachabilityFlags]); -} - -#pragma mark - callback function calls this method - --(void)reachabilityChanged:(SCNetworkReachabilityFlags)flags -{ - if([self isReachableWithFlags:flags]) - { - if(self.reachableBlock) - { - self.reachableBlock(self); - } - } - else - { - if(self.unreachableBlock) - { - self.unreachableBlock(self); - } - } - - // this makes sure the change notification happens on the MAIN THREAD - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:[AIReachability AIReachabilityDidChangeNotificationName] - object:self]; - }); -} - -@end diff --git a/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSConnectivity.m b/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSConnectivity.m index 84cc71871fc..d9c17661807 100644 --- a/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSConnectivity.m +++ b/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSConnectivity.m @@ -14,17 +14,17 @@ */ #import "AWSMobileAnalyticsIOSConnectivity.h" -#import "AIReachability.h" +#import "Reachability.h" @interface AWSMobileAnalyticsIOSConnectivity() -@property (nonatomic, readwrite) AIReachability* reachability; +@property (nonatomic, readwrite) Reachability* reachability; @end @implementation AWSMobileAnalyticsIOSConnectivity --(id) initWithReachability:(AIReachability*) theReachability +-(id) initWithReachability:(Reachability*) theReachability { if(self = [super init]) { diff --git a/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSSystem.m b/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSSystem.m index dbd46b7cc63..331933d4a24 100644 --- a/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSSystem.m +++ b/AWSCore/MobileAnalytics/core/system/AWSMobileAnalyticsIOSSystem.m @@ -15,7 +15,7 @@ #import #import -#import "AIReachability.h" +#import "Reachability.h" #import "AWSMobileAnalyticsIOSSystem.h" #import "AWSMobileAnalyticsIOSLifeCycleManager.h" #import "AZLogging.h" @@ -43,7 +43,7 @@ -(id) initWithIdentifier: (NSString*) theIdentifier withRootPath:(NSString*) the _lifeCycleManager = [AWSMobileAnalyticsIOSLifeCycleManager manager]; - AIReachability *reachability = [AIReachability reachabilityForInternetConnection]; + Reachability *reachability = [Reachability reachabilityForInternetConnection]; self.connectivity = [[AWSMobileAnalyticsIOSConnectivity alloc] initWithReachability:reachability]; NSFileManager *internalFileManager = [NSFileManager defaultManager]; diff --git a/AWSCore/MobileAnalytics/include/core/system/AWSMobileAnalyticsIOSConnectivity.h b/AWSCore/MobileAnalytics/include/core/system/AWSMobileAnalyticsIOSConnectivity.h index cd836a4f40e..fc778a818a7 100644 --- a/AWSCore/MobileAnalytics/include/core/system/AWSMobileAnalyticsIOSConnectivity.h +++ b/AWSCore/MobileAnalytics/include/core/system/AWSMobileAnalyticsIOSConnectivity.h @@ -16,13 +16,13 @@ #import #import "AWSMobileAnalyticsConnectivity.h" -@class AIReachability; +@class Reachability; @interface AWSMobileAnalyticsIOSConnectivity : NSObject --(id) initWithReachability:(AIReachability*) theReachability; +-(id) initWithReachability:(Reachability*) theReachability; -@property (nonatomic, readonly) AIReachability* reachability; +@property (nonatomic, readonly) Reachability* reachability; -(BOOL) isConnected; diff --git a/AWSCore/Networking/AWSNetworking.m b/AWSCore/Networking/AWSNetworking.m index db69a41ef05..4409b5eb3b5 100644 --- a/AWSCore/Networking/AWSNetworking.m +++ b/AWSCore/Networking/AWSNetworking.m @@ -85,7 +85,7 @@ - (NSString *)userAgent { NSString *systemName = [[[UIDevice currentDevice] systemName] stringByReplacingOccurrencesOfString:@" " withString:@"-"]; NSString *systemVersion = [[UIDevice currentDevice] systemVersion]; NSString *localeIdentifier = [[NSLocale currentLocale] localeIdentifier]; - _userAgent = [NSString stringWithFormat:@"aws-sdk-iOS/%@ %@/%@ %@", @"2.0.3", systemName, systemVersion, localeIdentifier]; + _userAgent = [NSString stringWithFormat:@"aws-sdk-iOS/%@ %@/%@ %@", @"2.0.4", systemName, systemVersion, localeIdentifier]; }); return _userAgent; diff --git a/AWSCore/STS/AWSSTS.m b/AWSCore/STS/AWSSTS.m index 064f853a9cb..80e85a869e6 100644 --- a/AWSCore/STS/AWSSTS.m +++ b/AWSCore/STS/AWSSTS.m @@ -112,7 +112,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSSTSErrorDomain]) { + && [error.domain isEqualToString:AWSSTSErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSSTSErrorIncompleteSignature: case AWSSTSErrorInvalidClientTokenId: diff --git a/AWSCore/Serialization/AWSSerialization.m b/AWSCore/Serialization/AWSSerialization.m index b170a82e725..0e98ad54139 100644 --- a/AWSCore/Serialization/AWSSerialization.m +++ b/AWSCore/Serialization/AWSSerialization.m @@ -379,13 +379,15 @@ + (NSMutableDictionary *)dictionaryForXMLData:(NSData *)data return nil; } - //[XMLDictionaryParser sharedInstance].attributesMode = XMLDictionaryAttributesModeDiscard; + [XMLDictionaryParser sharedInstance].attributesMode = XMLDictionaryAttributesModeDiscard; //discard all xml attributes. e.g. xmlns [XMLDictionaryParser sharedInstance].stripEmptyNodes = NO; - //[XMLDictionaryParser sharedInstance].nodeNameMode = XMLDictionaryNodeNameModeNever; - NSMutableDictionary *xmlDictionary = [[[XMLDictionaryParser sharedInstance] dictionaryWithData:data] mutableCopy]; //TODO: need error parameters for parsing - NSString *rootNodeName = [xmlDictionary nodeName]; - [xmlDictionary removeObjectForKey:XMLDictionaryNodeNameKey]; - + [XMLDictionaryParser sharedInstance].wrapRootNode = YES; //wrapRootNode for easy process + [XMLDictionaryParser sharedInstance].nodeNameMode = XMLDictionaryNodeNameModeNever; //do not need rootName anymore since rootNode is wrapped. + NSMutableDictionary *rootXmlDictionary = [[[XMLDictionaryParser sharedInstance] dictionaryWithData:data] mutableCopy]; //TODO: need error parameters for parsing + NSString *rootNodeName = [[rootXmlDictionary allKeys] firstObject]; + + NSMutableDictionary *xmlDictionary = ([rootXmlDictionary[rootNodeName] isKindOfClass:[NSDictionary class]] && [rootXmlDictionary[rootNodeName] count] > 0)?rootXmlDictionary[rootNodeName]:rootXmlDictionary; + if (*error) { return nil; } else if ([rootNodeName isEqualToString:@"Error"]) { @@ -412,6 +414,15 @@ + (NSMutableDictionary *)dictionaryForXMLData:(NSData *)data NSMutableDictionary *parsedData = [self parseStructure:xmlDictionary rules:rules error:error]; + if ([parsedData count] == 0) { + //try again with rootDictionary if it is S3 response + NSString *serviceTypeStr = serviceDefinitionRule[@"metadata"][@"type"]?serviceDefinitionRule[@"metadata"][@"type"]:serviceDefinitionRule[@"metadata"][@"protocol"]; + if ([serviceTypeStr isEqualToString:@"rest-xml"]) { + xmlDictionary = [self preprocessDictionary:xmlDictionary operationName:actionName actionRule:actionRule serviceDefinitionRule:serviceDefinitionRule]; + parsedData = [self parseStructure:xmlDictionary rules:rules error:error]; + } + } + return parsedData; }; } @@ -596,8 +607,7 @@ + (NSArray *)parseList:(id)list rules:(AWSJSONDictionary *)rules error:(NSError } if (![list isKindOfClass:[NSArray class]]) { - [self failWithCode:AWSXMLParserUnExpectedType description:[NSString stringWithFormat:@"xml(list type) should be an array but got:%@",NSStringFromClass([list class])] error:error]; - return @[]; + return @[list]; } [list enumerateObjectsUsingBlock:^(id value, NSUInteger idx, BOOL *stop) { [data addObject:[self parseMember:value rules:memberRules error:&blockErr]]; @@ -629,7 +639,13 @@ + (id)parseMember:(id)values rules:(AWSJSONDictionary *)rules error:(NSError *__ if (![self validateConstraint:values rules:rules error:error]) return @"XMLPARSER:ERROR"; if ([rulesType isEqualToString:@"string"]) { - return values; + if ([values isKindOfClass:[NSString class]]) { + return values; + } else if ([values isKindOfClass:[NSDictionary class]] && [values count] == 0) { + return @""; + } else { + return [values description]; + } } else if ([rulesType isEqualToString:@"structure"]) { return [self parseStructure:values rules:rules[@"members"]?rules[@"members"]:@{} error:error]; } else if ([rulesType isEqualToString:@"list"]) { diff --git a/AWSCore/Serialization/AWSURLRequestRetryHandler.m b/AWSCore/Serialization/AWSURLRequestRetryHandler.m index e4b8d560ca7..eaf5055cc41 100644 --- a/AWSCore/Serialization/AWSURLRequestRetryHandler.m +++ b/AWSCore/Serialization/AWSURLRequestRetryHandler.m @@ -40,7 +40,7 @@ - (BOOL)isClockSkewError:(NSError *)error { || error.code == AWSGeneralErrorAuthFailure) { return YES; } - + return NO; } @@ -52,16 +52,20 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount self.isClockSkewRetried = YES; return AZNetworkingRetryTypeShouldCorrectClockSkewAndRetry; } - + if (currentRetryCount >= self.maxRetryCount) { return AZNetworkingRetryTypeShouldNotRetry; } if ([error.domain isEqualToString:NSURLErrorDomain]) { - return AZNetworkingRetryTypeShouldRetry; + switch (error.code) { + case kCFURLErrorNotConnectedToInternet: + return AZNetworkingRetryTypeShouldNotRetry; + + default: + return AZNetworkingRetryTypeShouldRetry; + } } - - //TODO: Add Clock Skew Here switch (response.statusCode) { case 500: @@ -72,7 +76,7 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount default: break; } - + return AZNetworkingRetryTypeShouldNotRetry; } diff --git a/AWSCore/Serialization/AWSURLRequestSerialization.m b/AWSCore/Serialization/AWSURLRequestSerialization.m index eab7fc24242..1f72681d20c 100644 --- a/AWSCore/Serialization/AWSURLRequestSerialization.m +++ b/AWSCore/Serialization/AWSURLRequestSerialization.m @@ -306,6 +306,42 @@ @interface AWSQueryStringRequestSerializer() @implementation AWSQueryStringRequestSerializer +- (NSMutableString *)processParameters:(NSDictionary *)parameters QueryString:(NSMutableString *)queryString { + for (NSString *key in parameters) { + id obj = parameters[key]; + + if ([obj isKindOfClass:[NSDictionary class]]) { + [self processParameters:obj QueryString:queryString]; + } else { + + if ([queryString length] > 0) { + [queryString appendString:@"&"]; + } + + if ([obj isKindOfClass:[NSString class]]) { + [queryString appendString:[key az_stringWithURLEncoding]]; + [queryString appendString:@"="]; + [queryString appendString:[obj az_stringWithURLEncoding]]; + } else if ([obj isKindOfClass:[NSNumber class]]) { + [queryString appendString:[key az_stringWithURLEncoding]]; + [queryString appendString:@"="]; + [queryString appendString:[[obj stringValue] az_stringWithURLEncoding]]; + } else if ([obj isKindOfClass:[NSDate class]]) { + [queryString appendString:[key az_stringWithURLEncoding]]; + [queryString appendString:@"="]; + [queryString appendString:[[obj az_stringValue:self.dateFormat] az_stringWithURLEncoding]]; + } else { + AZLogError(@"key[%@] is invalid.", key); + [queryString appendString:[key az_stringWithURLEncoding]]; + [queryString appendString:@"="]; + [queryString appendString:[[obj description]az_stringWithURLEncoding]]; + } + } + } + + return queryString; +} + - (BFTask *)serializeRequest:(NSMutableURLRequest *)request headers:(NSDictionary *)headers parameters:(NSDictionary *)parameters { @@ -316,30 +352,7 @@ - (BFTask *)serializeRequest:(NSMutableURLRequest *)request [parameters setValue:obj forKey:key]; }]; - [parameters enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { - if ([queryString length] > 0) { - [queryString appendString:@"&"]; - } - - if ([obj isKindOfClass:[NSString class]]) { - [queryString appendString:[key az_stringWithURLEncoding]]; - [queryString appendString:@"="]; - [queryString appendString:[obj az_stringWithURLEncoding]]; - } else if ([obj isKindOfClass:[NSNumber class]]) { - [queryString appendString:[key az_stringWithURLEncoding]]; - [queryString appendString:@"="]; - [queryString appendString:[[obj stringValue] az_stringWithURLEncoding]]; - } else if ([obj isKindOfClass:[NSDate class]]) { - [queryString appendString:[key az_stringWithURLEncoding]]; - [queryString appendString:@"="]; - [queryString appendString:[[obj az_stringValue:self.dateFormat] az_stringWithURLEncoding]]; - } else { - // TODO: This shouldn't happen. We should log this. - [queryString appendString:[key az_stringWithURLEncoding]]; - [queryString appendString:@"="]; - [queryString appendString:[obj description]]; - } - }]; + queryString = [self processParameters:parameters QueryString:queryString]; if ([queryString length] > 0) { request.HTTPBody = [queryString dataUsingEncoding:NSUTF8StringEncoding]; diff --git a/AWSCore/Serialization/AWSURLResponseSerialization.m b/AWSCore/Serialization/AWSURLResponseSerialization.m index b8eb433f80a..5f80959b379 100644 --- a/AWSCore/Serialization/AWSURLResponseSerialization.m +++ b/AWSCore/Serialization/AWSURLResponseSerialization.m @@ -54,19 +54,23 @@ - (id)responseObjectForResponse:(NSHTTPURLResponse *)response currentRequest:(NSURLRequest *)currentRequest data:(id)data error:(NSError *__autoreleasing *)error { + if ([response isKindOfClass:[NSHTTPURLResponse class]]) { + AZLogDebug(@"Response header: [%@]", response.allHeaderFields); + } + if ([data isKindOfClass:[NSData class]]) { AZLogVerbose(@"Response body: [%@]", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); } - + NSString *responseContentTypeStr = [[response allHeaderFields] objectForKey:@"Content-Type"]; if (responseContentTypeStr) { if ([responseContentTypeStr rangeOfString:@"text/html"].location != NSNotFound) { //found html response rather than json format. should be an error. if (error) { NSString *message = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - - + + *error = [NSError errorWithDomain:AWSGeneralErrorDomain code:AWSGeneralErrorUnknown userInfo:@{NSLocalizedDescriptionKey : message?message:[NSNull null]}]; @@ -74,7 +78,7 @@ - (id)responseObjectForResponse:(NSHTTPURLResponse *)response } } } - + if (!data) { return nil; } @@ -226,19 +230,23 @@ - (id)responseObjectForResponse:(NSHTTPURLResponse *)response currentRequest:(NSURLRequest *)currentRequest data:(id)data error:(NSError *__autoreleasing *)error { + if ([response isKindOfClass:[NSHTTPURLResponse class]]) { + AZLogDebug(@"Response header: [%@]", response.allHeaderFields); + } + if ([data isKindOfClass:[NSData class]]) { AZLogVerbose(@"Response body: [%@]", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]); } - + NSString *responseContentTypeStr = [[response allHeaderFields] objectForKey:@"Content-Type"]; if (responseContentTypeStr) { if ([responseContentTypeStr rangeOfString:@"text/html"].location != NSNotFound) { //found html response rather than xml format. should be an error. if (error) { NSString *message = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - - + + *error = [NSError errorWithDomain:AWSGeneralErrorDomain code:AWSGeneralErrorUnknown userInfo:@{NSLocalizedDescriptionKey : message?message:[NSNull null]}]; @@ -263,7 +271,7 @@ - (id)responseObjectForResponse:(NSHTTPURLResponse *)response data = [NSData dataWithContentsOfFile:[(NSURL *)data path]]; } } - + if ([resultDic count] == 0) { //if not blob type, try to parse as XML string resultDic = [AWSXMLParser dictionaryForXMLData:data diff --git a/AWSiOSSDKTests/AWSAnalyticsTests.m b/AWSiOSSDKTests/AWSAnalyticsTests.m index 90444b0dd4a..f38dd6309fc 100644 --- a/AWSiOSSDKTests/AWSAnalyticsTests.m +++ b/AWSiOSSDKTests/AWSAnalyticsTests.m @@ -18,7 +18,7 @@ #import #import "AWSCore.h" -#import "AZLogging.h" +#import "AWSTestUtility.h" #import "AWSMobileAnalyticsDeliveryClient.h" @@ -28,33 +28,22 @@ @interface AWSAnalyticsTests : XCTestCase @implementation AWSAnalyticsTests -- (void)setUp -{ +- (void)setUp { [super setUp]; - // Put setup code here. This method is called before the invocation of each test method in the class. - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } - + [AWSTestUtility setupCognitoCredentialsProvider]; } -- (void)tearDown -{ +- (void)tearDown { // Put teardown code here. This method is called after the invocation of each test method in the class. [super tearDown]; } -- (void)test_createMobileAnalyticsInstance -{ +- (void)test_createMobileAnalyticsInstance { AWSMobileAnalytics* insights = [AWSMobileAnalytics defaultMobileAnalyticsWithAppNamespace:@"newuniqueid"]; XCTAssertNotNil([insights eventClient]); } - (void)test_createAndSubmitEvent{ - AWSMobileAnalytics* insights = [AWSMobileAnalytics defaultMobileAnalyticsWithAppNamespace:@"newuniqueid"]; XCTAssertNotNil([insights eventClient]); diff --git a/AWSiOSSDKTests/AWSAutoScalingTests.m b/AWSiOSSDKTests/AWSAutoScalingTests.m index 2c0f56235ef..ce1641e68f1 100644 --- a/AWSiOSSDKTests/AWSAutoScalingTests.m +++ b/AWSiOSSDKTests/AWSAutoScalingTests.m @@ -17,6 +17,7 @@ #import #import "AutoScaling.h" +#import "AWSTestUtility.h" @interface AWSAutoScalingTests : XCTestCase @@ -26,13 +27,7 @@ @implementation AWSAutoScalingTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp { diff --git a/AWSiOSSDKTests/AWSClockSkewTests.m b/AWSiOSSDKTests/AWSClockSkewTests.m index 7ffacb881b1..466f9615b76 100644 --- a/AWSiOSSDKTests/AWSClockSkewTests.m +++ b/AWSiOSSDKTests/AWSClockSkewTests.m @@ -29,6 +29,7 @@ #import "ElasticLoadBalancing.h" #import "Kinesis.h" #import "AWSKinesis.h" +#import "AWSTestUtility.h" @import ObjectiveC.runtime; @@ -43,15 +44,16 @@ @implementation AWSClockSkewTests Method _mockDateMethod; static char mockDateKey; -- (void)setUp -{ +- (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { + [AWSTestUtility setupCognitoCredentialsProvider]; + + if (![[AWSServiceManager defaultServiceManager] serviceForKey:@"test-sts"]) { AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; + AWSSTS *sts = [[AWSSTS alloc] initWithConfiguration:configuration]; + [[AWSServiceManager defaultServiceManager] setService:sts forKey:@"test-sts"]; } // Start by having the mock return the test startup date @@ -178,8 +180,7 @@ -(void)testClockSkewSimpleDB if (task.result) { AWSSimpleDBListDomainsResult *listDomainsResult = task.result; - XCTAssertNotNil(listDomainsResult.domainNames, @" doemainNames Array should not be nil."); - AZLogDebug(@"[%@]", listDomainsResult); + XCTAssertNotNil(listDomainsResult, @"listDomainsResult should not be nil."); } return nil; @@ -389,7 +390,7 @@ -(void)testClockSkewSTS XCTAssertFalse([NSDate az_getRuntimeClockSkew], @"current RunTimeClockSkew is not zero!"); [self setMockDate:[NSDate dateWithTimeIntervalSince1970:3600]]; - AWSSTS *sts = [AWSSTS defaultSTS]; + AWSSTS *sts = (AWSSTS *)[[AWSServiceManager defaultServiceManager] serviceForKey:@"test-sts"]; XCTAssertNotNil(sts); AWSSTSGetSessionTokenRequest *getSessionTokenRequest = [AWSSTSGetSessionTokenRequest new]; diff --git a/AWSiOSSDKTests/AWSCloudWatchTests.m b/AWSiOSSDKTests/AWSCloudWatchTests.m index 70d56212906..c85ea91c1e9 100644 --- a/AWSiOSSDKTests/AWSCloudWatchTests.m +++ b/AWSiOSSDKTests/AWSCloudWatchTests.m @@ -17,6 +17,7 @@ #import #import "CloudWatch.h" +#import "AWSTestUtility.h" @interface AWSCloudWatchTests : XCTestCase @@ -26,13 +27,7 @@ @implementation AWSCloudWatchTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp { diff --git a/AWSiOSSDKTests/AWSCognitoCredentialsProviderTests.m b/AWSiOSSDKTests/AWSCognitoCredentialsProviderTests.m index 66f6aade2fd..33351c5b07b 100644 --- a/AWSiOSSDKTests/AWSCognitoCredentialsProviderTests.m +++ b/AWSiOSSDKTests/AWSCognitoCredentialsProviderTests.m @@ -17,6 +17,7 @@ #import #import "AWSCore.h" +#import "AWSTestUtility.h" @interface AWSCognitoCredentialsProviderTests : XCTestCase @@ -41,12 +42,8 @@ @implementation AWSCognitoCredentialsProviderTests #pragma mark - Set up/Tear down + (void)setUp { - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [super setUp]; + [AWSTestUtility setupCognitoCredentialsProvider]; NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"credentials" ofType:@"json"]; diff --git a/AWSiOSSDKTests/AWSCognitoIdentityServiceTests.m b/AWSiOSSDKTests/AWSCognitoIdentityServiceTests.m index cfabae97011..b05629d76bb 100644 --- a/AWSiOSSDKTests/AWSCognitoIdentityServiceTests.m +++ b/AWSiOSSDKTests/AWSCognitoIdentityServiceTests.m @@ -18,6 +18,7 @@ #import #import "CognitoIdentityService.h" #import "STS.h" +#import "AWSTestUtility.h" @interface AWSCognitoIdentityServiceTests : XCTestCase @@ -27,13 +28,7 @@ @implementation AWSCognitoIdentityServiceTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoIdentityService]; } - (void)setUp { @@ -47,7 +42,7 @@ - (void)tearDown { } - (void)testListIdentityPools { - AWSCognitoIdentityService *cib = [AWSCognitoIdentityService defaultCognitoIdentityService]; + AWSCognitoIdentityService *cib = (AWSCognitoIdentityService *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilityCognitoIdentityServiceKey]; AWSCognitoIdentityServiceListIdentityPoolsInput *listPools = [AWSCognitoIdentityServiceListIdentityPoolsInput new]; listPools.maxResults = [NSNumber numberWithInt:10]; @@ -65,7 +60,7 @@ - (void)testListIdentityPools { } - (void)testCreateDeleteIdentityPool { - AWSCognitoIdentityService *cib = [AWSCognitoIdentityService defaultCognitoIdentityService]; + AWSCognitoIdentityService *cib = (AWSCognitoIdentityService *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilityCognitoIdentityServiceKey]; AWSCognitoIdentityServiceCreateIdentityPoolInput *createPool = [AWSCognitoIdentityServiceCreateIdentityPoolInput new]; createPool.identityPoolName = @"CIBiOSTestCreateDeleteIdentityPool"; @@ -95,7 +90,7 @@ - (void)testCreateDeleteIdentityPool { } - (void)testDeleteIdentityPoolFailed { - AWSCognitoIdentityService *cib = [AWSCognitoIdentityService defaultCognitoIdentityService]; + AWSCognitoIdentityService *cib = (AWSCognitoIdentityService *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilityCognitoIdentityServiceKey]; AWSCognitoIdentityServiceDeleteIdentityPoolInput *deletePool = [AWSCognitoIdentityServiceDeleteIdentityPoolInput new]; deletePool.identityPoolId = @"us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"; //Non-existent PoolId @@ -108,7 +103,7 @@ - (void)testDeleteIdentityPoolFailed { } - (void)testUpdateIdentityPoolPoolFailed { - AWSCognitoIdentityService *cib = [AWSCognitoIdentityService defaultCognitoIdentityService]; + AWSCognitoIdentityService *cib = (AWSCognitoIdentityService *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilityCognitoIdentityServiceKey]; AWSCognitoIdentityServiceIdentityPool *updatePoolInput = [AWSCognitoIdentityServiceIdentityPool new]; updatePoolInput.identityPoolId = @"us-east-1:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"; //Non-existent PoolId @@ -124,9 +119,8 @@ - (void)testUpdateIdentityPoolPoolFailed { - (void)testGetIdGetToken { - - AWSSTS *sts = [AWSSTS defaultSTS]; - AWSCognitoIdentityService *cib = [AWSCognitoIdentityService defaultCognitoIdentityService]; + AWSSTS *sts = (AWSSTS *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilitySTSKey]; + AWSCognitoIdentityService *cib = (AWSCognitoIdentityService *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilityCognitoIdentityServiceKey]; __block AWSSTSAssumeRoleWithWebIdentityRequest *wifRequest = nil; diff --git a/AWSiOSSDKTests/AWSDynamoDBObjectMapperTests.m b/AWSiOSSDKTests/AWSDynamoDBObjectMapperTests.m index 2bba028939a..69296f13560 100644 --- a/AWSiOSSDKTests/AWSDynamoDBObjectMapperTests.m +++ b/AWSiOSSDKTests/AWSDynamoDBObjectMapperTests.m @@ -17,6 +17,7 @@ #import #import "DynamoDB.h" +#import "AWSTestUtility.h" NSString *const AWSDynamoDBObjectMapperTestTable = @"DynamoDBOMTest"; @@ -57,13 +58,7 @@ @implementation AWSDynamoDBObjectMapperTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; tableName = [NSString stringWithFormat:@"%@-%f", AWSDynamoDBObjectMapperTestTable, timeIntervalSinceReferenceDate]; @@ -205,10 +200,10 @@ + (BOOL)deleteTable:(NSString *)tableName { } else { succeeded = YES; } - + return nil; }] waitUntilFinished]; - + return succeeded; } @@ -288,7 +283,7 @@ - (void)testAll { if (task.error) { XCTFail(@"Error: [%@]", task.error); } - + return nil; }] waitUntilFinished]; } diff --git a/AWSiOSSDKTests/AWSDynamoDBTests.m b/AWSiOSSDKTests/AWSDynamoDBTests.m index 9f821a1b2c2..85f08313cd6 100644 --- a/AWSiOSSDKTests/AWSDynamoDBTests.m +++ b/AWSiOSSDKTests/AWSDynamoDBTests.m @@ -17,6 +17,7 @@ #import #import "DynamoDB.h" +#import "AWSTestUtility.h" NSString *const AWSDynamoDBTestTable1 = @"AWSSDKForiOSv2Test1"; NSString *const AWSDynamoDBTestTable2 = @"AWSSDKForiOSv2Test2"; @@ -34,13 +35,7 @@ @implementation AWSDynamoDBTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; table1Name = [NSString stringWithFormat:@"%@-%f", AWSDynamoDBTestTable1, timeIntervalSinceReferenceDate]; @@ -725,48 +720,48 @@ - (void)testCreateAndDeleteTable { } /* -- (void)testThrottling { - XCTAssertTrue([[self class] createTable:table2Name], @"Failed to create a table."); - - AWSDynamoDB *dynamoDB = [AWSDynamoDB defaultDynamoDB]; - - NSMutableString *mutableString = [NSMutableString new]; - for(int32_t i = 0; i < 5000; i++) { - [mutableString appendString:@"0123456789"]; - } - - BFTask *task = [BFTask taskWithResult:nil]; - - for (int32_t i = 0; i < 200; i++) { - task = [task continueWithSuccessBlock:^id(BFTask *task) { - //Put item - AWSDynamoDBPutItemInput *putItemInput = [AWSDynamoDBPutItemInput new]; - putItemInput.tableName = table2Name; - AWSDynamoDBAttributeValue *hashValue = [AWSDynamoDBAttributeValue new]; - hashValue.S = [NSString stringWithFormat:@"testPutItem%d", i]; - AWSDynamoDBAttributeValue *otherValue = [AWSDynamoDBAttributeValue new]; - otherValue.S = [NSString stringWithFormat:@"%@%d", mutableString, i]; - putItemInput.item = @{ - @"hashKey" : hashValue, - @"otherKey" : otherValue - }; - return [dynamoDB putItem:putItemInput]; - }]; - } - - [[task continueWithBlock:^id(BFTask *task) { - if (!task.error - && !([task.error.domain isEqualToString:AWSDynamoDBErrorDomain] - || task.error.code == AWSDynamoDBErrorProvisionedThroughputExceeded)) { - XCTFail(@"Throttling didn't happen. result: [%@] error: [%@]", task.result, task.error); - } - - return nil; - }] waitUntilFinished]; - - XCTAssertTrue([[self class] deleteTable:table2Name], @"Failed to delete a table."); -} -*/ + - (void)testThrottling { + XCTAssertTrue([[self class] createTable:table2Name], @"Failed to create a table."); + + AWSDynamoDB *dynamoDB = [AWSDynamoDB defaultDynamoDB]; + + NSMutableString *mutableString = [NSMutableString new]; + for(int32_t i = 0; i < 5000; i++) { + [mutableString appendString:@"0123456789"]; + } + + BFTask *task = [BFTask taskWithResult:nil]; + + for (int32_t i = 0; i < 200; i++) { + task = [task continueWithSuccessBlock:^id(BFTask *task) { + //Put item + AWSDynamoDBPutItemInput *putItemInput = [AWSDynamoDBPutItemInput new]; + putItemInput.tableName = table2Name; + AWSDynamoDBAttributeValue *hashValue = [AWSDynamoDBAttributeValue new]; + hashValue.S = [NSString stringWithFormat:@"testPutItem%d", i]; + AWSDynamoDBAttributeValue *otherValue = [AWSDynamoDBAttributeValue new]; + otherValue.S = [NSString stringWithFormat:@"%@%d", mutableString, i]; + putItemInput.item = @{ + @"hashKey" : hashValue, + @"otherKey" : otherValue + }; + return [dynamoDB putItem:putItemInput]; + }]; + } + + [[task continueWithBlock:^id(BFTask *task) { + if (!task.error + && !([task.error.domain isEqualToString:AWSDynamoDBErrorDomain] + || task.error.code == AWSDynamoDBErrorProvisionedThroughputExceeded)) { + XCTFail(@"Throttling didn't happen. result: [%@] error: [%@]", task.result, task.error); + } + + return nil; + }] waitUntilFinished]; + + XCTAssertTrue([[self class] deleteTable:table2Name], @"Failed to delete a table."); + } + */ @end diff --git a/AWSiOSSDKTests/AWSEC2Tests.m b/AWSiOSSDKTests/AWSEC2Tests.m index 03ee1c56672..4d2bfb33044 100644 --- a/AWSiOSSDKTests/AWSEC2Tests.m +++ b/AWSiOSSDKTests/AWSEC2Tests.m @@ -17,6 +17,7 @@ #import #import "EC2.h" +#import "AWSTestUtility.h" @interface AWSEC2Tests : XCTestCase @@ -26,13 +27,7 @@ @implementation AWSEC2Tests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp { diff --git a/AWSiOSSDKTests/AWSERSTests.m b/AWSiOSSDKTests/AWSERSTests.m index ada14b4e97a..5c89d1a161b 100644 --- a/AWSiOSSDKTests/AWSERSTests.m +++ b/AWSiOSSDKTests/AWSERSTests.m @@ -18,6 +18,7 @@ #import #import "AWSCore.h" +#import "AWSTestUtility.h" @interface AWSERSTests : XCTestCase @@ -28,13 +29,7 @@ @implementation AWSERSTests - (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)tearDown diff --git a/AWSiOSSDKTests/AWSElasticLoadBalancingTests.m b/AWSiOSSDKTests/AWSElasticLoadBalancingTests.m index 274befbae2a..19e65e8c4e8 100644 --- a/AWSiOSSDKTests/AWSElasticLoadBalancingTests.m +++ b/AWSiOSSDKTests/AWSElasticLoadBalancingTests.m @@ -17,6 +17,7 @@ #import #import "ElasticLoadBalancing.h" +#import "AWSTestUtility.h" @interface AWSElasticLoadBalancingTests : XCTestCase @@ -26,13 +27,7 @@ @implementation AWSElasticLoadBalancingTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp { diff --git a/AWSiOSSDKTests/AWSKinesisRecorderTests.m b/AWSiOSSDKTests/AWSKinesisRecorderTests.m index a9bc9862b51..8b7c011d521 100644 --- a/AWSiOSSDKTests/AWSKinesisRecorderTests.m +++ b/AWSiOSSDKTests/AWSKinesisRecorderTests.m @@ -17,7 +17,7 @@ #import #import "Kinesis.h" -#import "AWSKinesis.h" +#import "AWSTestUtility.h" NSString *const AWSKinesisRecorderTestStream = @"AWSSDKForiOSv2Test"; @@ -31,13 +31,7 @@ @implementation AWSKinesisRecorderTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; testStreamName = [NSString stringWithFormat:@"%@-%f", AWSKinesisRecorderTestStream, timeIntervalSinceReferenceDate]; diff --git a/AWSiOSSDKTests/AWSKinesisTests.m b/AWSiOSSDKTests/AWSKinesisTests.m index a2c9a9bc3aa..d65ca0b8b38 100644 --- a/AWSiOSSDKTests/AWSKinesisTests.m +++ b/AWSiOSSDKTests/AWSKinesisTests.m @@ -17,7 +17,7 @@ #import #import "Kinesis.h" -#import "AWSKinesis.h" +#import "AWSTestUtility.h" NSString *const AWSKinesisTestStream = @"AWSSDKForiOSv2Test"; @@ -31,13 +31,7 @@ @implementation AWSKinesisTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; testStreamName = [NSString stringWithFormat:@"%@-%f", AWSKinesisTestStream, timeIntervalSinceReferenceDate]; diff --git a/AWSiOSSDKTests/AWSS3Tests.m b/AWSiOSSDKTests/AWSS3Tests.m index cdfc87e1e72..78bf1a9bed3 100644 --- a/AWSiOSSDKTests/AWSS3Tests.m +++ b/AWSiOSSDKTests/AWSS3Tests.m @@ -17,6 +17,7 @@ #import #import "S3.h" +#import "AWSTestUtility.h" @interface AWSS3Tests : XCTestCase @@ -32,13 +33,7 @@ @implementation AWSS3Tests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; //Create bucketName NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; @@ -67,6 +62,10 @@ + (BOOL)createBucketWithName:(NSString *)bucketName { AWSS3CreateBucketRequest *createBucketReq = [AWSS3CreateBucketRequest new]; createBucketReq.bucket = bucketName; +// AWSS3CreateBucketConfiguration *createBucketConfiguration = [AWSS3CreateBucketConfiguration new]; +// createBucketConfiguration.locationConstraint = AWSS3BucketLocationConstraintUSWest2; +// createBucketReq.createBucketConfiguration = createBucketConfiguration; + __block BOOL success = NO; [[[s3 createBucket:createBucketReq] continueWithBlock:^id(BFTask *task) { if (task.error) { @@ -621,6 +620,22 @@ - (void)testMultipartUploadWithComplete { }] waitUntilFinished]; } +- (void)testGetBucketLocation { + AWSS3 *s3 = [AWSS3 defaultS3]; + AWSS3GetBucketLocationRequest *getBucketLocationRequest = [AWSS3GetBucketLocationRequest new]; + getBucketLocationRequest.bucket = testBucketNameGeneral; + + [[[s3 getBucketLocation:getBucketLocationRequest] continueWithBlock:^id(BFTask *task) { + if(task.error != nil){ + XCTAssertNil(task.error, @"The request failed. error: [%@]", task.error); + } + + AWSS3GetBucketLocationOutput *getBucketLocationOutput = task.result; + XCTAssertEqual(getBucketLocationOutput.locationConstraint, AWSS3BucketLocationConstraintBlank); + return nil; + }] waitUntilFinished]; +} + @end #endif diff --git a/AWSiOSSDKTests/AWSS3TransferManagerTests.m b/AWSiOSSDKTests/AWSS3TransferManagerTests.m index 6a204052ed0..cad96f0e426 100644 --- a/AWSiOSSDKTests/AWSS3TransferManagerTests.m +++ b/AWSiOSSDKTests/AWSS3TransferManagerTests.m @@ -17,6 +17,7 @@ #import #import "S3.h" +#import "AWSTestUtility.h" @interface AWSS3TransferManagerTests : XCTestCase @@ -31,15 +32,7 @@ @implementation AWSS3TransferManagerTests + (void)setUp { [super setUp]; - //[AZLogger defaultLogger].logLevel = AZLogLevelVerbose; - // Put setup code here. This method is called before the invocation of each test method in the class. - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; //Create bucketName NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; diff --git a/AWSiOSSDKTests/AWSSESTests.m b/AWSiOSSDKTests/AWSSESTests.m index baccac06ead..6196c289bee 100644 --- a/AWSiOSSDKTests/AWSSESTests.m +++ b/AWSiOSSDKTests/AWSSESTests.m @@ -17,6 +17,7 @@ #import #import "SES.h" +#import "AWSTestUtility.h" @interface AWSSESTests : XCTestCase @@ -26,12 +27,7 @@ @implementation AWSSESTests + (void)setUp { [super setUp]; - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp { diff --git a/AWSiOSSDKTests/AWSSNSTests.m b/AWSiOSSDKTests/AWSSNSTests.m index e9abbceb0e1..dbd6c80f57d 100644 --- a/AWSiOSSDKTests/AWSSNSTests.m +++ b/AWSiOSSDKTests/AWSSNSTests.m @@ -17,6 +17,7 @@ #import #import "SNS.h" +#import "AWSTestUtility.h" @interface AWSSNSTests : XCTestCase @@ -26,13 +27,7 @@ @implementation AWSSNSTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp { @@ -76,6 +71,41 @@ - (void)testGetEndpointAttributesFailed { }] waitUntilFinished]; } +- (void)testCreatePlatformEndpointWithAttributes { + AWSSNS *sns = [AWSSNS defaultSNS]; + XCTAssertNotNil(sns); + + NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"credentials" + ofType:@"json"]; + NSDictionary *credentialsJson = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:filePath] + options:NSJSONReadingMutableContainers + error:nil]; + NSString *platformApplicationArn = credentialsJson[@"snsTestAppArn"]; + + if ([platformApplicationArn length] > 0) { + + AWSSNSCreatePlatformEndpointInput *createEndpointInput = [AWSSNSCreatePlatformEndpointInput new]; + createEndpointInput.platformApplicationArn = platformApplicationArn; + createEndpointInput.token = @"0123456789"; + createEndpointInput.attributes = @{@"Attributes.entry.1.key": @"Enabled",@"Attributes.entry.1.value":@"true"}; + + [[[sns createPlatformEndpoint:createEndpointInput] continueWithBlock:^id(BFTask *task) { + if (task.error) { + XCTFail(@"Error: [%@]", task.error); + } + + if (task.result) { + XCTAssertTrue([task.result isKindOfClass:[AWSSNSCreateEndpointResponse class]]); + AWSSNSCreateEndpointResponse *response = task.result; + XCTAssertNotNil(response.endpointArn, @"response endpointArn should not be nil!"); + } + + return nil; + }] waitUntilFinished]; + } else { + NSLog(@"Warning: can not get snsTestAppArn from credentials.json, you may need to update your credentials file"); + } +} @end #endif diff --git a/AWSiOSSDKTests/AWSSQSTests.m b/AWSiOSSDKTests/AWSSQSTests.m index 6d02027c9ab..f48a8eba3c3 100644 --- a/AWSiOSSDKTests/AWSSQSTests.m +++ b/AWSiOSSDKTests/AWSSQSTests.m @@ -17,6 +17,7 @@ #import #import "SQS.h" +#import "AWSTestUtility.h" @interface AWSSQSTests : XCTestCase @@ -26,13 +27,7 @@ @implementation AWSSQSTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupCognitoCredentialsProvider]; } - (void)setUp diff --git a/AWSiOSSDKTests/AWSSTSTests.m b/AWSiOSSDKTests/AWSSTSTests.m index b22f02b1c0e..72130e34264 100644 --- a/AWSiOSSDKTests/AWSSTSTests.m +++ b/AWSiOSSDKTests/AWSSTSTests.m @@ -17,6 +17,7 @@ #import #import "STS.h" +#import "AWSTestUtility.h" @interface AWSTestCredentialsProvider : NSObject @@ -38,13 +39,7 @@ @implementation AWSSTSTests + (void)setUp { [super setUp]; - - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [AWSTestUtility setupSTS]; } - (void)setUp { @@ -56,7 +51,7 @@ - (void)tearDown { } - (void)testGetSessionToken { - AWSSTS *sts = [AWSSTS defaultSTS]; + AWSSTS *sts = (AWSSTS *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilitySTSKey]; AWSSTSGetSessionTokenRequest *getSessionTokenRequest = [AWSSTSGetSessionTokenRequest new]; getSessionTokenRequest.durationSeconds = @900; @@ -79,10 +74,9 @@ - (void)testGetSessionToken { } + (void)runServiceWithStsCredential { - AWSTestCredentialsProvider *testCredentialProvider = [AWSTestCredentialsProvider new]; - AWSSTS *sts = [AWSSTS defaultSTS]; + AWSSTS *sts = (AWSSTS *)[[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilitySTSKey]; AWSSTSGetSessionTokenRequest *getSessionTokenRequest = [AWSSTSGetSessionTokenRequest new]; getSessionTokenRequest.durationSeconds = @900; diff --git a/AWSiOSSDKTests/AWSSimpleDBTests.m b/AWSiOSSDKTests/AWSSimpleDBTests.m index 9d9235588e4..15c2aeb2ef2 100644 --- a/AWSiOSSDKTests/AWSSimpleDBTests.m +++ b/AWSiOSSDKTests/AWSSimpleDBTests.m @@ -17,6 +17,10 @@ #import #import "SimpleDB.h" +#import "AWSTestUtility.h" + +NSString *const AWSSimpleDBTestDomainNamePrefix = @"ios-v2-test-"; +static NSString *_testDomainName = nil; @interface AWSSimpleDBTests : XCTestCase @@ -26,13 +30,12 @@ @implementation AWSSimpleDBTests + (void)setUp { [super setUp]; + [AWSTestUtility setupCognitoCredentialsProvider]; + + NSTimeInterval timeIntervalSinceReferenceDate = [NSDate timeIntervalSinceReferenceDate]; + _testDomainName = [NSString stringWithFormat:@"%@%lld", AWSSimpleDBTestDomainNamePrefix, (int64_t)timeIntervalSinceReferenceDate]; - if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { - AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; - AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - } + [[self createTestDomain] waitUntilFinished]; } - (void)setUp { @@ -45,6 +48,12 @@ - (void)tearDown { [super tearDown]; } ++ (void)tearDown { + [[self deleteTestDomain] waitUntilFinished]; + + [super tearDown]; +} + - (void)testListDomains { AWSSimpleDB *sdb = [AWSSimpleDB defaultSimpleDB]; @@ -64,18 +73,54 @@ - (void)testListDomains { }] waitUntilFinished]; } --(void)testDomainMetaDataFailed { +- (void)testSelect { + [[AZLogger defaultLogger] setLogLevel:AZLogLevelVerbose]; AWSSimpleDB *sdb = [AWSSimpleDB defaultSimpleDB]; - + + AWSSimpleDBSelectRequest *selectRequest = [AWSSimpleDBSelectRequest new]; + selectRequest.selectExpression = [NSString stringWithFormat:@"select * from `%@`", _testDomainName]; + [[[sdb select:selectRequest] continueWithBlock:^id(BFTask *task) { + if (task.error) { + XCTFail(@"Error: [%@]", task.error); + } + + if (task.result) { + AWSSimpleDBSelectResult *selectResult = task.result; + XCTAssertNotNil(selectResult, @"selectResult should not be nil."); + } + + return nil; + }] waitUntilFinished]; +} + +- (void)testDomainMetaDataFailed { + AWSSimpleDB *sdb = [AWSSimpleDB defaultSimpleDB]; + AWSSimpleDBDomainMetadataRequest *metaDataRequest = [AWSSimpleDBDomainMetadataRequest new]; metaDataRequest.domainName = @""; //domainName is empty - + [[[sdb domainMetadata:metaDataRequest] continueWithBlock:^id(BFTask *task) { XCTAssertNotNil(task.error, @"expected InvalidDomainName error but got nil"); return nil; }]waitUntilFinished]; } ++ (BFTask *)createTestDomain { + AWSSimpleDB *sdb = [AWSSimpleDB defaultSimpleDB]; + + AWSSimpleDBCreateDomainRequest *createDomainRequest = [AWSSimpleDBCreateDomainRequest new]; + createDomainRequest.domainName = _testDomainName; + return [sdb createDomain:createDomainRequest]; +} + ++ (BFTask *)deleteTestDomain { + AWSSimpleDB *sdb = [AWSSimpleDB defaultSimpleDB]; + + AWSSimpleDBDeleteDomainRequest *deleteDomainRequest = [AWSSimpleDBDeleteDomainRequest new]; + deleteDomainRequest.domainName = _testDomainName; + return [sdb deleteDomain:deleteDomainRequest]; +} + @end #endif diff --git a/AWSiOSSDKTests/AWSTestUtility.h b/AWSiOSSDKTests/AWSTestUtility.h new file mode 100644 index 00000000000..d7c2ddab4d2 --- /dev/null +++ b/AWSiOSSDKTests/AWSTestUtility.h @@ -0,0 +1,27 @@ +/* + * Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +#import + +FOUNDATION_EXPORT NSString *const AWSTestUtilitySTSKey; +FOUNDATION_EXPORT NSString *const AWSTestUtilityCognitoIdentityServiceKey; + +@interface AWSTestUtility : NSObject + ++ (void)setupCognitoCredentialsProvider; ++ (void)setupSTS; ++ (void)setupCognitoIdentityService; + +@end \ No newline at end of file diff --git a/AWSiOSSDKTests/AWSTestUtility.m b/AWSiOSSDKTests/AWSTestUtility.m new file mode 100644 index 00000000000..33d2335f31e --- /dev/null +++ b/AWSiOSSDKTests/AWSTestUtility.m @@ -0,0 +1,64 @@ +/* + * Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * A copy of the License is located at + * + * http://aws.amazon.com/apache2.0 + * + * or in the "license" file accompanying this file. This file is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing + * permissions and limitations under the License. + */ + +#import "AWSTestUtility.h" +#import "AWSCore.h" + +NSString *const AWSTestUtilitySTSKey = @"test-sts"; +NSString *const AWSTestUtilityCognitoIdentityServiceKey = @"test-cib"; + +@implementation AWSTestUtility + ++ (void)setupCognitoCredentialsProvider { + if (![AWSServiceManager defaultServiceManager].defaultServiceConfiguration) { + NSString *filePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"credentials" + ofType:@"json"]; + NSDictionary *credentialsJson = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:filePath] + options:NSJSONReadingMutableContainers + error:nil]; + AWSCognitoCredentialsProvider *credentialsProvider = [AWSCognitoCredentialsProvider credentialsWithRegionType:AWSRegionUSEast1 + identityId:nil + accountId:credentialsJson[@"accountId"] + identityPoolId:credentialsJson[@"identityPoolId"] + unauthRoleArn:credentialsJson[@"unauthRoleArn"] + authRoleArn:credentialsJson[@"authRoleArn"] + logins:nil]; + AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 + credentialsProvider:credentialsProvider]; + [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; + } +} + ++ (void)setupSTS { + if (![[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilitySTSKey]) { + AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; + AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 + credentialsProvider:credentialsProvider]; + AWSSTS *sts = [[AWSSTS alloc] initWithConfiguration:configuration]; + [[AWSServiceManager defaultServiceManager] setService:sts forKey:AWSTestUtilitySTSKey]; + } +} + ++ (void)setupCognitoIdentityService { + if (![[AWSServiceManager defaultServiceManager] serviceForKey:AWSTestUtilityCognitoIdentityServiceKey]) { + AWSStaticCredentialsProvider *credentialsProvider = [AWSStaticCredentialsProvider credentialsWithCredentialsFilename:@"credentials"]; + AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 + credentialsProvider:credentialsProvider]; + AWSCognitoIdentityService *cis = [[AWSCognitoIdentityService alloc] initWithConfiguration:configuration]; + [[AWSServiceManager defaultServiceManager] setService:cis forKey:AWSTestUtilityCognitoIdentityServiceKey]; + } +} + +@end diff --git a/AWSiOSSDKTests/AmazonCoreTests.m b/AWSiOSSDKTests/AmazonCoreTests.m index 7fa0bb3c2c3..8d6a99a060f 100644 --- a/AWSiOSSDKTests/AmazonCoreTests.m +++ b/AWSiOSSDKTests/AmazonCoreTests.m @@ -55,13 +55,13 @@ - (void)testStringToDate { double testTime = [testDate timeIntervalSince1970]; double expectedTime = 660096000; - XCTAssertEqual(testTime, expectedTime, "Failed to create a proper date from string usingAZDateDateStampFormat"); + XCTAssertEqualWithAccuracy(testTime, expectedTime, 10, "Failed to create a proper date from string usingAZDateDateStampFormat"); NSString *testStringAZDateAmzDateFormat = @"19901202T000000Z"; NSDate *testDateAmz = [NSDate az_dateFromString:testStringAZDateAmzDateFormat format:AZDateISO8601DateFormat2]; double testTimeAmz = [testDateAmz timeIntervalSince1970]; - XCTAssertEqual(testTimeAmz, expectedTime, "Failed to create a proper date from string usingAZDateAmzDateFormat"); + XCTAssertEqualWithAccuracy(testTimeAmz, expectedTime, 10, "Failed to create a proper date from string usingAZDateAmzDateFormat"); } @end diff --git a/AWSiOSSDKv2.podspec b/AWSiOSSDKv2.podspec index af0823cf518..5667a802d6e 100644 --- a/AWSiOSSDKv2.podspec +++ b/AWSiOSSDKv2.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'AWSiOSSDKv2' - s.version = '2.0.3' + s.version = '2.0.4' s.summary = 'Amazon Web Services SDK for iOS.' s.description = 'The AWS SDK for iOS provides a library, code samples, and documentation for developers to build connected mobile applications using AWS.' @@ -21,6 +21,7 @@ Pod::Spec.new do |s| s.dependency 'CSURITemplate', '~> 0.3.0' s.dependency 'XMLDictionary', '~> 1.4.0' s.dependency 'UICKeyChainStore', '~> 1.0.5' + s.dependency 'Reachability', '~> 3.1.1' s.requires_arc = true diff --git a/AWSiOSSDKv2.xcodeproj/project.pbxproj b/AWSiOSSDKv2.xcodeproj/project.pbxproj index 921b9f572bd..2ac3c3dedc2 100644 --- a/AWSiOSSDKv2.xcodeproj/project.pbxproj +++ b/AWSiOSSDKv2.xcodeproj/project.pbxproj @@ -102,6 +102,7 @@ CE0EFAE8193D2939002A896B /* AWSSTSModel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0986101922A7470006EA67 /* AWSSTSModel.m */; }; CE0EFAEF193D29B9002A896B /* AWSCognitoIdentityService.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0EFAEB193D29B9002A896B /* AWSCognitoIdentityService.m */; }; CE0EFAF0193D29B9002A896B /* AWSCognitoIdentityServiceModel.m in Sources */ = {isa = PBXBuildFile; fileRef = CE0EFAED193D29B9002A896B /* AWSCognitoIdentityServiceModel.m */; }; + CE160B2119774315001ABF94 /* AWSTestUtility.m in Sources */ = {isa = PBXBuildFile; fileRef = CE160B2019774315001ABF94 /* AWSTestUtility.m */; }; CE1C9DE51936CE38007B6F33 /* AWSClockSkewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CE1C9DE41936CE38007B6F33 /* AWSClockSkewTests.m */; }; CE287DD418EB6CDC00603067 /* AZLogging.m in Sources */ = {isa = PBXBuildFile; fileRef = CE287DD118EB5F4300603067 /* AZLogging.m */; }; CE2C174718D0D8CF003FE9AA /* AWSSTSTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2C174618D0D8CF003FE9AA /* AWSSTSTests.m */; }; @@ -219,7 +220,6 @@ EA2AF83F195E206B007DDDD4 /* AWSMobileAnalyticsSession.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2AF803195E206B007DDDD4 /* AWSMobileAnalyticsSession.m */; }; EA2AF840195E206B007DDDD4 /* AWSMobileAnalyticsSessionStore.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2AF804195E206B007DDDD4 /* AWSMobileAnalyticsSessionStore.m */; }; EA2AF841195E206B007DDDD4 /* AIDataGZIP.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2AF808195E206B007DDDD4 /* AIDataGZIP.m */; }; - EA2AF842195E206B007DDDD4 /* AIReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2AF80B195E206B007DDDD4 /* AIReachability.m */; }; EFEAC89619295448005FEDE4 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = EFEAC89419295311005FEDE4 /* libsqlite3.dylib */; }; EFEAC897192954B2005FEDE4 /* libAWSiOSSDKv2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE5D83D61857AA3100907C25 /* libAWSiOSSDKv2.a */; }; /* End PBXBuildFile section */ @@ -389,6 +389,8 @@ CE0EFAEC193D29B9002A896B /* AWSCognitoIdentityServiceModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWSCognitoIdentityServiceModel.h; sourceTree = ""; }; CE0EFAED193D29B9002A896B /* AWSCognitoIdentityServiceModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSCognitoIdentityServiceModel.m; sourceTree = ""; }; CE0EFAEE193D29B9002A896B /* CognitoIdentityService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CognitoIdentityService.h; sourceTree = ""; }; + CE160B2019774315001ABF94 /* AWSTestUtility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSTestUtility.m; sourceTree = ""; }; + CE160B2219774365001ABF94 /* AWSTestUtility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AWSTestUtility.h; sourceTree = ""; }; CE1C9DE41936CE38007B6F33 /* AWSClockSkewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AWSClockSkewTests.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; CE287DD118EB5F4300603067 /* AZLogging.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AZLogging.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; CE287DD218EB5F4300603067 /* AZLogging.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AZLogging.h; sourceTree = ""; }; @@ -556,7 +558,7 @@ EA2AF785195E206B007DDDD4 /* AWSMobileAnalyticsWriter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSMobileAnalyticsWriter.m; sourceTree = ""; }; EA2AF787195E206B007DDDD4 /* AWSMobileAnalyticsDefaultFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AWSMobileAnalyticsDefaultFileManager.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; EA2AF788195E206B007DDDD4 /* AWSMobileAnalyticsFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSMobileAnalyticsFile.m; sourceTree = ""; }; - EA2AF789195E206B007DDDD4 /* AWSMobileAnalyticsIOSConnectivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSMobileAnalyticsIOSConnectivity.m; sourceTree = ""; }; + EA2AF789195E206B007DDDD4 /* AWSMobileAnalyticsIOSConnectivity.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AWSMobileAnalyticsIOSConnectivity.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; EA2AF78A195E206B007DDDD4 /* AWSMobileAnalyticsIOSLifeCycleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AWSMobileAnalyticsIOSLifeCycleManager.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; EA2AF78B195E206B007DDDD4 /* AWSMobileAnalyticsIOSPreferences.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AWSMobileAnalyticsIOSPreferences.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; EA2AF78C195E206B007DDDD4 /* AWSMobileAnalyticsIOSSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = AWSMobileAnalyticsIOSSystem.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; @@ -665,8 +667,6 @@ EA2AF804195E206B007DDDD4 /* AWSMobileAnalyticsSessionStore.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AWSMobileAnalyticsSessionStore.m; sourceTree = ""; }; EA2AF807195E206B007DDDD4 /* AIDataGZIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIDataGZIP.h; sourceTree = ""; }; EA2AF808195E206B007DDDD4 /* AIDataGZIP.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIDataGZIP.m; sourceTree = ""; }; - EA2AF80A195E206B007DDDD4 /* AIReachability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIReachability.h; sourceTree = ""; }; - EA2AF80B195E206B007DDDD4 /* AIReachability.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIReachability.m; sourceTree = ""; }; EAC25F5E195E4A4500675156 /* AWSServiceEnum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AWSServiceEnum.h; sourceTree = ""; }; EADE666419539C4100313444 /* GenerateAppleDocs.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = GenerateAppleDocs.sh; path = Scripts/GenerateAppleDocs.sh; sourceTree = ""; }; EFEAC89419295311005FEDE4 /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; @@ -1009,6 +1009,7 @@ isa = PBXGroup; children = ( CE314866187B57F50068883B /* AmazonCoreTests.m */, + BDD39A10193E8D4500C712BD /* AWSAnalyticsTests.m */, CE8FEAA718D3B84E00EC90A6 /* AWSAutoScalingTests.m */, CE1C9DE41936CE38007B6F33 /* AWSClockSkewTests.m */, CE8FEAA518D3B62100EC90A6 /* AWSCloudWatchTests.m */, @@ -1018,9 +1019,8 @@ CEBA14CC1921AC2F008C596A /* AWSDynamoDBObjectMapperTests.m */, CE314864187B57F50068883B /* AWSDynamoDBTests.m */, CEB2A4A318D782F80007AAF4 /* AWSEC2Tests.m */, - BD9CC213193CFF0700780456 /* AWSERSTests.m */, - BDD39A10193E8D4500C712BD /* AWSAnalyticsTests.m */, CE8FEAA218D3B18600EC90A6 /* AWSElasticLoadBalancingTests.m */, + BD9CC213193CFF0700780456 /* AWSERSTests.m */, CEE68C181940000500259EFF /* AWSKinesisRecorderTests.m */, CE91D2BE18D3C03B000390D2 /* AWSKinesisTests.m */, BD19ED04188F15EB001F5B98 /* AWSS3Tests.m */, @@ -1030,6 +1030,8 @@ CE0D85D818D385DA00D41F8A /* AWSSNSTests.m */, CE0D85D618D37EC000D41F8A /* AWSSQSTests.m */, CE2C174618D0D8CF003FE9AA /* AWSSTSTests.m */, + CE160B2219774365001ABF94 /* AWSTestUtility.h */, + CE160B2019774315001ABF94 /* AWSTestUtility.m */, CE314857187B577A0068883B /* Supporting Files */, ); path = AWSiOSSDKTests; @@ -1854,7 +1856,6 @@ isa = PBXGroup; children = ( EA2AF806195E206B007DDDD4 /* gzip */, - EA2AF809195E206B007DDDD4 /* reachability */, ); path = ThirdParty; sourceTree = ""; @@ -1868,15 +1869,6 @@ path = gzip; sourceTree = ""; }; - EA2AF809195E206B007DDDD4 /* reachability */ = { - isa = PBXGroup; - children = ( - EA2AF80A195E206B007DDDD4 /* AIReachability.h */, - EA2AF80B195E206B007DDDD4 /* AIReachability.m */, - ); - path = reachability; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXLegacyTarget section */ @@ -2140,6 +2132,7 @@ CE314869187B57F50068883B /* AmazonCoreTests.m in Sources */, BD19ED05188F15EB001F5B98 /* AWSS3Tests.m in Sources */, CE2C174718D0D8CF003FE9AA /* AWSSTSTests.m in Sources */, + CE160B2119774315001ABF94 /* AWSTestUtility.m in Sources */, CE314867187B57F50068883B /* AWSDynamoDBTests.m in Sources */, CE8FEAA818D3B84E00EC90A6 /* AWSAutoScalingTests.m in Sources */, CE1C9DE51936CE38007B6F33 /* AWSClockSkewTests.m in Sources */, @@ -2227,7 +2220,6 @@ BDBA90C018EE43C8004EE131 /* AWSNetworking.m in Sources */, BDD77705193FBF6000F04070 /* (null) in Sources */, EA2AF835195E206B007DDDD4 /* AWSMobileAnalyticsDefaultEvent.m in Sources */, - EA2AF842195E206B007DDDD4 /* AIReachability.m in Sources */, EA2AF813195E206B007DDDD4 /* AWSMobileAnalyticsJSONSerializer.m in Sources */, BDBA90C218EE43FF004EE131 /* AWSSignature.m in Sources */, EA2AF83E195E206B007DDDD4 /* AWSMobileAnalyticsPausedSessionState.m in Sources */, diff --git a/AmazonCore/Utility/AZCategory.m b/AmazonCore/Utility/AZCategory.m index 63b74e7aa84..99d096cfbf5 100644 --- a/AmazonCore/Utility/AZCategory.m +++ b/AmazonCore/Utility/AZCategory.m @@ -268,13 +268,26 @@ - (BOOL)az_isBase64Data { } - (NSString *)az_stringWithURLEncoding { - NSString *encoded = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)@"!*'\();:@&=+$,/?%#[] ", kCFStringEncodingUTF8)); - return encoded; + return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, + (__bridge CFStringRef)[self az_decodeURLEncoding], + NULL, + (CFStringRef)@"!*'\();:@&=+$,/?%#[] ", + kCFStringEncodingUTF8)); } - (NSString *)az_stringWithURLEncodingExceptSlash { - NSString *encoded = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, NULL, (CFStringRef)@"!*'\();:@&=+$,?%#[] ", kCFStringEncodingUTF8)); - return encoded; + return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, + (__bridge CFStringRef)[self az_decodeURLEncoding], + NULL, + (CFStringRef)@"!*'\();:@&=+$,?%#[] ", + kCFStringEncodingUTF8)); +} + +- (NSString *)az_decodeURLEncoding { + return (__bridge NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(NULL, + (__bridge CFStringRef)self, + CFSTR(""), + kCFStringEncodingUTF8); } @end diff --git a/AutoScaling/AWSAutoScaling.m b/AutoScaling/AWSAutoScaling.m index 85f08e93384..6e13dbe1d15 100644 --- a/AutoScaling/AWSAutoScaling.m +++ b/AutoScaling/AWSAutoScaling.m @@ -123,7 +123,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSAutoScalingErrorDomain]) { + && [error.domain isEqualToString:AWSAutoScalingErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSAutoScalingErrorIncompleteSignature: case AWSAutoScalingErrorInvalidClientTokenId: diff --git a/CloudWatch/AWSCloudWatch.m b/CloudWatch/AWSCloudWatch.m index 3ff467492c7..95d18422dde 100644 --- a/CloudWatch/AWSCloudWatch.m +++ b/CloudWatch/AWSCloudWatch.m @@ -126,7 +126,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSCloudWatchErrorDomain]) { + && [error.domain isEqualToString:AWSCloudWatchErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSCloudWatchErrorIncompleteSignature: case AWSCloudWatchErrorInvalidClientTokenId: diff --git a/DynamoDB/AWSDynamoDB.m b/DynamoDB/AWSDynamoDB.m index e63da179fd2..9772729cd69 100644 --- a/DynamoDB/AWSDynamoDB.m +++ b/DynamoDB/AWSDynamoDB.m @@ -117,7 +117,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSDynamoDBErrorDomain]) { + && [error.domain isEqualToString:AWSDynamoDBErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSDynamoDBErrorProvisionedThroughputExceeded: retryType = AZNetworkingRetryTypeShouldRetry; diff --git a/EC2/AWSEC2.m b/EC2/AWSEC2.m index 990b00bcebf..fb442d7c86a 100644 --- a/EC2/AWSEC2.m +++ b/EC2/AWSEC2.m @@ -115,10 +115,10 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSEC2ErrorDomain]) { + && [error.domain isEqualToString:AWSEC2ErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSEC2ErrorAuthFailure: - case AWSEC2ErrorSignatureDoesNotMatch: retryType = AZNetworkingRetryTypeShouldRefreshCredentialsAndRetry; break; diff --git a/ElasticLoadBalancing/AWSElasticLoadBalancing.m b/ElasticLoadBalancing/AWSElasticLoadBalancing.m index 4f5c67e5fbb..572317031b5 100644 --- a/ElasticLoadBalancing/AWSElasticLoadBalancing.m +++ b/ElasticLoadBalancing/AWSElasticLoadBalancing.m @@ -132,7 +132,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSElasticLoadBalancingErrorDomain]) { + && [error.domain isEqualToString:AWSElasticLoadBalancingErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSElasticLoadBalancingErrorIncompleteSignature: case AWSElasticLoadBalancingErrorInvalidClientTokenId: diff --git a/Kinesis/AWSKinesis.m b/Kinesis/AWSKinesis.m index 9cbe8dfc4a7..ecf9f19e2cd 100644 --- a/Kinesis/AWSKinesis.m +++ b/Kinesis/AWSKinesis.m @@ -114,7 +114,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSKinesisErrorDomain]) { + && [error.domain isEqualToString:AWSKinesisErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSKinesisErrorIncompleteSignature: case AWSKinesisErrorInvalidClientTokenId: diff --git a/LICENSE b/LICENSE index 6fc984139c3..6864cc40ab8 100644 --- a/LICENSE +++ b/LICENSE @@ -266,52 +266,6 @@ POSSIBILITY OF SUCH DAMAGE. ==================== -File: Reachability.m Copyright (C) 2010 Apple Inc. All Rights Reserved. - -Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs. - -Version: 2.2 - -Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc. -("Apple") in consideration of your agreement to the following terms, and your -use, installation, modification or redistribution of this Apple software -constitutes acceptance of these terms. If you do not agree with these terms, -please do not use, install, modify or redistribute this Apple software. - -In consideration of your agreement to abide by the following terms, and subject -to these terms, Apple grants you a personal, non-exclusive license, under -Apple's copyrights in this original Apple software (the "Apple Software"), to -use, reproduce, modify and redistribute the Apple Software, with or without -modifications, in source and/or binary forms; provided that if you redistribute -the Apple Software in its entirety and without modifications, you must retain -this notice and the following text and disclaimers in all such redistributions -of the Apple Software. -Neither the name, trademarks, service marks or logos of Apple Inc. may be used -to endorse or promote products derived from the Apple Software without specific -prior written permission from Apple. Except as expressly stated in this notice, -no other rights or licenses, express or implied, are granted by Apple herein, -including but not limited to any patent rights that may be infringed by your -derivative works or by other works in which the Apple Software may be -incorporated. - -The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO -WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED -WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN -COMBINATION WITH YOUR PRODUCTS. - -IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR -DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF -CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF -APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -Copyright (C) 2010 Apple Inc. All Rights Reserved. - -==================== - OCMock - Copyright (c) 2004-2008 by Mulle Kybernetik. All rights reserved. Permission to use, copy, modify and distribute this software and its documentation diff --git a/NOTICE b/NOTICE index af3b5d65371..135535c6bcf 100644 --- a/NOTICE +++ b/NOTICE @@ -33,7 +33,6 @@ This software includes third party software subject to the following copyrights: - OCMock - Copyright (c) 2004-2008 by Mulle Kybernetik - https://github.com/erikdoe/ocmock/blob/f34e053c8901e8d36d59a582c35e78dcd50d743a/Source/License.txt - OCHamcrest - Copyright 2014 hamcrest.org - BSD License - - NSData+GZIP.m - Copyright (C) 2012 Charcoal Design - zlib License -- Reachability - Copyright (c) 2011, Tony Million. All rights reserved. - https://github.com/tonymillion/Reachability/blob/master/LICENCE.txt -- Reachability.m - Copyright (C) 2010 Apple Inc. All Rights Reserved. - https://developer.apple.com/library/ios/samplecode/Reachability/Reachability.zip (Embedded in the source code) +- Reachability - Copyright (c) 2011-2013, Tony Million. All rights reserved. - https://github.com/tonymillion/Reachability/blob/master/LICENCE.txt The licenses for these third party components are included in the License file. diff --git a/Podfile b/Podfile index 1996d0bc5f0..b1f016dbf24 100644 --- a/Podfile +++ b/Podfile @@ -4,3 +4,4 @@ pod 'TMCache', '~> 1.2.0' pod 'CSURITemplate', '~> 0.3.0' pod 'XMLDictionary', '~> 1.4.0' pod 'UICKeyChainStore', '~> 1.0.5' +pod 'Reachability', '~> 3.1.1' \ No newline at end of file diff --git a/S3/AWSS3.m b/S3/AWSS3.m index 26435c46a15..bfaa5565265 100644 --- a/S3/AWSS3.m +++ b/S3/AWSS3.m @@ -128,13 +128,12 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSS3ErrorDomain]) { + && [error.domain isEqualToString:AWSS3ErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { - case AWSS3ErrorAccessDenied: case AWSS3ErrorExpiredToken: case AWSS3ErrorInvalidAccessKeyId: case AWSS3ErrorInvalidToken: - case AWSS3ErrorSignatureDoesNotMatch: case AWSS3ErrorTokenRefreshRequired: retryType = AZNetworkingRetryTypeShouldRefreshCredentialsAndRetry; break; diff --git a/SES/AWSSES.m b/SES/AWSSES.m index 80d6014fa2a..23689e3a6d1 100644 --- a/SES/AWSSES.m +++ b/SES/AWSSES.m @@ -117,7 +117,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSSESErrorDomain]) { + && [error.domain isEqualToString:AWSSESErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSSESErrorIncompleteSignature: case AWSSESErrorInvalidClientTokenId: diff --git a/SNS/AWSSNS.m b/SNS/AWSSNS.m index ac70e7fffe7..959defcfb7f 100644 --- a/SNS/AWSSNS.m +++ b/SNS/AWSSNS.m @@ -125,7 +125,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSSNSErrorDomain]) { + && [error.domain isEqualToString:AWSSNSErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSSNSErrorIncompleteSignature: case AWSSNSErrorInvalidClientTokenId: diff --git a/SQS/AWSSQS.m b/SQS/AWSSQS.m index 1cd9ee304b2..9229659a182 100644 --- a/SQS/AWSSQS.m +++ b/SQS/AWSSQS.m @@ -132,7 +132,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSSQSErrorDomain]) { + && [error.domain isEqualToString:AWSSQSErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSSQSErrorIncompleteSignature: case AWSSQSErrorInvalidClientTokenId: diff --git a/Scripts/BoltsPackage.sh b/Scripts/BoltsPackage.sh deleted file mode 100755 index 830cfda6caa..00000000000 --- a/Scripts/BoltsPackage.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh - -cd "$SOURCE_ROOT" - -FRAMEWORK_VERSION=A - - -# framework name -BOLTS="Bolts" - - -# framework build path -BOLTS_BUILD_PATH="Build/Bolts" - - -# full name of framework -BOLTS_FRAMEWORK_DIR=$BOLTS_BUILD_PATH/$BOLTS.framework - - -# bolts -rm -rf $BOLTS_FRAMEWORK_DIR - -echo "Framework: Setting up directories for bolts..." -mkdir -p $BOLTS_FRAMEWORK_DIR -mkdir -p $BOLTS_FRAMEWORK_DIR/Versions -mkdir -p $BOLTS_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION -mkdir -p $BOLTS_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources -mkdir -p $BOLTS_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers - -echo "Framework: Creating symlinks..." -ln -s $FRAMEWORK_VERSION $BOLTS_FRAMEWORK_DIR/Versions/Current -ln -s Versions/Current/Headers $BOLTS_FRAMEWORK_DIR/Headers -ln -s Versions/Current/Resources $BOLTS_FRAMEWORK_DIR/Resources -ln -s Versions/Current/$BOLTS $BOLTS_FRAMEWORK_DIR/$BOLTS - - - -echo "Framework: Creating library bolts " -lipo -create "Pods/build/Debug-iphonesimulator/libPods-${BOLTS}.a" "Pods/build/Debug64-iphonesimulator/libPods-${BOLTS}.a" "Pods/build/Release-iphoneos/libPods-${BOLTS}.a" "Pods/build/Release64-iphoneos/libPods-${BOLTS}.a" -o "$BOLTS_FRAMEWORK_DIR/Versions/Current/$BOLTS" - - -# copy header file -cp -a Pods/Bolts/Bolts/*.h $BOLTS_FRAMEWORK_DIR/Headers/ - - - - diff --git a/Scripts/CSURITemplatePackage.sh b/Scripts/CSURITemplatePackage.sh deleted file mode 100755 index b0d08a4ffcd..00000000000 --- a/Scripts/CSURITemplatePackage.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -cd "$SOURCE_ROOT" - -FRAMEWORK_VERSION=A - - -CSURI_TEMPLATE="CSURITemplate" - -# framework build path -CSURI_TEMPLATE_BUILD_PATH="Build/CSURITemplate" - -# full name of framework -CSURI_TEMPLATE_FRAMEWORK_DIR=$CSURI_TEMPLATE_BUILD_PATH/$CSURI_TEMPLATE.framework - - -#CSURITemplate -rm -rf $CSURI_TEMPLATE_FRAMEWORK_DIR - -echo "Framework: Setting up directories for CSURITemplate..." -mkdir -p $CSURI_TEMPLATE_FRAMEWORK_DIR -mkdir -p $CSURI_TEMPLATE_FRAMEWORK_DIR/Versions -mkdir -p $CSURI_TEMPLATE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION -mkdir -p $CSURI_TEMPLATE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources -mkdir -p $CSURI_TEMPLATE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers - -echo "Framework: Creating symlinks..." -ln -s $FRAMEWORK_VERSION $CSURI_TEMPLATE_FRAMEWORK_DIR/Versions/Current -ln -s Versions/Current/Headers $CSURI_TEMPLATE_FRAMEWORK_DIR/Headers -ln -s Versions/Current/Resources $CSURI_TEMPLATE_FRAMEWORK_DIR/Resources -ln -s Versions/Current/$CSURI_TEMPLATE $CSURI_TEMPLATE_FRAMEWORK_DIR/$CSURI_TEMPLATE - - -echo "Framework: Creating library CSURITemplate " -lipo -create "Pods/build/Debug-iphonesimulator/libPods-${CSURI_TEMPLATE}.a" "Pods/build/Debug64-iphonesimulator/libPods-${CSURI_TEMPLATE}.a" "Pods/build/Release-iphoneos/libPods-${CSURI_TEMPLATE}.a" "Pods/build/Release64-iphoneos/libPods-${CSURI_TEMPLATE}.a" -o "$CSURI_TEMPLATE_FRAMEWORK_DIR/Versions/Current/$CSURI_TEMPLATE" - -# copy header file -cp -a Pods/CSURITemplate/CSURITemplate/*.h $CSURI_TEMPLATE_FRAMEWORK_DIR/Headers \ No newline at end of file diff --git a/Scripts/GenerateAppleDocs.sh b/Scripts/GenerateAppleDocs.sh index b22d92863db..45cabc8efec 100755 --- a/Scripts/GenerateAppleDocs.sh +++ b/Scripts/GenerateAppleDocs.sh @@ -9,7 +9,7 @@ function cleanup } -VERSION="2.0.3" +VERSION="2.0.4" if [ -n $1 ] && [ "$1" == "clean" ]; then cleanup diff --git a/Scripts/MantlePackage.sh b/Scripts/MantlePackage.sh deleted file mode 100755 index 8aca41c1247..00000000000 --- a/Scripts/MantlePackage.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -cd "$SOURCE_ROOT" - -FRAMEWORK_VERSION=A - -MANTLE="Mantle" - -# framework build path -MANTLE_BUILD_PATH="Build/Mantle" - -# full name of framework -MANTLE_FRAMEWORK_DIR=$MANTLE_BUILD_PATH/$MANTLE.framework - - -# Mantle -rm -rf $MANTLE_FRAMEWORK_DIR - -echo "Framework: Setting up directories for Mantle..." -mkdir -p $MANTLE_FRAMEWORK_DIR -mkdir -p $MANTLE_FRAMEWORK_DIR/Versions -mkdir -p $MANTLE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION -mkdir -p $MANTLE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources -mkdir -p $MANTLE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers - -echo "Framework: Creating symlinks..." -ln -s $FRAMEWORK_VERSION $MANTLE_FRAMEWORK_DIR/Versions/Current -ln -s Versions/Current/Headers $MANTLE_FRAMEWORK_DIR/Headers -ln -s Versions/Current/Resources $MANTLE_FRAMEWORK_DIR/Resources -ln -s Versions/Current/$MANTLE $MANTLE_FRAMEWORK_DIR/$MANTLE - - -echo "Framework: Creating library Mantle " -lipo -create "Pods/build/Debug-iphonesimulator/libPods-${MANTLE}.a" "Pods/build/Debug64-iphonesimulator/libPods-${MANTLE}.a" "Pods/build/Release-iphoneos/libPods-${MANTLE}.a" "Pods/build/Release64-iphoneos/libPods-${MANTLE}.a" -o "$MANTLE_FRAMEWORK_DIR/Versions/Current/$MANTLE" - - -# copy header file -cp -a Pods/Mantle/Mantle/*.h $MANTLE_FRAMEWORK_DIR/Headers \ No newline at end of file diff --git a/Scripts/Package.sh b/Scripts/Package.sh index 561b2a739a6..edb6ec3a36f 100755 --- a/Scripts/Package.sh +++ b/Scripts/Package.sh @@ -12,26 +12,12 @@ if [ -x "Scripts/SdkPackage.sh" ]; then Scripts/SdkPackage.sh fi -if [ -x "Scripts/BoltsPackage.sh" ]; then - Scripts/BoltsPackage.sh -fi - -if [ -x "Scripts/CSURITemplatePackage.sh" ]; then - Scripts/CSURITemplatePackage.sh -fi - -if [ -x "Scripts/MantlePackage.sh" ]; then - Scripts/MantlePackage.sh -fi - -if [ -x "Scripts/TMCachePackage.sh" ]; then - Scripts/TMCachePackage.sh -fi - -if [ -x "Scripts/XMLDictionaryPackage.sh" ]; then - Scripts/XMLDictionaryPackage.sh -fi - -if [ -x "Scripts/UICKeyChainStore.sh" ]; then - Scripts/UICKeyChainStore.sh -fi +if [ -x "Scripts/PodFramework.sh" ]; then + Scripts/PodFramework.sh Bolts + Scripts/PodFramework.sh CSURITemplate + Scripts/PodFramework.sh Mantle + Scripts/PodFramework.sh TMCache + Scripts/PodFramework.sh XMLDictionary + Scripts/PodFramework.sh UICKeyChainStore + Scripts/PodFramework.sh Reachability +fi \ No newline at end of file diff --git a/Scripts/PodFramework.sh b/Scripts/PodFramework.sh new file mode 100755 index 00000000000..ed13f327b6e --- /dev/null +++ b/Scripts/PodFramework.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +cd "$SOURCE_ROOT" + + +# version +FRAMEWORK_VERSION=A + +# framework name +NAME="$1" + +# framework build path +BUILD_PATH="Build/$NAME" + +# full name of framework +FRAMEWORK_DIR=$BUILD_PATH/$NAME.framework + +echo "generate framework for: " +echo $NAME +echo "framework path is: " +echo $FRAMEWORK_DIR + + +# clean +rm -rf $FRAMEWORK_DIR + +echo "Framework: Setting up directories ..." +mkdir -p $FRAMEWORK_DIR +mkdir -p $FRAMEWORK_DIR/Versions +mkdir -p $FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION +mkdir -p $FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources +mkdir -p $FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers + +echo "Framework: Creating symlinks..." +ln -s $FRAMEWORK_VERSION $FRAMEWORK_DIR/Versions/Current +ln -s Versions/Current/Headers $FRAMEWORK_DIR/Headers +ln -s Versions/Current/Resources $FRAMEWORK_DIR/Resources +ln -s Versions/Current/$NAME $FRAMEWORK_DIR/$NAME + + + +echo "Framework: Creating library bolts " +lipo -create "Pods/build/Debug-iphonesimulator/libPods-${NAME}.a" "Pods/build/Debug64-iphonesimulator/libPods-${NAME}.a" "Pods/build/Release-iphoneos/libPods-${NAME}.a" "Pods/build/Release64-iphoneos/libPods-${NAME}.a" -o "$FRAMEWORK_DIR/Versions/Current/$NAME" + + +# copy header file +if [ "$1" = "UICKeyChainStore" ] +then + cp -a Pods/${NAME}/Lib/*.h $FRAMEWORK_DIR/Headers/ +elif [ "$1" = "Reachability" ] +then + cp -a Pods/${NAME}/*.h $FRAMEWORK_DIR/Headers/ +else + cp -a Pods/${NAME}/${NAME}/*.h $FRAMEWORK_DIR/Headers/ +fi + diff --git a/Scripts/SdkHeader.sh b/Scripts/SdkHeader.sh new file mode 100755 index 00000000000..c24e8c74624 --- /dev/null +++ b/Scripts/SdkHeader.sh @@ -0,0 +1,6 @@ +echo "correct the way to import framework headers" +find . -name '*.h' | xargs perl -pi -e 's/"Mantle.h"//g' +find . -name '*.h' | xargs perl -pi -e 's/"Bolts.h"//g' +find . -name '*.h' | xargs perl -pi -e 's/"TMCache.h"//g' +find . -name '*.h' | xargs perl -pi -e 's/#import "/#import /g' \ No newline at end of file diff --git a/Scripts/SdkPackage.sh b/Scripts/SdkPackage.sh index 7dacfdc209d..b2e552513a0 100755 --- a/Scripts/SdkPackage.sh +++ b/Scripts/SdkPackage.sh @@ -110,3 +110,9 @@ cp -a SES/*.h $FRAMEWORK_DIR/Headers/ cp -a SimpleDB/*.h $FRAMEWORK_DIR/Headers/ cp -a SNS/*.h $FRAMEWORK_DIR/Headers/ cp -a SQS/*.h $FRAMEWORK_DIR/Headers/ + + +# correct the way to import framework's header +cd $FRAMEWORK_DIR/Headers +"$SOURCE_ROOT"/Scripts/SdkHeader.sh + diff --git a/Scripts/TMCachePackage.sh b/Scripts/TMCachePackage.sh deleted file mode 100755 index fb3d51e764d..00000000000 --- a/Scripts/TMCachePackage.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -cd "$SOURCE_ROOT" - -FRAMEWORK_VERSION=A - -TMCACHE="TMCache" - -# framework build path -TMCACHE_BUILD_PATH="Build/TMCache" - - -# full name of framework -TMCACHE_FRAMEWORK_DIR=$TMCACHE_BUILD_PATH/$TMCACHE.framework - - -# TMCache -rm -rf $TMCACHE_FRAMEWORK_DIR - -echo "Framework: Setting up directories for TMCache..." -mkdir -p $TMCACHE_FRAMEWORK_DIR -mkdir -p $TMCACHE_FRAMEWORK_DIR/Versions -mkdir -p $TMCACHE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION -mkdir -p $TMCACHE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources -mkdir -p $TMCACHE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers - -echo "Framework: Creating symlinks..." -ln -s $FRAMEWORK_VERSION $TMCACHE_FRAMEWORK_DIR/Versions/Current -ln -s Versions/Current/Headers $TMCACHE_FRAMEWORK_DIR/Headers -ln -s Versions/Current/Resources $TMCACHE_FRAMEWORK_DIR/Resources -ln -s Versions/Current/$TMCACHE $TMCACHE_FRAMEWORK_DIR/$TMCACHE - -echo "Framework: Creating library TMCache" -lipo -create "Pods/build/Debug-iphonesimulator/libPods-${TMCACHE}.a" "Pods/build/Debug64-iphonesimulator/libPods-${TMCACHE}.a" "Pods/build/Release-iphoneos/libPods-${TMCACHE}.a" "Pods/build/Release64-iphoneos/libPods-${TMCACHE}.a" -o "$TMCACHE_FRAMEWORK_DIR/Versions/Current/$TMCACHE" - -# copy header file -cp -a Pods/TMCache/TMCache/*.h $TMCACHE_FRAMEWORK_DIR/Headers - - - - - diff --git a/Scripts/UICKeyChainStore.sh b/Scripts/UICKeyChainStore.sh deleted file mode 100755 index 8749c77da0c..00000000000 --- a/Scripts/UICKeyChainStore.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - -cd "$SOURCE_ROOT" - -FRAMEWORK_VERSION=A - - -UICKEYCHAINSTORE_TEMPLATE="UICKeyChainStore" - -# framework build path -UICKEYCHAINSTORE_TEMPLATE_BUILD_PATH="Build/UICKeyChainStore" - -# full name of framework -UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR=$UICKEYCHAINSTORE_TEMPLATE_BUILD_PATH/$UICKEYCHAINSTORE_TEMPLATE.framework - - -#CSURITemplate -rm -rf $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR - -echo "Framework: Setting up directories for UICKeyChainStore..." -mkdir -p $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR -mkdir -p $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Versions -mkdir -p $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION -mkdir -p $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources -mkdir -p $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers - -echo "Framework: Creating symlinks..." -ln -s $FRAMEWORK_VERSION $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Versions/Current -ln -s Versions/Current/Headers $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Headers -ln -s Versions/Current/Resources $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Resources -ln -s Versions/Current/$UICKEYCHAINSTORE_TEMPLATE $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/$UICKEYCHAINSTORE_TEMPLATE - - -echo "Framework: Creating library CSURITemplate " -lipo -create "Pods/build/Debug-iphonesimulator/libPods-${UICKEYCHAINSTORE_TEMPLATE}.a" "Pods/build/Debug64-iphonesimulator/libPods-${UICKEYCHAINSTORE_TEMPLATE}.a" "Pods/build/Release-iphoneos/libPods-${UICKEYCHAINSTORE_TEMPLATE}.a" "Pods/build/Release64-iphoneos/libPods-${UICKEYCHAINSTORE_TEMPLATE}.a" -o "$UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Versions/Current/$UICKEYCHAINSTORE_TEMPLATE" - -# copy header file -cp -a Pods/UICKeyChainStore/Lib/*.h $UICKEYCHAINSTORE_TEMPLATE_FRAMEWORK_DIR/Headers \ No newline at end of file diff --git a/Scripts/XMLDictionaryPackage.sh b/Scripts/XMLDictionaryPackage.sh deleted file mode 100755 index f8a6efaa47a..00000000000 --- a/Scripts/XMLDictionaryPackage.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -cd "$SOURCE_ROOT" - -FRAMEWORK_VERSION=A - -XML_DICTIONARY="XMLDictionary" - -# framework build path -XML_DICTIONARY_BUILD_PATH="Build/XMLDictionary" - -# full name of framework -XML_DICTIONARY_FRAMEWORK_DIR=$XML_DICTIONARY_BUILD_PATH/$XML_DICTIONARY.framework - - -# XMLDictionary -rm -rf $TMCACHE_FRAMEWORK_DIR - -echo "Framework: Setting up directories for XMLDictionary..." -mkdir -p $XML_DICTIONARY_FRAMEWORK_DIR -mkdir -p $XML_DICTIONARY_FRAMEWORK_DIR/Versions -mkdir -p $XML_DICTIONARY_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION -mkdir -p $XML_DICTIONARY_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Resources -mkdir -p $XML_DICTIONARY_FRAMEWORK_DIR/Versions/$FRAMEWORK_VERSION/Headers - -echo "Framework: Creating symlinks..." -ln -s $FRAMEWORK_VERSION $XML_DICTIONARY_FRAMEWORK_DIR/Versions/Current -ln -s Versions/Current/Headers $XML_DICTIONARY_FRAMEWORK_DIR/Headers -ln -s Versions/Current/Resources $XML_DICTIONARY_FRAMEWORK_DIR/Resources -ln -s Versions/Current/$XML_DICTIONARY $XML_DICTIONARY_FRAMEWORK_DIR/$XML_DICTIONARY - - -echo "Framework: Creating library XMLDictionary" -lipo -create "Pods/build/Debug-iphonesimulator/libPods-${XML_DICTIONARY}.a" "Pods/build/Debug64-iphonesimulator/libPods-${XML_DICTIONARY}.a" "Pods/build/Release-iphoneos/libPods-${XML_DICTIONARY}.a" "Pods/build/Release64-iphoneos/libPods-${XML_DICTIONARY}.a" -o "$XML_DICTIONARY_FRAMEWORK_DIR/Versions/Current/$XML_DICTIONARY" - - - -# copy header file -cp -a Pods/XMLDictionary/XMLDictionary/*.h $XML_DICTIONARY_FRAMEWORK_DIR/Headers \ No newline at end of file diff --git a/SimpleDB/AWSSimpleDB.m b/SimpleDB/AWSSimpleDB.m index 4e1dc3021b3..d24ea307a08 100644 --- a/SimpleDB/AWSSimpleDB.m +++ b/SimpleDB/AWSSimpleDB.m @@ -134,7 +134,8 @@ - (AZNetworkingRetryType)shouldRetry:(uint32_t)currentRetryCount data:data error:error]; if(retryType == AZNetworkingRetryTypeShouldNotRetry - && [error.domain isEqualToString:AWSSimpleDBErrorDomain]) { + && [error.domain isEqualToString:AWSSimpleDBErrorDomain] + && currentRetryCount < self.maxRetryCount) { switch (error.code) { case AWSSimpleDBErrorAccessFailure: case AWSSimpleDBErrorAuthFailure: @@ -193,7 +194,6 @@ - (instancetype)initWithConfiguration:(AWSServiceConfiguration *)configuration { endpoint:_endpoint]; _configuration.baseURL = _endpoint.URL; - _configuration.requestSerializer = [AWSJSONRequestSerializer new]; _configuration.requestInterceptors = @[[AWSNetworkingRequestInterceptor new], signer]; _configuration.retryHandler = [[AWSSimpleDBRequestRetryHandler alloc] initWithMaximumRetryCount:_configuration.maxRetryCount]; _configuration.headers = @{@"Host" : _endpoint.hostName};