Showing
2 changed files
with
31 additions
and
0 deletions
@@ -332,6 +332,36 @@ IMPORTANT | @@ -332,6 +332,36 @@ IMPORTANT | ||
332 | 332 | ||
333 | } | 333 | } |
334 | 334 | ||
335 | +- (void)testDelegateAuthentication | ||
336 | +{ | ||
337 | + complete = NO; | ||
338 | + ASINetworkQueue *networkQueue = [ASINetworkQueue queue]; | ||
339 | + [networkQueue setDelegate:self]; | ||
340 | + [networkQueue setRequestDidFinishSelector:@selector(queueFinished:)]; | ||
341 | + | ||
342 | + ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/basic-authentication"]]; | ||
343 | + [networkQueue addOperation:request]; | ||
344 | + | ||
345 | + [networkQueue go]; | ||
346 | + | ||
347 | + while (!complete) { | ||
348 | + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.25]]; | ||
349 | + } | ||
350 | + | ||
351 | + NSError *error = [request error]; | ||
352 | + GHAssertNil(error,@"Request failed"); | ||
353 | +} | ||
354 | + | ||
355 | + | ||
356 | +- (void)authorizationNeededForRequest:(ASIHTTPRequest *)request | ||
357 | +{ | ||
358 | + [request setUsername:@"secret_username"]; | ||
359 | + [request setPassword:@"secret_password"]; | ||
360 | + [request retryWithAuthentication]; | ||
361 | +} | ||
362 | + | ||
363 | + | ||
364 | + | ||
335 | 365 | ||
336 | 366 | ||
337 | - (void)requestFailedExpectedly:(ASIHTTPRequest *)request | 367 | - (void)requestFailedExpectedly:(ASIHTTPRequest *)request |
@@ -20,6 +20,7 @@ | @@ -20,6 +20,7 @@ | ||
20 | - (void)testProxy; | 20 | - (void)testProxy; |
21 | - (void)testProxyAutodetect; | 21 | - (void)testProxyAutodetect; |
22 | - (void)testProxyWithSuppliedAuthenticationCredentials; | 22 | - (void)testProxyWithSuppliedAuthenticationCredentials; |
23 | +- (void)testDoubleAuthentication; | ||
23 | 24 | ||
24 | @property (retain) ASINetworkQueue *queue; | 25 | @property (retain) ASINetworkQueue *queue; |
25 | @property (assign) BOOL complete; | 26 | @property (assign) BOOL complete; |
-
Please register or login to post a comment