Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases #54

Merged
merged 1 commit into from
Jan 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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