From f066d70bd6b873d1241459d2a7e7abb8b44043ec Mon Sep 17 00:00:00 2001 From: Federico Cappelli Date: Thu, 16 Nov 2023 14:51:17 +0000 Subject: [PATCH] fixed some unit tests, submodule updated --- DuckDuckGo/MainViewController+Segues.swift | 2 +- .../PrivacyDashboard/BrokenSiteInfo.swift | 96 +++++++++---------- .../BrokenSiteReportingTests.swift | 2 +- submodules/privacy-reference-tests | 2 +- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/DuckDuckGo/MainViewController+Segues.swift b/DuckDuckGo/MainViewController+Segues.swift index 70b5251559..47af3fba21 100644 --- a/DuckDuckGo/MainViewController+Segues.swift +++ b/DuckDuckGo/MainViewController+Segues.swift @@ -124,7 +124,7 @@ extension MainViewController { hideAllHighlightsIfNeeded() let brokenSiteInfo = currentTab?.getCurrentWebsiteInfo() - guard let currentURL = brokenSiteInfo?.url, + guard let currentURL = currentTab?.url, let privacyInfo = currentTab?.makePrivacyInfo(url: currentURL) else { assertionFailure("Missing fundamental data") return diff --git a/DuckDuckGo/PrivacyDashboard/BrokenSiteInfo.swift b/DuckDuckGo/PrivacyDashboard/BrokenSiteInfo.swift index 9a1746df10..ab5bcd3e33 100644 --- a/DuckDuckGo/PrivacyDashboard/BrokenSiteInfo.swift +++ b/DuckDuckGo/PrivacyDashboard/BrokenSiteInfo.swift @@ -24,24 +24,24 @@ public struct BrokenSiteInfo { static let allowedQueryReservedCharacters = CharacterSet(charactersIn: ",") - enum Key: String { - case siteUrl - case category - case description - case upgradedHttps - case tds - case blockedTrackers - case surrogates - case atb - case os - case manufacturer - case model - case siteType - case gpc - case ampUrl - case urlParametersRemoved - case protectionsState - case reportFlow + private struct Keys { + static let url = "siteUrl" + static let category = "category" + static let reportFlow = "reportFlow" + static let description = "description" + static let upgradedHttps = "upgradedHttps" + static let tds = "tds" + static let blockedTrackers = "blockedTrackers" + static let surrogates = "surrogates" + static let atb = "atb" + static let os = "os" + static let manufacturer = "manufacturer" + static let model = "model" + static let siteType = "siteType" + static let gpc = "gpc" + static let ampUrl = "ampUrl" + static let urlParametersRemoved = "urlParametersRemoved" + static let protectionsState = "protectionsState" } public enum Source: String { @@ -49,19 +49,19 @@ public struct BrokenSiteInfo { case dashboard } - public let url: URL? - public let httpsUpgrade: Bool - public let blockedTrackerDomains: [String] - public let installedSurrogates: [String] - public let isDesktop: Bool - public let tdsETag: String? - public let ampUrl: String? - public let urlParametersRemoved: Bool - public let model: String - public let manufacturer: String - public let systemVersion: String - public let gpc: Bool - public let protectionsState: Bool + private let url: URL? + private let httpsUpgrade: Bool + private let blockedTrackerDomains: [String] + private let installedSurrogates: [String] + private let isDesktop: Bool + private let tdsETag: String? + private let ampUrl: String? + private let urlParametersRemoved: Bool + private let model: String + private let manufacturer: String + private let systemVersion: String + private let gpc: Bool + private let protectionsState: Bool public init(url: URL?, httpsUpgrade: Bool, blockedTrackerDomains: [String], @@ -99,23 +99,23 @@ public struct BrokenSiteInfo { func send(with category: String?, description: String, source: Source) { let parameters: [String: String] = [ - Key.siteUrl.rawValue: normalize(url), - Key.category.rawValue: category ?? "", - Key.description.rawValue: description, - Key.reportFlow.rawValue: source.rawValue, - Key.upgradedHttps.rawValue: httpsUpgrade ? "true" : "false", - Key.siteType.rawValue: isDesktop ? "desktop" : "mobile", - Key.tds.rawValue: tdsETag?.trimmingCharacters(in: CharacterSet(charactersIn: "\"")) ?? "", - Key.blockedTrackers.rawValue: blockedTrackerDomains.joined(separator: ","), - Key.surrogates.rawValue: installedSurrogates.joined(separator: ","), - Key.atb.rawValue: StatisticsUserDefaults().atb ?? "", - Key.os.rawValue: systemVersion, - Key.manufacturer.rawValue: manufacturer, - Key.model.rawValue: model, - Key.gpc.rawValue: gpc ? "true" : "false", - Key.ampUrl.rawValue: ampUrl ?? "", - Key.urlParametersRemoved.rawValue: urlParametersRemoved ? "true" : "false", - Key.protectionsState.rawValue: protectionsState ? "true" : "false" + Keys.url: normalize(url), + Keys.category: category ?? "", + Keys.description: description, + Keys.reportFlow: source.rawValue, + Keys.upgradedHttps: httpsUpgrade ? "true" : "false", + Keys.siteType: isDesktop ? "desktop" : "mobile", + Keys.tds: tdsETag?.trimmingCharacters(in: CharacterSet(charactersIn: "\"")) ?? "", + Keys.blockedTrackers: blockedTrackerDomains.joined(separator: ","), + Keys.surrogates: installedSurrogates.joined(separator: ","), + Keys.atb: StatisticsUserDefaults().atb ?? "", + Keys.os: systemVersion, + Keys.manufacturer: manufacturer, + Keys.model: model, + Keys.gpc: gpc ? "true" : "false", + Keys.ampUrl: ampUrl ?? "", + Keys.urlParametersRemoved: urlParametersRemoved ? "true" : "false", + Keys.protectionsState: protectionsState ? "true" : "false" ] Pixel.fire(pixel: .brokenSiteReport, diff --git a/DuckDuckGoTests/BrokenSiteReportingTests.swift b/DuckDuckGoTests/BrokenSiteReportingTests.swift index ed20ec802e..2ffc9f0d7b 100644 --- a/DuckDuckGoTests/BrokenSiteReportingTests.swift +++ b/DuckDuckGoTests/BrokenSiteReportingTests.swift @@ -44,6 +44,7 @@ final class BrokenSiteReportingTests: XCTestCase { func testBrokenSiteReporting() throws { let testJSON = data.fromJsonFile(Resource.tests) + let testString = String(data: testJSON, encoding: .utf8) let testData = try JSONDecoder().decode(BrokenSiteReportingTestData.self, from: testJSON) referenceTests = testData.reportURL.tests.filter { @@ -133,7 +134,6 @@ private struct ReportURL: Codable { } // MARK: - Test - private struct Test: Codable { let name: String let siteURL: String diff --git a/submodules/privacy-reference-tests b/submodules/privacy-reference-tests index 7519c3d430..a3acc21947 160000 --- a/submodules/privacy-reference-tests +++ b/submodules/privacy-reference-tests @@ -1 +1 @@ -Subproject commit 7519c3d430e5dcef75b6128bfdadb0de3f463a49 +Subproject commit a3acc2194758bec0f01f57dd0c5f106de01a354e