Ben Copsey

Added a couple more unit tests for cookies, and added comments in cookie tests

... ... @@ -120,6 +120,7 @@ More tests needed for:
{
BOOL success;
//Set setting a cookie
NSURL *url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/set_cookie"] autorelease];
ASIHTTPRequest *request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseCookiePersistance:YES];
... ... @@ -128,9 +129,12 @@ More tests needed for:
success = [html isEqualToString:@"I have set a cookie"];
STAssertTrue(success,@"Failed to set a cookie");
//Test a cookie is stored in responseCookies
NSArray *cookies = [request responseCookies];
STAssertNotNil(cookies,@"Failed to store cookie data in responseCookies");
//Test the cookie contains the correct data
NSHTTPCookie *cookie = nil;
BOOL foundCookie = NO;
for (cookie in cookies) {
... ... @@ -152,6 +156,7 @@ More tests needed for:
return;
}
//Test a cookie is presented when manually added to the request
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseCookiePersistance:NO];
... ... @@ -161,6 +166,7 @@ More tests needed for:
success = [html isEqualToString:@"I have 'This is the value' as the value of 'ASIHTTPRequestTestCookie'"];
STAssertTrue(success,@"Cookie not presented to the server with cookie persistance OFF");
//Test a cookie is presented from the persistent store
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseCookiePersistance:YES];
... ... @@ -169,6 +175,7 @@ More tests needed for:
success = [html isEqualToString:@"I have 'This is the value' as the value of 'ASIHTTPRequestTestCookie'"];
STAssertTrue(success,@"Cookie not presented to the server with cookie persistance ON");
//Test removing a cookie
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/remove_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request start];
... ... @@ -176,6 +183,35 @@ More tests needed for:
success = [html isEqualToString:@"I have removed a cookie"];
STAssertTrue(success,@"Failed to remove a cookie");
//Test making sure cookie was properly removed
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request start];
html = [request dataString];
success = [html isEqualToString:@"No cookie exists"];
STAssertTrue(success,@"Cookie presented to the server when it should have been removed");
//Test setting a custom cookie works
NSDictionary *cookieProperties = [[[NSMutableDictionary alloc] init] autorelease];
[cookieProperties setValue:@"Test Value" forKey:NSHTTPCookieValue];
[cookieProperties setValue:@"ASIHTTPRequestTestCookie" forKey:NSHTTPCookieName];
[cookieProperties setValue:@".allseeing-i.com" forKey:NSHTTPCookieDomain];
[cookieProperties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires];
[cookieProperties setValue:@"/asi-http-request/tests" forKey:NSHTTPCookiePath];
cookie = [[[NSHTTPCookie alloc] initWithProperties:cookieProperties] autorelease];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request setUseCookiePersistance:NO];
[request setRequestCookies:[NSMutableArray arrayWithObject:cookie]];
[request start];
html = [request dataString];
success = [html isEqualToString:@"I have 'Test Value' as the value of 'ASIHTTPRequestTestCookie'"];
STAssertTrue(success,@"Custom cookie not presented to the server with cookie persistance OFF");
//Test removing all cookies works
[ASIHTTPRequest clearSession];
url = [[[NSURL alloc] initWithString:@"http://allseeing-i.com/asi-http-request/tests/read_cookie"] autorelease];
request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];
[request start];
... ...
... ... @@ -279,8 +279,8 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
<integer>11</integer>
<integer>5</integer>
<integer>4</integer>
<integer>2</integer>
<integer>0</integer>
</array>
</array>
... ... @@ -304,7 +304,7 @@
<real>312</real>
</array>
<key>RubberWindowFrame</key>
<string>224 81 1432 976 0 0 1920 1178 </string>
<string>268 202 1432 976 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
... ... @@ -322,7 +322,7 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20306471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>ASIHTTPRequest.m</string>
<string>ASIHTTPRequestTests.m</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
... ... @@ -330,11 +330,11 @@
<key>PBXProjectModuleGUID</key>
<string>1CE0B20406471E060097A5F4</string>
<key>PBXProjectModuleLabel</key>
<string>ASIHTTPRequest.m</string>
<string>ASIHTTPRequestTests.m</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
<string>B5CF37350E7A8D040050CBA7</string>
<string>B5CF37440E7A90E10050CBA7</string>
<key>history</key>
<array>
<string>B5731B8B0E4310180008024F</string>
... ... @@ -352,9 +352,9 @@
<string>B5CF37000E7A8C380050CBA7</string>
<string>B5CF37010E7A8C380050CBA7</string>
<string>B5CF37100E7A8C7F0050CBA7</string>
<string>B5CF37110E7A8C7F0050CBA7</string>
<string>B5CF37120E7A8C7F0050CBA7</string>
<string>B5CF36FB0E7A8C380050CBA7</string>
<string>B5CF37420E7A90E10050CBA7</string>
<string>B5CF37400E7A90320050CBA7</string>
</array>
<key>prevStack</key>
<array>
... ... @@ -456,6 +456,7 @@
<string>B5CF37130E7A8C7F0050CBA7</string>
<string>B5CF37140E7A8C7F0050CBA7</string>
<string>B5CF37150E7A8C7F0050CBA7</string>
<string>B5CF37430E7A90E10050CBA7</string>
</array>
</dict>
<key>SplitCount</key>
... ... @@ -469,7 +470,7 @@
<key>Frame</key>
<string>{{0, 0}, {1098, 836}}</string>
<key>RubberWindowFrame</key>
<string>224 81 1432 976 0 0 1920 1178 </string>
<string>268 202 1432 976 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
... ... @@ -489,7 +490,7 @@
<key>Frame</key>
<string>{{0, 841}, {1098, 94}}</string>
<key>RubberWindowFrame</key>
<string>224 81 1432 976 0 0 1920 1178 </string>
<string>268 202 1432 976 0 0 1920 1178 </string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
... ... @@ -658,7 +659,7 @@
<string>/Users/ben/asi-http-request/asi-http-request.xcodeproj</string>
</array>
<key>WindowString</key>
<string>224 81 1432 976 0 0 1920 1178 </string>
<string>268 202 1432 976 0 0 1920 1178 </string>
<key>WindowToolsV3</key>
<array>
<dict>
... ...
... ... @@ -15,7 +15,7 @@
8D1107260486CEB800E47090 /* asi-http-request */,
);
breakpoints = (
B5CF36D30E7A8A910050CBA7 /* ASIHTTPRequestTests.m:143 */,
B5CF36D30E7A8A910050CBA7 /* ASIHTTPRequestTests.m:147 */,
);
codeSenseManager = B5ABC7B60E24C52A0072F422 /* Code sense */;
executables = (
... ... @@ -380,6 +380,13 @@
B5CF371B0E7A8CC30050CBA7 /* PBXTextBookmark */ = B5CF371B0E7A8CC30050CBA7 /* PBXTextBookmark */;
B5CF372E0E7A8CEC0050CBA7 /* PBXTextBookmark */ = B5CF372E0E7A8CEC0050CBA7 /* PBXTextBookmark */;
B5CF37350E7A8D040050CBA7 /* PBXTextBookmark */ = B5CF37350E7A8D040050CBA7 /* PBXTextBookmark */;
B5CF373C0E7A8FF90050CBA7 /* PBXTextBookmark */ = B5CF373C0E7A8FF90050CBA7 /* PBXTextBookmark */;
B5CF373D0E7A8FF90050CBA7 /* PBXTextBookmark */ = B5CF373D0E7A8FF90050CBA7 /* PBXTextBookmark */;
B5CF37400E7A90320050CBA7 /* PBXTextBookmark */ = B5CF37400E7A90320050CBA7 /* PBXTextBookmark */;
B5CF37410E7A90320050CBA7 /* PBXTextBookmark */ = B5CF37410E7A90320050CBA7 /* PBXTextBookmark */;
B5CF37420E7A90E10050CBA7 /* PBXTextBookmark */ = B5CF37420E7A90E10050CBA7 /* PBXTextBookmark */;
B5CF37430E7A90E10050CBA7 /* PBXTextBookmark */ = B5CF37430E7A90E10050CBA7 /* PBXTextBookmark */;
B5CF37440E7A90E10050CBA7 /* PBXTextBookmark */ = B5CF37440E7A90E10050CBA7 /* PBXTextBookmark */;
B5F3B7370E43683600E001FD = B5F3B7370E43683600E001FD /* PBXTextBookmark */;
B5F3B7390E43683600E001FD = B5F3B7390E43683600E001FD /* PBXTextBookmark */;
};
... ... @@ -548,9 +555,9 @@
};
B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1218, 2674}}";
sepNavSelRange = "{1971, 188}";
sepNavVisRange = "{1072, 1767}";
sepNavIntBoundsRect = "{{0, 0}, {1164, 3192}}";
sepNavSelRange = "{4774, 0}";
sepNavVisRange = "{6716, 3018}";
sepNavWindowFrame = "{{148, 98}, {1485, 874}}";
};
};
... ... @@ -762,9 +769,9 @@
};
B5ABC7B90E24C5620072F422 /* ASIHTTPRequest.m */ = {
uiCtxt = {
sepNavIntBoundsRect = "{{0, 0}, {1680, 11858}}";
sepNavIntBoundsRect = "{{0, 0}, {1037, 11900}}";
sepNavSelRange = "{14904, 0}";
sepNavVisRange = "{12494, 2255}";
sepNavVisRange = "{12494, 2251}";
sepNavWindowFrame = "{{759, 71}, {1475, 874}}";
};
};
... ... @@ -2523,7 +2530,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2507;
vrLoc = 5316;
... ... @@ -2533,12 +2540,12 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2538;
vrLoc = 5285;
};
B5CF36D30E7A8A910050CBA7 /* ASIHTTPRequestTests.m:143 */ = {
B5CF36D30E7A8A910050CBA7 /* ASIHTTPRequestTests.m:147 */ = {
isa = PBXFileBreakpoint;
actions = (
);
... ... @@ -2550,7 +2557,7 @@
functionName = "-testCookies";
hitCount = 0;
ignoreCount = 0;
lineNumber = 143;
lineNumber = 147;
location = Tests;
modificationTime = 242912513.58;
state = 0;
... ... @@ -2560,7 +2567,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2661;
vrLoc = 5162;
... ... @@ -2570,7 +2577,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2661;
vrLoc = 5162;
... ... @@ -2580,7 +2587,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2803;
vrLoc = 4757;
... ... @@ -2590,7 +2597,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2804;
vrLoc = 4757;
... ... @@ -2600,7 +2607,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2804;
vrLoc = 4757;
... ... @@ -2610,7 +2617,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2636;
vrLoc = 4757;
... ... @@ -2630,7 +2637,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 179";
rLen = 0;
rLoc = 7503;
rLoc = 7814;
rType = 0;
vrLen = 2636;
vrLoc = 4757;
... ... @@ -2708,7 +2715,7 @@
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 162";
rLen = 90;
rLoc = 6535;
rLoc = 6716;
rType = 0;
vrLen = 1609;
vrLoc = 5784;
... ... @@ -3061,6 +3068,72 @@
vrLen = 2255;
vrLoc = 12494;
};
B5CF373C0E7A8FF90050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
comments = "error: -[ASIHTTPRequestTests testBasicDownload] : \"((error) != nil)\" should be true. Failed to generate an error for a bad host - this test may fail when your DNS server redirects you to another page when it can't find a domain name (eg OpenDNS)";
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
rLen = 1;
rLoc = 57;
rType = 1;
};
B5CF373D0E7A8FF90050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 58";
rLen = 188;
rLoc = 1971;
rType = 0;
vrLen = 1767;
vrLoc = 1072;
};
B5CF37400E7A90320050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
comments = "error: -[ASIHTTPRequestTests testBasicDownload] : \"((error) != nil)\" should be true. Failed to generate an error for a bad host - this test may fail when your DNS server redirects you to another page when it can't find a domain name (eg OpenDNS)";
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
rLen = 1;
rLoc = 57;
rType = 1;
};
B5CF37410E7A90320050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 58";
rLen = 188;
rLoc = 1971;
rType = 0;
vrLen = 1767;
vrLoc = 1072;
};
B5CF37420E7A90E10050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B5ABC7B90E24C5620072F422 /* ASIHTTPRequest.m */;
name = "ASIHTTPRequest.m: 456";
rLen = 0;
rLoc = 14904;
rType = 0;
vrLen = 2251;
vrLoc = 12494;
};
B5CF37430E7A90E10050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B5ABC7B90E24C5620072F422 /* ASIHTTPRequest.m */;
name = "ASIHTTPRequest.m: 456";
rLen = 0;
rLoc = 14904;
rType = 0;
vrLen = 2251;
vrLoc = 12494;
};
B5CF37440E7A90E10050CBA7 /* PBXTextBookmark */ = {
isa = PBXTextBookmark;
fRef = B5731AFB0E430B1F0008024F /* ASIHTTPRequestTests.m */;
name = "ASIHTTPRequestTests.m: 123";
rLen = 0;
rLoc = 4774;
rType = 0;
vrLen = 3018;
vrLoc = 6716;
};
B5F3B72B0E4367CA00E001FD /* TimelineViewSelectionManagement.m */ = {
isa = PBXFileReference;
lastKnownFileType = sourcecode.c.objc;
... ...