3 class OctagonCKKSConfigurationTestsPolicyDisabled: OctagonTestsBase {
4 // Pre-configure some things, so the OctagonTests will only operate on these views
5 override func setUp() {
6 if self.mockDeviceInfo == nil {
7 let actualDeviceAdapter = OTDeviceInformationActualAdapter()
8 self.mockDeviceInfo = OTMockDeviceInfoAdapter(modelID: actualDeviceAdapter.modelID(),
9 deviceName: actualDeviceAdapter.deviceName(),
10 serialNumber: NSUUID().uuidString,
11 osVersion: actualDeviceAdapter.osVersion())
14 // With the policy disabled, we only want to operate on a few zones
15 if self.mockDeviceInfo.mockModelID.contains("AppleTV") {
16 self.intendedCKKSZones = Set([
17 CKRecordZone.ID(zoneName: "LimitedPeersAllowed"),
20 self.intendedCKKSZones = Set([
21 CKRecordZone.ID(zoneName: "LimitedPeersAllowed"),
22 CKRecordZone.ID(zoneName: "Manatee"),
26 self.setCKKSViewsFromPolicyToNo = true
30 XCTAssertFalse(self.cuttlefishContext.viewManager!.useCKKSViewsFromPolicy(), "CKKS should not be configured to listen to policy-based views")
33 func testMergedViewListOff() throws {
34 XCTAssertFalse(self.cuttlefishContext.viewManager!.useCKKSViewsFromPolicy(), "CKKS should not be configured to listen to policy-based views")
36 self.startCKAccountStatusMock()
37 self.assertResetAndBecomeTrustedInDefaultContext()
39 let viewList = self.cuttlefishContext.viewManager!.viewList()
41 let expected = Set<String>(["Manatee", "LimitedPeersAllowed"])
43 let expected = Set<String>(["LimitedPeersAllowed"])
45 XCTAssertEqual(expected, viewList)
49 class OctagonCKKSConfigurationTestsPolicyEnabled: OctagonTestsBase {
50 override func setUp() {
52 if self.mockDeviceInfo == nil {
53 let actualDeviceAdapter = OTDeviceInformationActualAdapter()
54 self.mockDeviceInfo = OTMockDeviceInfoAdapter(modelID: actualDeviceAdapter.modelID(),
55 deviceName: actualDeviceAdapter.deviceName(),
56 serialNumber: NSUUID().uuidString,
57 osVersion: actualDeviceAdapter.osVersion())
60 // Most tests will use a much smaller list of views. But not us! Go wild!
61 if self.mockDeviceInfo.mockModelID.contains("AppleTV") {
62 self.intendedCKKSZones = Set([
63 CKRecordZone.ID(zoneName: "Home"),
64 self.limitedPeersAllowedZoneID!,
65 CKRecordZone.ID(zoneName: "WiFi"),
68 self.intendedCKKSZones = Set([
69 CKRecordZone.ID(zoneName: "ApplePay"),
70 CKRecordZone.ID(zoneName: "Applications"),
71 CKRecordZone.ID(zoneName: "AutoUnlock"),
72 // <rdar://problem/57771098> Octagon: create final policy for CKKS4All
73 // CKRecordZone.ID(zoneName: "Backstop"),
74 // <rdar://problem/57810109> Cuttlefish: remove Safari prefix from view names
75 CKRecordZone.ID(zoneName: "SafariCreditCards"),
76 CKRecordZone.ID(zoneName: "DevicePairing"),
77 CKRecordZone.ID(zoneName: "Engram"),
78 CKRecordZone.ID(zoneName: "Health"),
79 CKRecordZone.ID(zoneName: "Home"),
80 CKRecordZone.ID(zoneName: "LimitedPeersAllowed"),
81 CKRecordZone.ID(zoneName: "Manatee"),
82 // <rdar://problem/57810109> Cuttlefish: remove Safari prefix from view names
83 CKRecordZone.ID(zoneName: "SafariPasswords"),
84 CKRecordZone.ID(zoneName: "ProtectedCloudStorage"),
85 CKRecordZone.ID(zoneName: "SecureObjectSync"),
86 CKRecordZone.ID(zoneName: "WiFi"),
93 func testMergedViewListOn() throws {
94 XCTAssertTrue(self.cuttlefishContext.viewManager!.useCKKSViewsFromPolicy(), "CKKS should be configured to listen to policy-based views")
96 self.startCKAccountStatusMock()
97 self.assertResetAndBecomeTrustedInDefaultContext()
99 let viewList = self.cuttlefishContext.viewManager!.viewList()
102 let expected = Set<String>([
106 // <rdar://problem/57771098> Octagon: create final policy for CKKS4All
108 // <rdar://problem/57810109> Cuttlefish: remove Safari prefix from view names
114 "LimitedPeersAllowed",
116 // <rdar://problem/57810109> Cuttlefish: remove Safari prefix from view names
118 "ProtectedCloudStorage",
123 let expected = Set<String>(["LimitedPeersAllowed",
127 XCTAssertEqual(expected, viewList)
130 func testPolicyResetRPC() throws {
131 XCTAssertTrue(self.cuttlefishContext.viewManager!.useCKKSViewsFromPolicy(), "CKKS should be configured to listen to policy-based views")
133 self.startCKAccountStatusMock()
134 self.assertResetAndBecomeTrustedInDefaultContext()
136 XCTAssertNotNil(self.injectedManager?.policy, "Should have given CKKS a TPPolicy during initialization")
137 XCTAssertEqual(self.injectedManager?.policy?.version, prevailingPolicyVersion, "Policy given to CKKS should be prevailing policy")
139 self.injectedManager!.resetSyncingPolicy()
140 XCTAssertNil(self.injectedManager?.policy, "CKKS policy should be reset (by the test)")
142 self.otControl.refetchCKKSPolicy(nil, contextID: self.cuttlefishContext.contextID) { error in
143 XCTAssertNil(error, "Should be no error refetching the CKKS policy")
146 XCTAssertNotNil(self.injectedManager?.policy, "Should have given CKKS a TPPolicy during refetch")
147 XCTAssertEqual(self.injectedManager?.policy?.version, prevailingPolicyVersion, "Policy given to CKKS should be prevailing policy")