Use NSProcessInfo to get host name instead in tests (fixing iPhone build)
Fix warning about the new NSXMLParserDelegate protocol on Leopard and iPhone
Showing
3 changed files
with
17 additions
and
13 deletions
@@ -21,8 +21,13 @@ typedef enum _ASIS3ErrorType { | @@ -21,8 +21,13 @@ typedef enum _ASIS3ErrorType { | ||
21 | 21 | ||
22 | } ASIS3ErrorType; | 22 | } ASIS3ErrorType; |
23 | 23 | ||
24 | +// Prevent warning about missing NSXMLParserDelegate on Leopard and iPhone | ||
25 | +#if !TARGET_OS_IPHONE && MAC_OS_X_VERSION_10_5 < MAC_OS_X_VERSION_MAX_ALLOWED | ||
24 | @interface ASIS3Request : ASIHTTPRequest <NSXMLParserDelegate> { | 26 | @interface ASIS3Request : ASIHTTPRequest <NSXMLParserDelegate> { |
27 | +#else | ||
28 | +@interface ASIS3Request : ASIHTTPRequest { | ||
25 | 29 | ||
30 | +#endif | ||
26 | // Your S3 access key. Set it on the request, or set it globally using [ASIS3Request setSharedAccessKey:] | 31 | // Your S3 access key. Set it on the request, or set it globally using [ASIS3Request setSharedAccessKey:] |
27 | NSString *accessKey; | 32 | NSString *accessKey; |
28 | 33 |
@@ -605,12 +605,11 @@ | @@ -605,12 +605,11 @@ | ||
605 | 605 | ||
606 | GHAssertNil([request error],@"Got an error when credentials were supplied"); | 606 | GHAssertNil([request error],@"Got an error when credentials were supplied"); |
607 | 607 | ||
608 | - // Ok, so I assume that not everyone will have a hostname in the form 'Ben-Copseys-MacBook-Pro.local', but anyway... | 608 | + // NSProcessInfo returns a lower case string for host name, while CFNetwork will send a mixed case string for host name, so we'll compare by lowercasing everything |
609 | - NSString *hostName = [NSString stringWithFormat:@"%@.local",[(NSString *)SCDynamicStoreCopyLocalHostName(NULL) autorelease]]; | 609 | + NSString *hostName = [[NSProcessInfo processInfo] hostName]; |
610 | - | 610 | + NSString *expectedResponse = [[NSString stringWithFormat:@"You are %@ from %@/%@",@"king",@"Castle.Kingdom",hostName] lowercaseString]; |
611 | - NSString *expectedResponse = [NSString stringWithFormat:@"You are %@ from %@/%@",@"king",[@"Castle.Kingdom" uppercaseString],hostName]; | 611 | + success = [[[request responseString] lowercaseString] isEqualToString:expectedResponse]; |
612 | - success = [[request responseString] isEqualToString:expectedResponse]; | 612 | + GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[[request responseString] lowercaseString]); |
613 | - GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[request responseString]); | ||
614 | } | 613 | } |
615 | 614 | ||
616 | - (void)testCompressedResponse | 615 | - (void)testCompressedResponse |
@@ -857,7 +857,8 @@ IMPORTANT | @@ -857,7 +857,8 @@ IMPORTANT | ||
857 | 857 | ||
858 | - (void)throttleFail:(ASIHTTPRequest *)request | 858 | - (void)throttleFail:(ASIHTTPRequest *)request |
859 | { | 859 | { |
860 | - GHAssertTrue(NO,@"Request failed"); | 860 | + GHAssertTrue(NO,@"Request failed, cannot continue with this test"); |
861 | + [[request queue] cancelAllOperations]; | ||
861 | } | 862 | } |
862 | 863 | ||
863 | // Test for a bug that used to exist where the temporary file used to store the request body would be removed when authentication failed | 864 | // Test for a bug that used to exist where the temporary file used to store the request body would be removed when authentication failed |
@@ -924,12 +925,11 @@ IMPORTANT | @@ -924,12 +925,11 @@ IMPORTANT | ||
924 | { | 925 | { |
925 | GHAssertNil([request error],@"Got an error when credentials were supplied"); | 926 | GHAssertNil([request error],@"Got an error when credentials were supplied"); |
926 | 927 | ||
927 | - // Ok, so I assume that not everyone will have a hostname in the form 'Ben-Copseys-MacBook-Pro.local', but anyway... | 928 | + // NSProcessInfo returns a lower case string for host name, while CFNetwork will send a mixed case string for host name, so we'll compare by lowercasing everything |
928 | - NSString *hostName = [NSString stringWithFormat:@"%@.local",[(NSString *)SCDynamicStoreCopyLocalHostName(NULL) autorelease]]; | 929 | + NSString *hostName = [[NSProcessInfo processInfo] hostName]; |
929 | - | 930 | + NSString *expectedResponse = [[NSString stringWithFormat:@"You are %@ from %@/%@",@"king",@"Castle.Kingdom",hostName] lowercaseString]; |
930 | - NSString *expectedResponse = [NSString stringWithFormat:@"You are %@ from %@/%@",@"king",[@"Castle.Kingdom" uppercaseString],hostName]; | 931 | + BOOL success = [[[request responseString] lowercaseString] isEqualToString:expectedResponse]; |
931 | - BOOL success = [[request responseString] isEqualToString:expectedResponse]; | 932 | + GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[[request responseString] lowercaseString]); |
932 | - GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[request responseString]); | ||
933 | 933 | ||
934 | } | 934 | } |
935 | 935 |
-
Please register or login to post a comment