2 * Copyright (c) 2018 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
26 #import "CloudKitKeychainSyncingTestsBase.h"
28 @implementation CloudKitKeychainSyncingTestsBase
30 - (ZoneKeys*)keychainZoneKeys {
31 return self.keys[self.keychainZoneID];
34 - (BOOL)mockPostFollowUpWithContext:(CDPFollowUpContext *)context error:(NSError **)error {
35 secnotice("octagon", "mock cdp posting follow up");
39 // Override our base class
40 - (NSSet<NSString*>*)managedViewList {
41 return [NSSet setWithObject:@"keychain"];
46 SecCKKSResetSyncing();
51 self.utcCalendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierISO8601];
52 self.utcCalendar.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
56 if(SecCKKSIsEnabled()) {
57 self.keychainZoneID = [[CKRecordZoneID alloc] initWithZoneName:@"keychain" ownerName:CKCurrentUserDefaultName];
58 self.keychainZone = [[FakeCKZone alloc] initZone: self.keychainZoneID];
60 [self.ckksZones addObject:self.keychainZoneID];
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");
65 self.keychainView = [[CKKSViewManager manager] findView:@"keychain"];
66 XCTAssertNotNil(self.keychainView, "CKKSViewManager created the keychain view");
67 [self.ckksViews addObject:self.keychainView];
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");
78 SecCKKSResetSyncing();
82 // Fetch status, to make sure we can
83 NSDictionary* status = [self.keychainView status];
86 [self.keychainView halt];
87 [self.keychainView waitUntilAllOperationsAreFinished];
89 self.keychainView = nil;
90 self.keychainZoneID = nil;
92 [self.injectedManager haltAll];
97 - (FakeCKZone*)keychainZone {
98 return self.zones[self.keychainZoneID];
101 - (void)setKeychainZone: (FakeCKZone*) zone {
102 self.zones[self.keychainZoneID] = zone;