2 // si-15-delete-access-group.m
5 // Created by Love Hörnquist Åstrand on 2016-06-28.
9 #import <Foundation/Foundation.h>
10 #include <Security/Security.h>
11 #include <Security/SecItemPriv.h>
14 #include "Security_regressions.h"
17 int si_15_delete_access_group(int argc, char *const *argv)
22 NSDictionary *query = NULL, *item = NULL;
23 NSDictionary *query2 = NULL, *item2 = NULL;
24 NSString *agrp = @"123456.test.group";
25 NSString *agrp2 = @"123456.test.group2";
26 CFErrorRef error = NULL;
32 (id)kSecClass : (id)kSecClassGenericPassword,
33 (id)kSecAttrLabel : @"keychain label",
36 (id)kSecClass : (id)kSecClassGenericPassword,
37 (id)kSecAttrLabel : @"keychain label2",
39 SecItemDelete((CFDictionaryRef)query);
40 SecItemDelete((CFDictionaryRef)query2);
47 (id)kSecClass : (id)kSecClassGenericPassword,
48 (id)kSecAttrLabel : @"keychain label",
49 (id)kSecAttrAccessGroup : agrp
52 ok_status(SecItemAdd((CFDictionaryRef)item, NULL), "SecItemAdd2");
54 ok_status(SecItemCopyMatching((CFDictionaryRef)query, NULL));
57 (id)kSecClass : (id)kSecClassGenericPassword,
58 (id)kSecAttrLabel : @"keychain label2",
59 (id)kSecAttrAccessGroup : agrp2
62 ok_status(SecItemAdd((CFDictionaryRef)item2, NULL), "SecItemAdd2");
64 is_status(SecItemCopyMatching((CFDictionaryRef)query, NULL), errSecSuccess);
65 is_status(SecItemCopyMatching((CFDictionaryRef)query2, NULL), errSecSuccess);
68 ok(SecItemDeleteAllWithAccessGroups((__bridge CFArrayRef)@[ agrp ], &error),
69 "SecItemDeleteAllWithAccessGroups: %@", error);
74 is_status(SecItemCopyMatching((CFDictionaryRef)query, NULL), errSecItemNotFound);
75 is_status(SecItemCopyMatching((CFDictionaryRef)query2, NULL), errSecSuccess);
77 ok(SecItemDeleteAllWithAccessGroups((__bridge CFArrayRef)@[ agrp2 ], &error),
78 "SecItemDeleteAllWithAccessGroups: %@", error);
83 is_status(SecItemCopyMatching((CFDictionaryRef)query, NULL), errSecItemNotFound);
84 is_status(SecItemCopyMatching((CFDictionaryRef)query2, NULL), errSecItemNotFound);