Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Remove dependency on SSKeychain #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
platform :ios, '7.0'

target 'venmo-sdk', :exclusive => true do
podspec
end
pod 'CMDQueryStringSerialization', '0.2.0'
pod 'VENCore', '3.1.1'

target 'venmo-sdk-specs', :exclusive => true do
target 'venmo-sdk-specs' do
pod 'Specta'
pod 'Expecta'
pod 'OCMock', '~> 2.2.4'
pod 'Nocilla'
end

target 'venmo-sdk-integration-specs', :exclusive => true do
target 'venmo-sdk-integration-specs' do
pod 'Specta'
pod 'Expecta'
pod 'OCMock', '~> 2.2.4'
Expand Down
7 changes: 2 additions & 5 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,23 @@ PODS:
- Nocilla (0.10.0)
- OCMock (2.2.4)
- Specta (1.0.5)
- SSKeychain (1.2.3)
- VENCore (3.1.1):
- CMDQueryStringSerialization (~> 0.2.0)

DEPENDENCIES:
- CMDQueryStringSerialization (~> 0.2)
- CMDQueryStringSerialization (= 0.2.0)
- Expecta
- Nocilla
- OCMock (~> 2.2.4)
- Specta
- SSKeychain (~> 1.2)
- VENCore (~> 3.1)
- VENCore (= 3.1.1)

SPEC CHECKSUMS:
CMDQueryStringSerialization: 15f9004212bbc72533bb533f63df79d90a00a7d8
Expecta: e1c022fcd33910b6be89c291d2775b3fe27a89fe
Nocilla: ae0a2b05f3087b473624ac2b25903695df51246a
OCMock: a6a7dc0e3997fb9f35d99f72528698ebf60d64f2
Specta: ac94d110b865115fe60ff2c6d7281053c6f8e8a2
SSKeychain: 3f42991739c6c60a9cf1bbd4dff6c0d3694bcf3d
VENCore: fb44651f466971a2f3585b7e4e5a13c1641da9bf

COCOAPODS: 0.39.0
87 changes: 87 additions & 0 deletions venmo-sdk-specs/VENKeychainSpec.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#import "VENKeychain.h"

SpecBegin(VENKeychain)

__block VENKeychain *testKeychain;

beforeEach(^{
testKeychain = [[VENKeychain alloc] initWithService:@"VenmoSDK"];
});

describe(@"-initWithService:", ^{
it(@"is initialized with the provided service", ^{
expect(testKeychain.service).to.equal(@"VenmoSDK");
});
});

describe(@"-stringForAccount:error:", ^{
NSString *string = @"Password";
NSString *account = @"ClientApp";

afterEach(^{
[testKeychain removeStringForAccount:account error:nil];
});

context(@"when there is a stored string", ^{
it(@"returns the stored string", ^{
[testKeychain setString:string forAccount:account error:nil];

expect([testKeychain stringForAccount:account error:nil]).to.equal(@"Password");
});
});

context(@"when there is no stored string", ^{
it(@"returns nil", ^{
expect([testKeychain stringForAccount:account error:nil]).to.beNil();
});
});
});

describe(@"-setString:forAccount:error:", ^{
NSString *string = @"Password";
NSString *account = @"ClientApp2";

afterEach(^{
[testKeychain removeStringForAccount:account error:nil];
});

context(@"when there is no string for the given account", ^{
it(@"sets the string for the given account", ^{
expect([testKeychain stringForAccount:account error:nil]).to.beNil();

[testKeychain setString:string forAccount:account error:nil];

expect([testKeychain stringForAccount:account error:nil]).to.equal(string);
});
});

context(@"where there is a string for a given account", ^{
it(@"updates the string", ^{
NSString *updatedString = @"UpdatedPassword";
[testKeychain setString:string forAccount:account error:nil];

expect([testKeychain stringForAccount:account error:nil]).to.equal(string);

[testKeychain setString:updatedString forAccount:account error:nil];

expect([testKeychain stringForAccount:account error:nil]).to.equal(updatedString);
});
});
});

describe(@"-removeStringForAccount:error:", ^{
it(@"removes the string for the given account", ^{
NSString *string = @"Password";
NSString *account = @"ClientApp3";

[testKeychain setString:string forAccount:account error:nil];

expect([testKeychain stringForAccount:account error:nil]).to.equal(string);

[testKeychain removeStringForAccount:account error:nil];

expect([testKeychain stringForAccount:account error:nil]).to.beNil();
});
});

SpecEnd
22 changes: 0 additions & 22 deletions venmo-sdk-specs/VENSessionSpec.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
#import "VENSession.h"

#import <SSKeychain/SSKeychainQuery.h>
#import <VENCore/VENCore.h>
#import <VENCore/VENUserPayloadKeys.h>

extern NSString *const kVENKeychainServiceName;
extern NSString *const kVENKeychainAccountNamePrefix;

@interface VENSession ()

+ (SSKeychainQuery *)keychainQueryWithAppId:(NSString *)appId;

@end

SpecBegin(VENSession)

describe(@"init", ^{
Expand Down Expand Up @@ -97,19 +90,4 @@ + (SSKeychainQuery *)keychainQueryWithAppId:(NSString *)appId;
});
});

describe(@"keychainQueryWithAppId", ^{

it(@"should return a query with the correct service name", ^{
SSKeychainQuery *query = [VENSession keychainQueryWithAppId:@"123"];
expect(query.service).to.equal(kVENKeychainServiceName);
});

it(@"should return a query with the correct account name", ^{
SSKeychainQuery *query = [VENSession keychainQueryWithAppId:@"123"];
NSString *expectedAccountName = [NSString stringWithFormat:@"%@123", kVENKeychainAccountNamePrefix];
expect(query.account).to.equal(expectedAccountName);
});

});

SpecEnd
Loading