Ben Copsey

Use NSProcessInfo to get host name instead in tests (fixing iPhone build)

Fix warning about the new NSXMLParserDelegate protocol on Leopard and iPhone
... ... @@ -21,8 +21,13 @@ typedef enum _ASIS3ErrorType {
} ASIS3ErrorType;
// Prevent warning about missing NSXMLParserDelegate on Leopard and iPhone
#if !TARGET_OS_IPHONE && MAC_OS_X_VERSION_10_5 < MAC_OS_X_VERSION_MAX_ALLOWED
@interface ASIS3Request : ASIHTTPRequest <NSXMLParserDelegate> {
#else
@interface ASIS3Request : ASIHTTPRequest {
#endif
// Your S3 access key. Set it on the request, or set it globally using [ASIS3Request setSharedAccessKey:]
NSString *accessKey;
... ...
... ... @@ -605,12 +605,11 @@
GHAssertNil([request error],@"Got an error when credentials were supplied");
// Ok, so I assume that not everyone will have a hostname in the form 'Ben-Copseys-MacBook-Pro.local', but anyway...
NSString *hostName = [NSString stringWithFormat:@"%@.local",[(NSString *)SCDynamicStoreCopyLocalHostName(NULL) autorelease]];
NSString *expectedResponse = [NSString stringWithFormat:@"You are %@ from %@/%@",@"king",[@"Castle.Kingdom" uppercaseString],hostName];
success = [[request responseString] isEqualToString:expectedResponse];
GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[request responseString]);
// 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
NSString *hostName = [[NSProcessInfo processInfo] hostName];
NSString *expectedResponse = [[NSString stringWithFormat:@"You are %@ from %@/%@",@"king",@"Castle.Kingdom",hostName] lowercaseString];
success = [[[request responseString] lowercaseString] isEqualToString:expectedResponse];
GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[[request responseString] lowercaseString]);
}
- (void)testCompressedResponse
... ...
... ... @@ -857,7 +857,8 @@ IMPORTANT
- (void)throttleFail:(ASIHTTPRequest *)request
{
GHAssertTrue(NO,@"Request failed");
GHAssertTrue(NO,@"Request failed, cannot continue with this test");
[[request queue] cancelAllOperations];
}
// 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
{
GHAssertNil([request error],@"Got an error when credentials were supplied");
// Ok, so I assume that not everyone will have a hostname in the form 'Ben-Copseys-MacBook-Pro.local', but anyway...
NSString *hostName = [NSString stringWithFormat:@"%@.local",[(NSString *)SCDynamicStoreCopyLocalHostName(NULL) autorelease]];
NSString *expectedResponse = [NSString stringWithFormat:@"You are %@ from %@/%@",@"king",[@"Castle.Kingdom" uppercaseString],hostName];
BOOL success = [[request responseString] isEqualToString:expectedResponse];
GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[request responseString]);
// 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
NSString *hostName = [[NSProcessInfo processInfo] hostName];
NSString *expectedResponse = [[NSString stringWithFormat:@"You are %@ from %@/%@",@"king",@"Castle.Kingdom",hostName] lowercaseString];
BOOL success = [[[request responseString] lowercaseString] isEqualToString:expectedResponse];
GHAssertTrue(success,@"Failed to send credentials correctly? (Expected: '%@', got '%@')",expectedResponse,[[request responseString] lowercaseString]);
}
... ...