Investigated issues surrounding inability to change HTTP AUTH credentials thoroughly. fixes #250, #237, #127

These issues has been open for some time. I have added thorough unit test coverage
for scenarios of mutating the HTTP AUTH credentials on the RKClient and on individual
RKRequest instances. Everything seems to work fine.

Also added RKAuthenticationExample to RKCatalog for testing. Needs to be updated with
support for using OAuth.
This commit is contained in:
Blake Watters
2011-09-27 23:54:30 -04:00
parent a6364ed5db
commit 2d281e60d3
15 changed files with 610 additions and 92 deletions

View File

@@ -1,32 +0,0 @@
//
// RKNetwork.h
// RestKit
//
// Created by Blake Watters on 3/28/11.
// Copyright 2011 Two Toasters
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import <Foundation/Foundation.h>
/**
* Returns the global value for credential persistence to use during HTTP AUTH
* Defaults to NSURLCredentialPersistenceForSession
*/
NSURLCredentialPersistence RKNetworkGetGlobalCredentialPersistence(void);
/**
* Set the global value for credential persistence to use during HTTP AUTH
*/
void RKNetworkSetGlobalCredentialPersistence(NSURLCredentialPersistence persistence);

View File

@@ -1,32 +0,0 @@
//
// RKNetwork.m
// RestKit
//
// Created by Blake Watters on 3/28/11.
// Copyright 2011 Two Toasters
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#import "RKNetwork.h"
// Global credential persistence value.
static NSURLCredentialPersistence gCredentialPersistence = NSURLCredentialPersistenceForSession;
NSURLCredentialPersistence RKNetworkGetGlobalCredentialPersistence(void) {
return gCredentialPersistence;
}
void RKNetworkSetGlobalCredentialPersistence(NSURLCredentialPersistence persistence) {
gCredentialPersistence = persistence;
}

View File

@@ -98,11 +98,11 @@
*/
- (NSString*)bodyAsString;
/*!
/**
* Return the response body parsed as JSON into an object
* @deprecated in version 2.0
*/
- (id)bodyAsJSON;
- (id)bodyAsJSON DEPRECATED_ATTRIBUTE;
/**
* Return the response body parsed as JSON into an object

View File

@@ -20,7 +20,6 @@
#import "RKResponse.h"
#import "RKNotifications.h"
#import "RKNetwork.h"
#import "RKLog.h"
#import "RKParserRegistry.h"
#import "RKClient.h"
@@ -151,7 +150,7 @@ extern NSString* cacheURLKey;
NSURLCredential *newCredential;
newCredential=[NSURLCredential credentialWithUser:[NSString stringWithFormat:@"%@", _request.username]
password:[NSString stringWithFormat:@"%@", _request.password]
persistence:RKNetworkGetGlobalCredentialPersistence()];
persistence:NSURLCredentialPersistenceNone];
[[challenge sender] useCredential:newCredential
forAuthenticationChallenge:challenge];
} else {