]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/tests/CloudKitKeychainSyncingTestsBase.m
Security-59306.101.1.tar.gz
[apple/security.git] / keychain / ckks / tests / CloudKitKeychainSyncingTestsBase.m
1 /*
2 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 #if OCTAGON
25
26 #import "CloudKitKeychainSyncingTestsBase.h"
27
28 @implementation CloudKitKeychainSyncingTestsBase
29
30 - (ZoneKeys*)keychainZoneKeys {
31 return self.keys[self.keychainZoneID];
32 }
33
34 - (BOOL)mockPostFollowUpWithContext:(CDPFollowUpContext *)context error:(NSError **)error {
35 secnotice("octagon", "mock cdp posting follow up");
36 return YES;
37 }
38
39 // Override our base class
40 - (NSSet<NSString*>*)managedViewList {
41 return [NSSet setWithObject:@"keychain"];
42 }
43
44 + (void)setUp {
45 SecCKKSEnable();
46 SecCKKSResetSyncing();
47 [super setUp];
48 }
49
50 - (void)setUp {
51 self.utcCalendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierISO8601];
52 self.utcCalendar.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
53
54 [super setUp];
55
56 if(SecCKKSIsEnabled()) {
57 self.keychainZoneID = [[CKRecordZoneID alloc] initWithZoneName:@"keychain" ownerName:CKCurrentUserDefaultName];
58 self.keychainZone = [[FakeCKZone alloc] initZone: self.keychainZoneID];
59
60 [self.ckksZones addObject:self.keychainZoneID];
61
62 // Wait for the ViewManager to be brought up
63 XCTAssertEqual(0, [self.injectedManager.completedSecCKKSInitialize wait:20*NSEC_PER_SEC], "No timeout waiting for SecCKKSInitialize");
64
65 self.keychainView = [[CKKSViewManager manager] findView:@"keychain"];
66 XCTAssertNotNil(self.keychainView, "CKKSViewManager created the keychain view");
67 [self.ckksViews addObject:self.keychainView];
68 }
69
70 // Check that your environment is set up correctly
71 XCTAssertFalse([CKKSManifest shouldSyncManifests], "Manifests syncing is disabled");
72 XCTAssertFalse([CKKSManifest shouldEnforceManifests], "Manifests enforcement is disabled");
73 }
74
75
76 + (void)tearDown {
77 [super tearDown];
78 SecCKKSResetSyncing();
79 }
80
81 - (void)tearDown {
82 // Fetch status, to make sure we can
83 NSDictionary* status = [self.keychainView status];
84 (void)status;
85
86 [self.keychainView halt];
87 [self.keychainView waitUntilAllOperationsAreFinished];
88
89 self.keychainView = nil;
90 self.keychainZoneID = nil;
91
92 [self.injectedManager haltAll];
93
94 [super tearDown];
95 }
96
97 - (FakeCKZone*)keychainZone {
98 return self.zones[self.keychainZoneID];
99 }
100
101 - (void)setKeychainZone: (FakeCKZone*) zone {
102 self.zones[self.keychainZoneID] = zone;
103 }
104
105 @end
106
107 #endif /* OCTAGON */