Ben Copsey

Cached credentials will not be used if different ones are set on the request

Tweak to finding NTLM proxy credentials
This diff is collapsed. Click to expand it.
@@ -1036,10 +1036,10 @@ @@ -1036,10 +1036,10 @@
1036 1036
1037 - (void)testBasicAuthentication 1037 - (void)testBasicAuthentication
1038 { 1038 {
1039 - [ASIHTTPRequest removeCredentialsForHost:@"allseeing-i.com" port:0 protocol:@"http" realm:@"SECRET_STUFF"]; 1039 + [ASIHTTPRequest removeCredentialsForHost:@"asi" port:0 protocol:@"http" realm:@"SECRET_STUFF"];
1040 [ASIHTTPRequest clearSession]; 1040 [ASIHTTPRequest clearSession];
1041 1041
1042 - NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com/ASIHTTPRequest/tests/basic-authentication"]; 1042 + NSURL *url = [NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/basic-authentication"];
1043 ASIHTTPRequest *request; 1043 ASIHTTPRequest *request;
1044 BOOL success; 1044 BOOL success;
1045 NSError *err; 1045 NSError *err;
@@ -1087,6 +1087,16 @@ @@ -1087,6 +1087,16 @@
1087 err = [request error]; 1087 err = [request error];
1088 GHAssertNil(err,@"Failed to reuse credentials"); 1088 GHAssertNil(err,@"Failed to reuse credentials");
1089 1089
  1090 + // Ensure new credentials are used in place of those in the session
  1091 + request = [[[ASIHTTPRequest alloc] initWithURL:[NSURL URLWithString:@"http://asi/ASIHTTPRequest/tests/basic-authentication-new-credentials"]] autorelease];
  1092 + [request setUsername:@"secret_username_2"];
  1093 + [request setPassword:@"secret_password_2"];
  1094 + [request setUseSessionPersistence:YES];
  1095 + [request setUseKeychainPersistence:NO];
  1096 + [request startSynchronous];
  1097 + err = [request error];
  1098 + GHAssertNil(err,@"Failed to reuse credentials");
  1099 +
1090 [ASIHTTPRequest clearSession]; 1100 [ASIHTTPRequest clearSession];
1091 1101
1092 // Ensure credentials stored in the session were wiped 1102 // Ensure credentials stored in the session were wiped
@@ -1103,7 +1113,7 @@ @@ -1103,7 +1113,7 @@
1103 err = [request error]; 1113 err = [request error];
1104 GHAssertNil(err,@"Failed to use stored credentials"); 1114 GHAssertNil(err,@"Failed to use stored credentials");
1105 1115
1106 - [ASIHTTPRequest removeCredentialsForHost:@"allseeing-i.com" port:0 protocol:@"http" realm:@"SECRET_STUFF"]; 1116 + [ASIHTTPRequest removeCredentialsForHost:@"asi" port:0 protocol:@"http" realm:@"SECRET_STUFF"];
1107 1117
1108 // Ensure credentials stored in the keychain were wiped 1118 // Ensure credentials stored in the keychain were wiped
1109 request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease]; 1119 request = [[[ASIHTTPRequest alloc] initWithURL:url] autorelease];