Toggle navigation
Toggle navigation
This project
Loading...
Sign in
iOS
/
asi-http-request
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Ben Copsey
2009-08-27 15:59:27 +0100
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
25ad47f00ecd431c3fb222838468e2780d079bc7
25ad47f0
1 parent
6027b865
Fix bug with delegate authentication that would be triggered when presenting the wrong credentials
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
3 deletions
Classes/ASIHTTPRequest.m
Classes/Tests/ASINetworkQueueTests.m
Classes/ASIHTTPRequest.m
View file @
25ad47f
...
...
@@ -1518,6 +1518,12 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
// Prevent more than one request from asking for credentials at once
[
delegateAuthenticationLock
lock
];
// We know the credentials we just presented are bad. If they are the same as the session credentials, we should clear those too.
if
([
self
proxyCredentials
]
==
sessionProxyCredentials
)
{
[
ASIHTTPRequest
setSessionProxyCredentials
:
nil
];
}
[
self
setProxyCredentials
:
nil
];
// If the user cancelled authentication via a dialog presented by another request, our queue may have cancelled us
if
([
self
error
]
||
[
self
isCancelled
])
{
[
delegateAuthenticationLock
unlock
];
...
...
@@ -1531,8 +1537,8 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
return
;
}
[
self
setProxyCredentials
:
nil
];
[
self
setLastActivityTime
:
nil
];
if
([
self
askDelegateForProxyCredentials
])
{
[
self
attemptToApplyProxyCredentialsAndResume
];
[
delegateAuthenticationLock
unlock
];
...
...
@@ -1708,6 +1714,12 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
// Prevent more than one request from asking for credentials at once
[
delegateAuthenticationLock
lock
];
// We know the credentials we just presented are bad. If they are the same as the session credentials, we should clear those too.
if
([
self
requestCredentials
]
==
sessionCredentials
)
{
[
ASIHTTPRequest
setSessionCredentials
:
nil
];
}
[
self
setRequestCredentials
:
nil
];
// If the user cancelled authentication via a dialog presented by another request, our queue may have cancelled us
if
([
self
error
]
||
[
self
isCancelled
])
{
[
delegateAuthenticationLock
unlock
];
...
...
@@ -1721,7 +1733,7 @@ static NSRecursiveLock *delegateAuthenticationLock = nil;
return
;
}
[
self
setRequestCredentials
:
nil
];
[
self
setLastActivityTime
:
nil
];
...
...
Classes/Tests/ASINetworkQueueTests.m
View file @
25ad47f
...
...
@@ -397,7 +397,18 @@ IMPORTANT
[
request
setUsername
:
@"secret_username"
];
[
request
setPassword
:
@"secret_password"
];
[
request
retryUsingSuppliedCredentials
];
}
else
if
([[[
request
userInfo
]
objectForKey
:
@"test"
]
isEqualToString
:
@"delegate-auth-failure"
])
{
authenticationPromptCount
++
;
if
(
authenticationPromptCount
==
5
)
{
[
request
setUsername
:
@"secret_username"
];
[
request
setPassword
:
@"secret_password"
];
}
else
{
[
request
setUsername
:
@"wrong_username"
];
[
request
setPassword
:
@"wrong_password"
];
}
[
request
retryUsingSuppliedCredentials
];
// testProgressWithAuthentication will set a userInfo dictionary on the main request, to tell us not to supply credentials
}
else
if
(
!
[
request
mainRequest
]
||
!
[[
request
mainRequest
]
userInfo
])
{
...
...
@@ -829,6 +840,7 @@ IMPORTANT
// Test for a bug that used to exist where the temporary file used to store the request body would be removed when authentication failed
-
(
void
)
testPOSTWithAuthentication
{
[[
self
postQueue
]
cancelAllOperations
];
[
self
setPostQueue
:[
ASINetworkQueue
queue
]];
[[
self
postQueue
]
setRequestDidFinishSelector
:
@selector
(
postDone
:)];
[[
self
postQueue
]
setDelegate
:
self
];
...
...
@@ -846,6 +858,21 @@ IMPORTANT
GHAssertTrue
(
success
,
@"Didn't post correct data"
);
}
-
(
void
)
testDelegateAuthenticationFailure
{
[[
self
postQueue
]
cancelAllOperations
];
[
self
setPostQueue
:[
ASINetworkQueue
queue
]];
[[
self
postQueue
]
setRequestDidFinishSelector
:
@selector
(
postDone
:)];
[[
self
postQueue
]
setDelegate
:
self
];
ASIFormDataRequest
*
request
=
[
ASIFormDataRequest
requestWithURL
:[
NSURL
URLWithString
:
@"http://allseeing-i.com/ASIHTTPRequest/Tests/post_with_authentication"
]];
[
request
setPostValue
:
@"This is the first item"
forKey
:
@"first"
];
[
request
setData
:[
@"This is the second item"
dataUsingEncoding
:
NSUTF8StringEncoding
]
forKey
:
@"second"
];
[
request
setUserInfo
:[
NSDictionary
dictionaryWithObject
:
@"delegate-auth-failure"
forKey
:
@"test"
]];
[[
self
postQueue
]
addOperation
:
request
];
[[
self
postQueue
]
go
];
}
@synthesize
immediateCancelQueue
;
@synthesize
failedRequests
;
@synthesize
finishedRequests
;
...
...
Please
register
or
login
to post a comment