Skip to content

Commit

Permalink
Merge a5633fb into 737e056
Browse files Browse the repository at this point in the history
  • Loading branch information
kishikawakatsumi committed Jan 12, 2015
2 parents 737e056 + a5633fb commit ab9563e
Showing 1 changed file with 78 additions and 2 deletions.
80 changes: 78 additions & 2 deletions Lib/UICKeyChainStoreTests/UICKeyChainStoreTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,7 @@ - (void)testInstanceMethodsSetAndRemoveWithNilValue

#pragma mark -

- (void)testGetAllKeys
- (void)testGetAllKeys1
{
UICKeyChainStore *store = [UICKeyChainStore keyChainStoreWithService:@"github.com"];
[store removeAllItems];
Expand All @@ -1008,7 +1008,26 @@ - (void)testGetAllKeys
[store removeAllItems];
}

- (void)testGetAllItems
- (void)testGetAllKeys2
{
UICKeyChainStore *store = [UICKeyChainStore keyChainStoreWithServer:[NSURL URLWithString:@"https://kishikawakatsumi.com"] protocolType:UICKeyChainStoreProtocolTypeHTTPS];
[store removeAllItems];

[store setString:@"01234567-89ab-cdef-0123-456789abcdef" forKey:@"kishikawakatsumi"];
[store setString:@"00000000-89ab-cdef-0000-456789abcdef" forKey:@"hirohamada"];
[store setString:@"11111111-89ab-cdef-1111-456789abcdef" forKey:@"honeylemon"];

NSArray *allKeys = store.allKeys;
XCTAssertTrue([allKeys containsObject:@"kishikawakatsumi"]);
XCTAssertTrue([allKeys containsObject:@"hirohamada"]);
XCTAssertTrue([allKeys containsObject:@"honeylemon"]);

XCTAssertEqual(allKeys.count, 3);

[store removeAllItems];
}

- (void)testGetAllItems1
{
UICKeyChainStore *store = [UICKeyChainStore keyChainStoreWithService:@"github.com"];
[store removeAllItems];
Expand Down Expand Up @@ -1059,6 +1078,63 @@ - (void)testGetAllItems
[store removeAllItems];
}

- (void)testGetAllItems2
{
UICKeyChainStore *store = [UICKeyChainStore keyChainStoreWithServer:[NSURL URLWithString:@"https://kishikawakatsumi.com"] protocolType:UICKeyChainStoreProtocolTypeHTTPS];
[store removeAllItems];

[store setString:@"01234567-89ab-cdef-0123-456789abcdef" forKey:@"kishikawakatsumi"];
[store setString:@"00000000-89ab-cdef-0000-456789abcdef" forKey:@"hirohamada"];
[store setString:@"11111111-89ab-cdef-1111-456789abcdef" forKey:@"honeylemon"];

NSArray *allItems = store.allItems;
for (NSDictionary *item in allItems) {
if ([item[@"key"] isEqualToString:@"kishikawakatsumi"]) {
#if TARGET_OS_IPHONE
XCTAssertEqualObjects(item[@"value"], @"01234567-89ab-cdef-0123-456789abcdef");
#else
XCTAssertEqualObjects(item[@"value"], @"");
#endif
XCTAssertEqualObjects(item[@"server"], @"kishikawakatsumi.com");
XCTAssertEqualObjects(item[@"protocol"], (__bridge id)kSecAttrProtocolHTTPS);
XCTAssertEqualObjects(item[@"authenticationType"], (__bridge id)kSecAttrAuthenticationTypeDefault);
#if TARGET_OS_IPHONE
XCTAssertEqualObjects(item[@"accessibility"], (__bridge id)kSecAttrAccessibleAfterFirstUnlock);
#endif
}
if ([item[@"key"] isEqualToString:@"hirohamada"]) {
#if TARGET_OS_IPHONE
XCTAssertEqualObjects(item[@"value"], @"00000000-89ab-cdef-0000-456789abcdef");
#else
XCTAssertEqualObjects(item[@"value"], @"");
#endif
XCTAssertEqualObjects(item[@"server"], @"kishikawakatsumi.com");
XCTAssertEqualObjects(item[@"protocol"], (__bridge id)kSecAttrProtocolHTTPS);
XCTAssertEqualObjects(item[@"authenticationType"], (__bridge id)kSecAttrAuthenticationTypeDefault);
#if TARGET_OS_IPHONE
XCTAssertEqualObjects(item[@"accessibility"], (__bridge id)kSecAttrAccessibleAfterFirstUnlock);
#endif
}
if ([item[@"key"] isEqualToString:@"honeylemon"]) {
#if TARGET_OS_IPHONE
XCTAssertEqualObjects(item[@"value"], @"11111111-89ab-cdef-1111-456789abcdef");
#else
XCTAssertEqualObjects(item[@"value"], @"");
#endif
XCTAssertEqualObjects(item[@"server"], @"kishikawakatsumi.com");
XCTAssertEqualObjects(item[@"protocol"], (__bridge id)kSecAttrProtocolHTTPS);
XCTAssertEqualObjects(item[@"authenticationType"], (__bridge id)kSecAttrAuthenticationTypeDefault);
#if TARGET_OS_IPHONE
XCTAssertEqualObjects(item[@"accessibility"], (__bridge id)kSecAttrAccessibleAfterFirstUnlock);
#endif
}
}

XCTAssertEqual(allItems.count, 3);

[store removeAllItems];
}

- (void)testGetAllKeysClassMethod
{
[UICKeyChainStore removeAllItemsForService:@"github.com"];
Expand Down

0 comments on commit ab9563e

Please sign in to comment.