]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/tests/CloudKitKeychainSyncingTestsBase.m
Security-58286.200.222.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:20*NSEC_PER_SEC], "No timeout waiting for SecCKKSInitialize");
58
59 self.keychainView = [[CKKSViewManager manager] findView:@"keychain"];
60 [self.ckksViews addObject:self.keychainView];
61 XCTAssertNotNil(self.keychainView, "CKKSViewManager created the keychain view");
62
63 // Check that your environment is set up correctly
64 XCTAssertFalse([CKKSManifest shouldSyncManifests], "Manifests syncing is disabled");
65 XCTAssertFalse([CKKSManifest shouldEnforceManifests], "Manifests enforcement is disabled");
66 }
67
68 + (void)tearDown {
69 [super tearDown];
70 SecCKKSResetSyncing();
71 }
72
73 - (void)tearDown {
74 // Fetch status, to make sure we can
75 NSDictionary* status = [self.keychainView status];
76 (void)status;
77
78 [self.keychainView halt];
79 [self.keychainView waitUntilAllOperationsAreFinished];
80
81 self.keychainView = nil;
82 self.keychainZoneID = nil;
83
84 [super tearDown];
85 }
86
87 - (FakeCKZone*)keychainZone {
88 return self.zones[self.keychainZoneID];
89 }
90
91 - (void)setKeychainZone: (FakeCKZone*) zone {
92 self.zones[self.keychainZoneID] = zone;
93 }
94
95 @end
96
97 #endif /* OCTAGON */