Skip to content

Commit

Permalink
Added unit tests for UTF-8 key and parameter values.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanus committed Aug 28, 2011
1 parent 2bee678 commit add29d5
Show file tree
Hide file tree
Showing 11 changed files with 408 additions and 14 deletions.
236 changes: 223 additions & 13 deletions PlainOAuth.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEWorkspaceUserSettings_HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
</dict>
</plist>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
version = "1.8">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
Expand All @@ -27,6 +27,16 @@
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EA94F336140AD7DC00EFAF02"
BuildableName = "PlainOAuthUnitTests.octest"
BlueprintName = "PlainOAuthUnitTests"
ReferencedContainer = "container:PlainOAuth.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand Down
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "EA94F336140AD7DC00EFAF02"
BuildableName = "PlainOAuthUnitTests.octest"
BlueprintName = "PlainOAuthUnitTests"
ReferencedContainer = "container:PlainOAuth.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug">
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Expand Up @@ -9,6 +9,11 @@
<key>orderHint</key>
<integer>0</integer>
</dict>
<key>PlainOAuthUnitTests.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
Expand All @@ -17,6 +22,11 @@
<key>primary</key>
<true/>
</dict>
<key>EA94F336140AD7DC00EFAF02</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
22 changes: 22 additions & 0 deletions PlainOAuthUnitTests/PlainOAuthUnitTests-Info.plist
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>com.jaanuskase.test.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
8 changes: 8 additions & 0 deletions PlainOAuthUnitTests/PlainOAuthUnitTests-Prefix.pch
@@ -0,0 +1,8 @@
//
// Prefix header for all source files of the 'PlainOAuthUnitTests' target in the 'PlainOAuthUnitTests' project
//

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif
17 changes: 17 additions & 0 deletions PlainOAuthUnitTests/PlainOAuthUnitTests.h
@@ -0,0 +1,17 @@
//
// PlainOAuthUnitTests.h
// PlainOAuthUnitTests
//
// Created by Jaanus Kase on 28.08.11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <SenTestingKit/SenTestingKit.h>

@class OAuth;

@interface PlainOAuthUnitTests : SenTestCase {
OAuth *oAuth;
}

@end
53 changes: 53 additions & 0 deletions PlainOAuthUnitTests/PlainOAuthUnitTests.m
@@ -0,0 +1,53 @@
//
// PlainOAuthUnitTests.m
// PlainOAuthUnitTests
//
// Created by Jaanus Kase on 28.08.11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import "PlainOAuthUnitTests.h"
#import "OAuth.h"
#import "OAuthConsumerCredentials.h"

@implementation PlainOAuthUnitTests

- (void)setUp
{
[super setUp];
oAuth = [[OAuth alloc] initWithConsumerKey:OAUTH_CONSUMER_KEY andConsumerSecret:OAUTH_CONSUMER_SECRET];
}

- (void)tearDown
{
[oAuth release];
[super tearDown];
}


- (void)testUtf8ParameterValue {
NSString *header = [oAuth oAuthHeaderForMethod:@"GET"
andUrl:@"http://www.example.com/"
andParams:[NSDictionary dictionaryWithObjectsAndKeys:@"hõäöš€", @"utf8Value", nil]];

NSRange range = [header rangeOfString:@"h%C3%B5%C3%A4%C3%B6%C5%A1%E2%82%AC"];
if (range.location == NSNotFound) {
STFail(@"Did not detect expected encoded UTF-8 parameter value in OAuth header");
}

}

- (void)testUtf8KeyValue {
NSString *header = [oAuth oAuthHeaderForMethod:@"GET"
andUrl:@"http://www.example.com/"
andParams:[NSDictionary dictionaryWithObjectsAndKeys:@"value", @"utf8Keyhõäöš€", nil]];

NSRange range = [header rangeOfString:@"h%C3%B5%C3%A4%C3%B6%C5%A1%E2%82%AC"];
if (range.location == NSNotFound) {
STFail(@"Did not detect expected encoded UTF-8 key value in OAuth header");
}


}

@end
2 changes: 2 additions & 0 deletions PlainOAuthUnitTests/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -15,6 +15,10 @@ I have tested the example app in Xcode 3.2.3 on iPhone with iOS 4, and iPad with

## Change log

### August 28, 2011

* Added unit tests for UTF-8 parameter keys and values.

### April 13, 2011

* Fixed a memory leak.
Expand Down

0 comments on commit add29d5

Please sign in to comment.