]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/tests/CloudKitKeychainSyncingTestsBase.m
Security-58286.70.7.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 // Override our base class
35 -(NSSet*)managedViewList {
36 return [NSSet setWithObject:@"keychain"];
37 }
38
39 + (void)setUp {
40 SecCKKSEnable();
41 SecCKKSResetSyncing();
42 [super setUp];
43 }
44
45 - (void)setUp {
46 self.utcCalendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierISO8601];
47 self.utcCalendar.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
48
49 [super setUp];
50
51 self.keychainZoneID = [[CKRecordZoneID alloc] initWithZoneName:@"keychain" ownerName:CKCurrentUserDefaultName];
52 self.keychainZone = [[FakeCKZone alloc] initZone: self.keychainZoneID];
53
54 [self.ckksZones addObject:self.keychainZoneID];
55
56 // Wait for the ViewManager to be brought up
57 XCTAssertEqual(0, [self.injectedManager.completedSecCKKSInitialize wait:4*NSEC_PER_SEC], "No timeout waiting for SecCKKSInitialize");
58
59 self.keychainView = [[CKKSViewManager manager] findView:@"keychain"];
60 XCTAssertNotNil(self.keychainView, "CKKSViewManager created the keychain view");
61
62 // Check that your environment is set up correctly
63 XCTAssertFalse([CKKSManifest shouldSyncManifests], "Manifests syncing is disabled");
64 XCTAssertFalse([CKKSManifest shouldEnforceManifests], "Manifests enforcement is disabled");
65 }
66
67 + (void)tearDown {
68 [super tearDown];
69 SecCKKSResetSyncing();
70 }
71
72 - (void)tearDown {
73 // Fetch status, to make sure we can
74 NSDictionary* status = [self.keychainView status];
75 (void)status;
76
77 [self.keychainView halt];
78 [self.keychainView waitUntilAllOperationsAreFinished];
79
80 self.keychainView = nil;
81 self.keychainZoneID = nil;
82
83 [super tearDown];
84 }
85
86 - (FakeCKZone*)keychainZone {
87 return self.zones[self.keychainZoneID];
88 }
89
90 - (void)setKeychainZone: (FakeCKZone*) zone {
91 self.zones[self.keychainZoneID] = zone;
92 }
93
94 @end
95
96 #endif /* OCTAGON */