krz/domain-dig
an ios app for DNS & SSL analysis
clone: git clone https://gitbay.org/krz/domain-dig.git
v5.0.1: DomainDig/AuditFixtures.swift · raw
1#if DEBUG
2import Foundation
3
4/// Deterministic in-memory fixtures for the accessibility audit suite.
5///
6/// The dense rows (`WatchlistRowView`, `BatchResultRowView`) and the Dashboard
7/// portfolio sections never render on a fresh simulator, so five phases of row
8/// treatment shipped unverified by the automated audit. Driving the add-domain
9/// UI instead was tried and rejected: typing raises the keyboard, which then
10/// follows the audit onto later screens, and the added domains persist across
11/// runs, contaminating every other test's baseline.
12///
13/// These are activated by the `DOMAIN_DIG_SEED_FIXTURES` launch argument
14/// (DEBUG builds only, same pattern as `DOMAIN_DIG_FORCE_PRO_PLUS`) and are
15/// **never persisted** — see `seedAuditFixturesIfRequested()`.
16///
17/// The set is chosen to exercise every row path: healthy/warning/critical
18/// certificate badges, pinned, noted, changed, monitoring on/off, a
19/// stress-length domain name, and every batch status including failure.
20enum AuditFixtures {
21 static let launchArgument = "DOMAIN_DIG_SEED_FIXTURES"
22
23 static var requested: Bool {
24 ProcessInfo.processInfo.arguments.contains(launchArgument)
25 }
26
27 /// Relative to launch so the recency-gated Dashboard sections (Recent
28 /// Activity, Attention Required — both keyed to the last 24h) actually
29 /// render. Label text varies run to run ("2 hr. ago"); the audit measures
30 /// layout and traits, not string equality, so coverage wins.
31 private static let now = Date()
32
33 static var trackedDomains: [TrackedDomain] {
34 [
35 TrackedDomain(
36 domain: "healthy.example",
37 createdAt: now.addingTimeInterval(-86_400 * 30),
38 updatedAt: now.addingTimeInterval(-3_600),
39 isPinned: true,
40 monitoringEnabled: true,
41 lastKnownAvailability: .registered,
42 certificateWarningLevel: .none,
43 certificateDaysRemaining: 240,
44 lastMonitoredAt: now.addingTimeInterval(-1_800)
45 ),
46 TrackedDomain(
47 domain: "expiring.example",
48 createdAt: now.addingTimeInterval(-86_400 * 90),
49 updatedAt: now.addingTimeInterval(-7_200),
50 monitoringEnabled: true,
51 lastKnownAvailability: .registered,
52 lastChangeSummary: DomainChangeSummary(
53 hasChanges: true,
54 changedSections: ["ssl"],
55 message: "Certificate is approaching expiry",
56 severity: .medium,
57 impactClassification: .warning,
58 generatedAt: now.addingTimeInterval(-7_200)
59 ),
60 lastChangeSeverity: .medium,
61 certificateWarningLevel: .warning,
62 certificateDaysRemaining: 12,
63 lastMonitoredAt: now.addingTimeInterval(-7_200),
64 lastAlertAt: now.addingTimeInterval(-7_000)
65 ),
66 TrackedDomain(
67 domain: "broken.example",
68 createdAt: now.addingTimeInterval(-86_400 * 7),
69 updatedAt: now.addingTimeInterval(-600),
70 note: "Production incident follow-up: certificate replaced?",
71 monitoringEnabled: false,
72 lastKnownAvailability: .registered,
73 lastChangeSummary: DomainChangeSummary(
74 hasChanges: true,
75 changedSections: ["ssl", "dns"],
76 message: "TLS validation failed and NS records changed",
77 severity: .high,
78 impactClassification: .critical,
79 generatedAt: now.addingTimeInterval(-600)
80 ),
81 lastChangeSeverity: .high,
82 certificateWarningLevel: .critical,
83 certificateDaysRemaining: -3
84 ),
85 TrackedDomain(
86 domain: "very-long-subdomain.observability.internal.staging.example",
87 createdAt: now.addingTimeInterval(-86_400),
88 updatedAt: now.addingTimeInterval(-60),
89 monitoringEnabled: true,
90 lastKnownAvailability: .unknown
91 )
92 ]
93 }
94
95 static var batchResults: [BatchLookupResult] {
96 [
97 BatchLookupResult(
98 domain: "healthy.example",
99 historyEntryID: nil,
100 resultSource: .live,
101 availability: .registered,
102 primaryIP: "203.0.113.10",
103 quickStatus: "Stable",
104 summaryMessage: nil,
105 changeSeverity: nil,
106 changeClassification: nil,
107 certificateWarningLevel: .none,
108 riskScore: 12,
109 riskLevel: .low,
110 timestamp: now.addingTimeInterval(-120),
111 status: .completed,
112 errorMessage: nil
113 ),
114 BatchLookupResult(
115 domain: "expiring.example",
116 historyEntryID: nil,
117 resultSource: .cached,
118 availability: .registered,
119 primaryIP: "203.0.113.11",
120 quickStatus: "Changed",
121 summaryMessage: "Certificate is approaching expiry",
122 changeSeverity: .medium,
123 changeClassification: .warning,
124 certificateWarningLevel: .warning,
125 riskScore: 41,
126 riskLevel: .medium,
127 timestamp: now.addingTimeInterval(-3_600),
128 status: .completed,
129 errorMessage: nil
130 ),
131 BatchLookupResult(
132 domain: "broken.example",
133 historyEntryID: nil,
134 resultSource: .live,
135 availability: .registered,
136 primaryIP: "2001:db8::1f3:44",
137 quickStatus: "Changed",
138 summaryMessage: "TLS validation failed",
139 changeSeverity: .high,
140 changeClassification: .critical,
141 certificateWarningLevel: .critical,
142 riskScore: 78,
143 riskLevel: .high,
144 timestamp: now.addingTimeInterval(-60),
145 status: .completed,
146 errorMessage: nil
147 ),
148 BatchLookupResult(
149 domain: "unreachable.example",
150 historyEntryID: nil,
151 resultSource: .live,
152 availability: nil,
153 primaryIP: nil,
154 quickStatus: "Failed",
155 summaryMessage: nil,
156 changeSeverity: nil,
157 changeClassification: nil,
158 certificateWarningLevel: .none,
159 riskScore: nil,
160 riskLevel: nil,
161 timestamp: now,
162 status: .failed,
163 errorMessage: "The lookup timed out before any records were returned"
164 )
165 ]
166 }
167}
168#endif