X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/822b670c6f91d089ccb51b77e24b6ac80406b337..e3d460c9de4426da6c630c3ae3f46173a99f82d8:/RegressionTests/secedumodetest/secedumodetest.m diff --git a/RegressionTests/secedumodetest/secedumodetest.m b/RegressionTests/secedumodetest/secedumodetest.m new file mode 100644 index 00000000..617a88de --- /dev/null +++ b/RegressionTests/secedumodetest/secedumodetest.m @@ -0,0 +1,65 @@ +// +// Copyright 2016 Apple. All rights reserved. +// + +/* + * This is to fool os services to not provide the Keychain manager + * interface tht doens't work since we don't have unified headers + * between iOS and OS X. rdar://23405418/ + */ +#define __KEYCHAINCORE__ 1 + +#include +#include +#include +#include +#include + + +int main (int argc, const char * argv[]) +{ + @autoreleasepool { + + NSDictionary *addItem = @{ + (id)kSecClass : (id)kSecClassGenericPassword, + (id)kSecAttrLabel : @"vpn-test-label", + (id)kSecAttrAccount : @"vpn-test-account", + (id)kSecValueData : @"password", + (id)kSecUseSystemKeychain : @YES, + }; + + NSDictionary *querySystemItem = @{ + (id)kSecClass : (id)kSecClassGenericPassword, + (id)kSecAttrLabel : @"vpn-test-label", + (id)kSecAttrAccount : @"vpn-test-account", + (id)kSecUseSystemKeychain : @YES, + }; + + NSDictionary *queryItem = @{ + (id)kSecClass : (id)kSecClassGenericPassword, + (id)kSecAttrLabel : @"vpn-test-label", + (id)kSecAttrAccount : @"vpn-test-account", + }; + + (void)SecItemDelete((__bridge CFDictionaryRef)querySystemItem); + + + if (!SecItemAdd((__bridge CFDictionaryRef)addItem, NULL)) + errx(1, "failed to add"); + + + if (!SecItemCopyMatching((__bridge CFDictionaryRef)queryItem, NULL)) + errx(1, "failed to find in user + system"); + + if (!SecItemCopyMatching((__bridge CFDictionaryRef)querySystemItem, NULL)) + errx(1, "failed to find in system"); + + + if (!SecItemDelete((__bridge CFDictionaryRef)querySystemItem)) + errx(1, "failed to clean up"); + + return 0; + } +} + +