diff --git a/Package.swift b/Package.swift index 8e145be80..c3244e754 100644 --- a/Package.swift +++ b/Package.swift @@ -62,7 +62,6 @@ let package = Package( "UserScript", "ContentBlocking", "SecureStorage", - .product(name: "Macros", package: "apple-toolbox"), ], resources: [ .process("ContentBlocking/UserScripts/contentblockerrules.js"), @@ -150,7 +149,6 @@ let package = Package( "Common", .product(name: "DDGSyncCrypto", package: "sync_crypto"), "Networking", - .product(name: "Macros", package: "apple-toolbox"), ], resources: [ .process("SyncMetadata.xcdatamodeld"), @@ -283,7 +281,6 @@ let package = Package( dependencies: [ "Networking", "Persistence", - .product(name: "Macros", package: "apple-toolbox"), ], plugins: [swiftlintPlugin] ), @@ -293,7 +290,6 @@ let package = Package( .target(name: "WireGuardC"), .product(name: "WireGuard", package: "wireguard-apple"), "Common", - .product(name: "Macros", package: "apple-toolbox"), ], swiftSettings: [ .define("DEBUG", .when(configuration: .debug)) @@ -330,7 +326,6 @@ let package = Package( name: "Subscription", dependencies: [ "Common", - .product(name: "Macros", package: "apple-toolbox"), ], swiftSettings: [ .define("DEBUG", .when(configuration: .debug)) @@ -375,7 +370,6 @@ let package = Package( "RemoteMessaging", // Move tests later (lots of test dependencies in BSK) "SecureStorageTestsUtils", "TestUtils", - .product(name: "Macros", package: "apple-toolbox"), ], resources: [ .copy("Resources") @@ -387,7 +381,6 @@ let package = Package( dependencies: [ "DDGSync", "TestUtils", - .product(name: "Macros", package: "apple-toolbox"), ], plugins: [swiftlintPlugin] ), @@ -402,7 +395,6 @@ let package = Package( name: "CommonTests", dependencies: [ "Common", - .product(name: "Macros", package: "apple-toolbox"), ], plugins: [swiftlintPlugin] ), @@ -418,7 +410,6 @@ let package = Package( dependencies: [ "Navigation", .product(name: "Swifter", package: "swifter"), - .product(name: "Macros", package: "apple-toolbox"), ], resources: [ .copy("Resources") @@ -485,7 +476,6 @@ let package = Package( dependencies: [ "SecureStorage", "SecureStorageTestsUtils", - .product(name: "Macros", package: "apple-toolbox"), ], plugins: [swiftlintPlugin] ), @@ -494,7 +484,6 @@ let package = Package( dependencies: [ "PrivacyDashboard", "TestUtils", - .product(name: "Macros", package: "apple-toolbox"), ], plugins: [swiftlintPlugin] ), diff --git a/Sources/BrowserServicesKit/Suggestions/SuggestionLoading.swift b/Sources/BrowserServicesKit/Suggestions/SuggestionLoading.swift index 5d05e2d32..1bfeeaa3f 100644 --- a/Sources/BrowserServicesKit/Suggestions/SuggestionLoading.swift +++ b/Sources/BrowserServicesKit/Suggestions/SuggestionLoading.swift @@ -17,7 +17,6 @@ // import Foundation -import Macros public protocol SuggestionLoading: AnyObject { diff --git a/Sources/DDGSync/DDGSyncing.swift b/Sources/DDGSync/DDGSyncing.swift index 02fb394ae..71d8dfcb3 100644 --- a/Sources/DDGSync/DDGSyncing.swift +++ b/Sources/DDGSync/DDGSyncing.swift @@ -20,7 +20,6 @@ import BrowserServicesKit import Combine import DDGSyncCrypto import Foundation -import Macros public enum SyncAuthState: String, Sendable, Codable { /// Sync engine is not initialized. @@ -177,9 +176,9 @@ public enum ServerEnvironment: LosslessStringConvertible { var baseURL: URL { switch self { case .development: - return #URL("https://dev-sync-use.duckduckgo.com") + return URL(string: "https://dev-sync-use.duckduckgo.com")! case .production: - return #URL("https://sync.duckduckgo.com") + return URL(string: "https://sync.duckduckgo.com")! } } diff --git a/Sources/NetworkProtection/AppLaunching.swift b/Sources/NetworkProtection/AppLaunching.swift deleted file mode 100644 index aa46a20e7..000000000 --- a/Sources/NetworkProtection/AppLaunching.swift +++ /dev/null @@ -1,38 +0,0 @@ -// -// AppLaunching.swift -// -// Copyright © 2022 DuckDuckGo. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -// SPDX-License-Identifier: MIT -// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved. - -import Foundation - -public enum AppLaunchCommand: Codable { - case justOpen - case shareFeedback - case showStatus - case showSettings - case showVPNLocations - case startVPN - case stopVPN - case enableOnDemand - case moveAppToApplications -} - -public protocol AppLaunching { - func launchApp(withCommand command: AppLaunchCommand) async -} diff --git a/Sources/NetworkProtection/NetworkProtectionDeviceManager.swift b/Sources/NetworkProtection/NetworkProtectionDeviceManager.swift index 58e3055ce..f54bfec38 100644 --- a/Sources/NetworkProtection/NetworkProtectionDeviceManager.swift +++ b/Sources/NetworkProtection/NetworkProtectionDeviceManager.swift @@ -138,7 +138,16 @@ public actor NetworkProtectionDeviceManager: NetworkProtectionDeviceManagement { if regenerateKey { keyPair = keyStore.newKeyPair() } else { - keyPair = keyStore.currentKeyPair() ?? keyStore.newKeyPair() + // Temporary code added on 2024-03-12 to fix a previous issue where users had a really long + // key expiration date. We should remove this after a month or so. + if let existingKeyPair = keyStore.currentKeyPair(), + existingKeyPair.expirationDate > Date().addingTimeInterval(TimeInterval.day) { + + keyPair = keyStore.newKeyPair() + } else { + // This is the regular code to restore when the above code is removed. + keyPair = keyStore.currentKeyPair() ?? keyStore.newKeyPair() + } } let (selectedServer, newExpiration) = try await register(keyPair: keyPair, selectionMethod: selectionMethod) @@ -146,7 +155,11 @@ public actor NetworkProtectionDeviceManager: NetworkProtectionDeviceManagement { keyStore.updateKeyPair(keyPair) - if let newExpiration { + // We only update the expiration date if it happens before our client-set expiration date. + // This way we respect the client-set expiration date, unless the server has set an earlier + // expiration for whatever reason (like if the subscription is known to expire). + // + if let newExpiration, newExpiration < keyPair.expirationDate { keyPair = KeyPair(privateKey: keyPair.privateKey, expirationDate: newExpiration) keyStore.updateKeyPair(keyPair) } @@ -224,9 +237,7 @@ public actor NetworkProtectionDeviceManager: NetworkProtectionDeviceManagement { // If we're looking to exclude a server we should have a few other options available. If we can't find any // then it means theres an inconsistency in the server list that was returned. errorEvents?.fire(NetworkProtectionError.serverListInconsistency) - - let cachedServer = try cachedServer(registeredWith: keyPair) - return (cachedServer, nil) + throw NetworkProtectionError.serverListInconsistency } selectedServer = registeredServer @@ -238,9 +249,7 @@ public actor NetworkProtectionDeviceManager: NetworkProtectionDeviceManagement { } handle(clientError: error) - - let cachedServer = try cachedServer(registeredWith: keyPair) - return (cachedServer, nil) + throw error } } diff --git a/Sources/NetworkProtection/Networking/NetworkProtectionClient.swift b/Sources/NetworkProtection/Networking/NetworkProtectionClient.swift index fadfca715..37ce3a174 100644 --- a/Sources/NetworkProtection/Networking/NetworkProtectionClient.swift +++ b/Sources/NetworkProtection/Networking/NetworkProtectionClient.swift @@ -17,7 +17,6 @@ // import Foundation -import Macros public enum NetworkProtectionAuthenticationMethod { case inviteCode(String) @@ -119,8 +118,8 @@ public struct AuthenticationFailureResponse: Decodable { final class NetworkProtectionBackendClient: NetworkProtectionClient { enum Constants { - static let productionEndpoint = #URL("https://controller.netp.duckduckgo.com") - static let stagingEndpoint = #URL("https://staging.netp.duckduckgo.com") + static let productionEndpoint = URL(string: "https://controller.netp.duckduckgo.com")! + static let stagingEndpoint = URL(string: "https://staging.netp.duckduckgo.com")! } private enum DecoderError: Error { diff --git a/Sources/NetworkProtection/PacketTunnelProvider.swift b/Sources/NetworkProtection/PacketTunnelProvider.swift index 0c40f6041..09a9e7f12 100644 --- a/Sources/NetworkProtection/PacketTunnelProvider.swift +++ b/Sources/NetworkProtection/PacketTunnelProvider.swift @@ -595,7 +595,7 @@ open class PacketTunnelProvider: NEPacketTunnelProvider { serverSelectionMethod: currentServerSelectionMethod, includedRoutes: includedRoutes ?? [], excludedRoutes: settings.excludedRanges, - regenerateKey: false) + regenerateKey: true) startTunnel(with: tunnelConfiguration, onDemand: onDemand, completionHandler: completionHandler) os_log("🔵 Done generating tunnel config", log: .networkProtection, type: .info) } catch { diff --git a/Sources/NetworkProtection/Settings/VPNSettings.swift b/Sources/NetworkProtection/Settings/VPNSettings.swift index f9dd01be0..5525318bf 100644 --- a/Sources/NetworkProtection/Settings/VPNSettings.swift +++ b/Sources/NetworkProtection/Settings/VPNSettings.swift @@ -18,7 +18,6 @@ import Combine import Foundation -import Macros /// Persists and publishes changes to tunnel settings. /// @@ -80,9 +79,9 @@ public final class VPNSettings { public var endpointURL: URL { switch self { case .production: - return #URL("https://controller.netp.duckduckgo.com") + return URL(string: "https://controller.netp.duckduckgo.com")! case .staging: - return #URL("https://staging1.netp.duckduckgo.com") + return URL(string: "https://staging1.netp.duckduckgo.com")! } } } diff --git a/Sources/NetworkProtectionTestUtils/MockAppLauncher.swift b/Sources/NetworkProtectionTestUtils/MockAppLauncher.swift deleted file mode 100644 index 3b8a1ac87..000000000 --- a/Sources/NetworkProtectionTestUtils/MockAppLauncher.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// MockAppLauncher.swift -// -// Copyright © 2023 DuckDuckGo. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -import Foundation -import NetworkProtection - -public final class MockAppLauncher: AppLaunching { - public init() { - } - - public var spyLaunchAppCommand: AppLaunchCommand? - public func launchApp(withCommand command: AppLaunchCommand) async { - spyLaunchAppCommand = command - } -} diff --git a/Sources/Subscription/Services/AuthService.swift b/Sources/Subscription/Services/AuthService.swift index f046e4489..b2e337a99 100644 --- a/Sources/Subscription/Services/AuthService.swift +++ b/Sources/Subscription/Services/AuthService.swift @@ -18,7 +18,6 @@ import Common import Foundation -import Macros public struct AuthService: APIService { @@ -30,9 +29,9 @@ public struct AuthService: APIService { public static var baseURL: URL { switch SubscriptionPurchaseEnvironment.currentServiceEnvironment { case .production: - #URL("https://quack.duckduckgo.com/api/auth") + URL(string: "https://quack.duckduckgo.com/api/auth")! case .staging: - #URL("https://quackdev.duckduckgo.com/api/auth") + URL(string: "https://quackdev.duckduckgo.com/api/auth")! } } diff --git a/Sources/Subscription/Services/SubscriptionService.swift b/Sources/Subscription/Services/SubscriptionService.swift index 030d28251..d6b94cb25 100644 --- a/Sources/Subscription/Services/SubscriptionService.swift +++ b/Sources/Subscription/Services/SubscriptionService.swift @@ -18,7 +18,6 @@ import Common import Foundation -import Macros public final class SubscriptionService: APIService { @@ -30,9 +29,9 @@ public final class SubscriptionService: APIService { public static var baseURL: URL { switch SubscriptionPurchaseEnvironment.currentServiceEnvironment { case .production: - #URL("https://subscriptions.duckduckgo.com/api") + URL(string: "https://subscriptions.duckduckgo.com/api")! case .staging: - #URL("https://subscriptions-dev.duckduckgo.com/api") + URL(string: "https://subscriptions-dev.duckduckgo.com/api")! } } diff --git a/Sources/Subscription/URL+Subscription.swift b/Sources/Subscription/URL+Subscription.swift index f3e6a2bd0..0bc7fddd4 100644 --- a/Sources/Subscription/URL+Subscription.swift +++ b/Sources/Subscription/URL+Subscription.swift @@ -17,16 +17,15 @@ // import Foundation -import Macros public extension URL { static var subscriptionBaseURL: URL { switch SubscriptionPurchaseEnvironment.currentServiceEnvironment { case .production: - #URL("https://duckduckgo.com/subscriptions") + URL(string: "https://duckduckgo.com/subscriptions")! case .staging: - #URL("https://duckduckgo.com/subscriptions?environment=staging") + URL(string: "https://duckduckgo.com/subscriptions?environment=staging")! } } @@ -35,7 +34,7 @@ public extension URL { } static var subscriptionFAQ: URL { - #URL("https://duckduckgo.com/about") + URL(string: "https://duckduckgo.com/about")! } // MARK: - Subscription Email @@ -54,7 +53,7 @@ public extension URL { // MARK: - App Store app manage subscription URL static var manageSubscriptionsInAppStoreAppURL: URL { - #URL("macappstores://apps.apple.com/account/subscriptions") + URL(string: "macappstores://apps.apple.com/account/subscriptions")! } // MARK: - Identity Theft Restoration @@ -62,9 +61,9 @@ public extension URL { static var identityTheftRestoration: URL { switch SubscriptionPurchaseEnvironment.currentServiceEnvironment { case .production: - #URL("https://duckduckgo.com/identity-theft-restoration") + URL(string: "https://duckduckgo.com/identity-theft-restoration")! case .staging: - #URL("https://duckduckgo.com/identity-theft-restoration?environment=staging") + URL(string: "https://duckduckgo.com/identity-theft-restoration?environment=staging")! } } } diff --git a/Sources/TestUtils/Utils/HTTPURLResponseExtension.swift b/Sources/TestUtils/Utils/HTTPURLResponseExtension.swift index cc2b76530..73f3948d3 100644 --- a/Sources/TestUtils/Utils/HTTPURLResponseExtension.swift +++ b/Sources/TestUtils/Utils/HTTPURLResponseExtension.swift @@ -17,13 +17,12 @@ // import Foundation -import Macros import Networking extension HTTPURLResponse { static let testEtag = "test-etag" - static let testUrl = #URL("http://www.example.com") + static let testUrl = URL(string: "http://www.example.com")! static let ok = HTTPURLResponse(url: testUrl, statusCode: 200, diff --git a/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionDetectionTests.swift b/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionDetectionTests.swift index e8ce0398d..87493169f 100644 --- a/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionDetectionTests.swift +++ b/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionDetectionTests.swift @@ -18,7 +18,6 @@ import BrowserServicesKit import Common -import Macros import XCTest final class MockAttributing: AdClickAttributing { @@ -81,9 +80,9 @@ final class AdClickAttributionDetectionTests: XCTestCase { let detection = AdClickAttributionDetection(feature: feature, tld: Self.tld) detection.delegate = delegate - detection.onStartNavigation(url: #URL("https://example.com")) - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.onStartNavigation(url: URL(string: "https://example.com")!) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) } func testWhenHeuristicOptionIsDisabledThenNothingIsDetected() { @@ -97,9 +96,9 @@ final class AdClickAttributionDetectionTests: XCTestCase { let detection = AdClickAttributionDetection(feature: feature, tld: Self.tld) detection.delegate = delegate - detection.onStartNavigation(url: #URL("https://example.com")) - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.onStartNavigation(url: URL(string: "https://example.com")!) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) } func testWhenDomainDetectionOptionIsDisabledThenFallbackToHeuristic() { @@ -125,8 +124,8 @@ final class AdClickAttributionDetectionTests: XCTestCase { } detection.delegate = delegate - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) wait(for: [delegateCalled], timeout: 0.1) } @@ -142,9 +141,9 @@ final class AdClickAttributionDetectionTests: XCTestCase { let detection = AdClickAttributionDetection(feature: feature, tld: Self.tld) detection.delegate = delegate - detection.onStartNavigation(url: #URL("https://example.com")) - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.onStartNavigation(url: URL(string: "https://example.com")!) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) } func testWhenThereAreMatchesThenVendorIsDetected_Heuristic() { @@ -161,9 +160,9 @@ final class AdClickAttributionDetectionTests: XCTestCase { let detection = AdClickAttributionDetection(feature: feature, tld: Self.tld) detection.delegate = delegate - detection.onStartNavigation(url: #URL("https://example.com")) - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.onStartNavigation(url: URL(string: "https://example.com")!) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) waitForExpectations(timeout: 0.1) } @@ -185,8 +184,8 @@ final class AdClickAttributionDetectionTests: XCTestCase { detection.delegate = delegate detection.onStartNavigation(url: URL(string: "https://example.com?\(domainParameterName)=domain.net")) - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) waitForExpectations(timeout: 0.1) } @@ -205,9 +204,9 @@ final class AdClickAttributionDetectionTests: XCTestCase { let detection = AdClickAttributionDetection(feature: feature, tld: Self.tld) detection.delegate = delegate - detection.onStartNavigation(url: #URL("https://example.com")) - detection.on2XXResponse(url: #URL("https://a.sub.test.com")) - detection.onDidFinishNavigation(url: #URL("https://a.sub.test.com")) + detection.onStartNavigation(url: URL(string: "https://example.com")!) + detection.on2XXResponse(url: URL(string: "https://a.sub.test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://a.sub.test.com")!) waitForExpectations(timeout: 0.1) } @@ -229,8 +228,8 @@ final class AdClickAttributionDetectionTests: XCTestCase { detection.delegate = delegate detection.onStartNavigation(url: URL(string: "https://example.com?\(domainParameterName)=a.domain.net")) - detection.on2XXResponse(url: #URL("https://sub.test.com")) - detection.onDidFinishNavigation(url: #URL("https://sub.test.com")) + detection.on2XXResponse(url: URL(string: "https://sub.test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://sub.test.com")!) waitForExpectations(timeout: 0.1) } @@ -253,12 +252,12 @@ final class AdClickAttributionDetectionTests: XCTestCase { detection.delegate = delegate detection.onStartNavigation(url: URL(string: "https://example.com?\(domainParameterName)=com")) - detection.on2XXResponse(url: #URL("https://sub.test.com")) + detection.on2XXResponse(url: URL(string: "https://sub.test.com")!) // Should match and notify only once - detection.on2XXResponse(url: #URL("https://another.test.com")) + detection.on2XXResponse(url: URL(string: "https://another.test.com")!) - detection.onDidFinishNavigation(url: #URL("https://another.test.com")) + detection.onDidFinishNavigation(url: URL(string: "https://another.test.com")!) waitForExpectations(timeout: 0.1) } @@ -275,15 +274,15 @@ final class AdClickAttributionDetectionTests: XCTestCase { detection.delegate = delegate // First matching requests that fails - detection.onStartNavigation(url: #URL("https://example.com")) + detection.onStartNavigation(url: URL(string: "https://example.com")!) detection.onDidFailNavigation() // Simulate non-matching request - nothing should be detected feature.onFormatMatching = { _ in return false } - detection.onStartNavigation(url: #URL("https://other.com")) - detection.on2XXResponse(url: #URL("https://test.com")) - detection.onDidFinishNavigation(url: #URL("https://test.com")) + detection.onStartNavigation(url: URL(string: "https://other.com")!) + detection.on2XXResponse(url: URL(string: "https://test.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://test.com")!) // Simulate matching request - it should be detected feature.onFormatMatching = { _ in return true } @@ -295,9 +294,9 @@ final class AdClickAttributionDetectionTests: XCTestCase { } detection.delegate = delegate - detection.onStartNavigation(url: #URL("https://domain.com")) - detection.on2XXResponse(url: #URL("https://a.something.com")) - detection.onDidFinishNavigation(url: #URL("https://a.something.com")) + detection.onStartNavigation(url: URL(string: "https://domain.com")!) + detection.on2XXResponse(url: URL(string: "https://a.something.com")!) + detection.onDidFinishNavigation(url: URL(string: "https://a.something.com")!) waitForExpectations(timeout: 0.1) } diff --git a/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionPixelTests.swift b/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionPixelTests.swift index bf432cd42..8407df0b5 100644 --- a/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionPixelTests.swift +++ b/Tests/BrowserServicesKitTests/ContentBlocker/AdClickAttribution/AdClickAttributionPixelTests.swift @@ -19,7 +19,6 @@ import BrowserServicesKit import Common import ContentBlocking -import Macros import XCTest final class AdClickAttributionPixelTests: XCTestCase { @@ -31,10 +30,10 @@ final class AdClickAttributionPixelTests: XCTestCase { static let domainParameterName = "ad_domain_param.com" static let linkUrlWithParameter = URL(string: "https://example.com/test.html?\(domainParameterName)=test.com")! - static let linkUrlWithoutParameter = #URL("https://example.com/test.html") + static let linkUrlWithoutParameter = URL(string: "https://example.com/test.html")! - static let matchedVendorURL = #URL("https://test.com/site") - static let mismatchedVendorURL = #URL("https://other.com/site") + static let matchedVendorURL = URL(string: "https://test.com/site")! + static let mismatchedVendorURL = URL(string: "https://other.com/site")! var currentEventHandler: (AdClickAttributionEvents, [String: String]?) -> Void = { _, _ in } diff --git a/Tests/BrowserServicesKitTests/ContentBlocker/ContentBlockerRulesUserScriptsTests.swift b/Tests/BrowserServicesKitTests/ContentBlocker/ContentBlockerRulesUserScriptsTests.swift index 5284904b8..f6b4440e5 100644 --- a/Tests/BrowserServicesKitTests/ContentBlocker/ContentBlockerRulesUserScriptsTests.swift +++ b/Tests/BrowserServicesKitTests/ContentBlocker/ContentBlockerRulesUserScriptsTests.swift @@ -18,7 +18,6 @@ import BrowserServicesKit import Common -import Macros import TrackerRadarKit import WebKit import XCTest @@ -79,9 +78,9 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { var webView: WKWebView? - let nonTrackerURL = #URL("test://nontracker.com/1.png") - let trackerURL = #URL("test://tracker.com/1.png") - let subTrackerURL = #URL("test://sub.tracker.com/1.png") + let nonTrackerURL = URL(string: "test://nontracker.com/1.png")! + let trackerURL = URL(string: "test://tracker.com/1.png")! + let subTrackerURL = URL(string: "test://sub.tracker.com/1.png")! var website: MockWebsite! @@ -178,7 +177,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://example.com") + let websiteURL = URL(string: "test://example.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -205,7 +204,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://tracker.com") + let websiteURL = URL(string: "test://tracker.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -239,7 +238,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://nontracker.com") + let websiteURL = URL(string: "test://nontracker.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -269,7 +268,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -301,7 +300,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://example.com") + let websiteURL = URL(string: "test://example.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -331,7 +330,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://sub.example.com") + let websiteURL = URL(string: "test://sub.example.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -358,7 +357,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://someexample.com") + let websiteURL = URL(string: "test://someexample.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -385,7 +384,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -415,7 +414,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://sub.example.com/index.html") + let websiteURL = URL(string: "test://sub.example.com/index.html")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -445,7 +444,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://someexample.com") + let websiteURL = URL(string: "test://someexample.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -472,7 +471,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: ["example.com"]) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -502,7 +501,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: ["example.com"]) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://sub.example.com/index.html") + let websiteURL = URL(string: "test://sub.example.com/index.html")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() @@ -532,7 +531,7 @@ class ContentBlockerRulesUserScriptsTests: XCTestCase { exceptions: []) let websiteLoaded = self.expectation(description: "Website Loaded") - let websiteURL = #URL("test://example.com") + let websiteURL = URL(string: "test://example.com")! navigationDelegateMock.onDidFinishNavigation = { websiteLoaded.fulfill() diff --git a/Tests/BrowserServicesKitTests/ContentBlocker/SurrogatesUserScriptTests.swift b/Tests/BrowserServicesKitTests/ContentBlocker/SurrogatesUserScriptTests.swift index 8bb936ebd..3dc3f0968 100644 --- a/Tests/BrowserServicesKitTests/ContentBlocker/SurrogatesUserScriptTests.swift +++ b/Tests/BrowserServicesKitTests/ContentBlocker/SurrogatesUserScriptTests.swift @@ -18,7 +18,6 @@ import BrowserServicesKit import Common -import Macros import TrackerRadarKit import WebKit import XCTest @@ -115,10 +114,10 @@ class SurrogatesUserScriptsTests: XCTestCase { var webView: WKWebView? - let nonTrackerURL = #URL("test://nontracker.com/1.png") - let trackerURL = #URL("test://tracker.com/1.png") - let surrogateScriptURL = #URL("test://tracker.com/scripts/script.js") - let nonSurrogateScriptURL = #URL("test://tracker.com/other/script.js") + let nonTrackerURL = URL(string: "test://nontracker.com/1.png")! + let trackerURL = URL(string: "test://tracker.com/1.png")! + let surrogateScriptURL = URL(string: "test://tracker.com/scripts/script.js")! + let nonSurrogateScriptURL = URL(string: "test://tracker.com/other/script.js")! var website: MockWebsite! @@ -216,7 +215,7 @@ class SurrogatesUserScriptsTests: XCTestCase { trackerAllowlist: [:], contentBlockingEnabled: true, exceptions: []) - let websiteURL = #URL("test://example.com") + let websiteURL = URL(string: "test://example.com")! let websiteLoaded = self.expectation(description: "Website Loaded") let surrogateValidated = self.expectation(description: "Validated surrogate injection") @@ -246,7 +245,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenSiteIsLocallyUnprotectedThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! let privacyConfig = WebKitTestHelper.preparePrivacyConfig(locallyUnprotected: ["example.com"], tempUnprotected: [], @@ -284,7 +283,7 @@ class SurrogatesUserScriptsTests: XCTestCase { contentBlockingEnabled: true, exceptions: []) - let websiteURL = #URL("test://sub.example.com") + let websiteURL = URL(string: "test://sub.example.com")! let websiteLoaded = self.expectation(description: "Website Loaded") let surrogateValidated = self.expectation(description: "Validated surrogate injection") @@ -314,7 +313,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenSiteIsTempUnprotectedThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! let privacyConfig = WebKitTestHelper.preparePrivacyConfig(locallyUnprotected: [], tempUnprotected: ["example.com"], @@ -346,7 +345,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenSiteIsSubdomainOfTempUnprotectedThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://sub.example.com/index.html") + let websiteURL = URL(string: "test://sub.example.com/index.html")! let privacyConfig = WebKitTestHelper.preparePrivacyConfig(locallyUnprotected: [], tempUnprotected: ["example.com"], @@ -378,7 +377,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenSiteIsInExceptionListThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! let allowlist = ["tracker.com": [PrivacyConfigurationData.TrackerAllowlist.Entry(rule: "tracker.com/", domains: ["example.com"])]] @@ -412,7 +411,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenSiteIsNotInExceptionListThenSurrogatesAreInjected() { - let websiteURL = #URL("test://example.com") + let websiteURL = URL(string: "test://example.com")! let allowlist = ["tracker.com": [PrivacyConfigurationData.TrackerAllowlist.Entry(rule: "tracker.com/", domains: ["test.com"])]] @@ -446,7 +445,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenTrackerIsInAllowListThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://example.com/index.html") + let websiteURL = URL(string: "test://example.com/index.html")! let privacyConfig = WebKitTestHelper.preparePrivacyConfig(locallyUnprotected: [], tempUnprotected: [], @@ -478,7 +477,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenSiteIsSubdomainOfExceptionListThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://sub.example.com/index.html") + let websiteURL = URL(string: "test://sub.example.com/index.html")! let privacyConfig = WebKitTestHelper.preparePrivacyConfig(locallyUnprotected: [], tempUnprotected: [], @@ -510,7 +509,7 @@ class SurrogatesUserScriptsTests: XCTestCase { func testWhenContentBlockingFeatureIsDisabledThenSurrogatesAreNotInjected() { - let websiteURL = #URL("test://sub.example.com") + let websiteURL = URL(string: "test://sub.example.com")! let privacyConfig = WebKitTestHelper.preparePrivacyConfig(locallyUnprotected: [], tempUnprotected: [], diff --git a/Tests/BrowserServicesKitTests/ContentBlocker/TrackerResolverTests.swift b/Tests/BrowserServicesKitTests/ContentBlocker/TrackerResolverTests.swift index db8b04153..b0bb57823 100644 --- a/Tests/BrowserServicesKitTests/ContentBlocker/TrackerResolverTests.swift +++ b/Tests/BrowserServicesKitTests/ContentBlocker/TrackerResolverTests.swift @@ -18,7 +18,6 @@ import Common import ContentBlocking -import Macros import TrackerRadarKit import XCTest @@ -32,7 +31,7 @@ class TrackerResolverTests: XCTestCase { let rule = KnownTracker.Rule.Matching(domains: [], types: []) - let urlOne = #URL("https://www.one.com") + let urlOne = URL(string: "https://www.one.com")! XCTAssertFalse(TrackerResolver.isMatching(rule, host: urlOne.host!, @@ -43,9 +42,9 @@ class TrackerResolverTests: XCTestCase { let rule = KnownTracker.Rule.Matching(domains: ["one.com", "two.com"], types: nil) - let urlOne = #URL("https://www.one.com") - let urlTwo = #URL("https://two.com") - let urlThree = #URL("https://www.three.com") + let urlOne = URL(string: "https://www.one.com")! + let urlTwo = URL(string: "https://two.com")! + let urlThree = URL(string: "https://www.three.com")! XCTAssertTrue(TrackerResolver.isMatching(rule, host: urlOne.host!, @@ -62,9 +61,9 @@ class TrackerResolverTests: XCTestCase { let rule = KnownTracker.Rule.Matching(domains: [], types: ["image", "script"]) - let urlOne = #URL("https://www.one.com") - let urlTwo = #URL("https://two.com") - let urlThree = #URL("https://www.three.com") + let urlOne = URL(string: "https://www.one.com")! + let urlTwo = URL(string: "https://two.com")! + let urlThree = URL(string: "https://www.three.com")! XCTAssertTrue(TrackerResolver.isMatching(rule, host: urlOne.host!, @@ -84,9 +83,9 @@ class TrackerResolverTests: XCTestCase { let rule = KnownTracker.Rule.Matching(domains: ["one.com", "two.com"], types: ["image", "script"]) - let urlOne = #URL("https://www.one.com") - let urlTwo = #URL("https://two.com") - let urlThree = #URL("https://www.three.com") + let urlOne = URL(string: "https://www.one.com")! + let urlTwo = URL(string: "https://two.com")! + let urlThree = URL(string: "https://www.three.com")! XCTAssertTrue(TrackerResolver.isMatching(rule, host: urlOne.host!, diff --git a/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultInternalUserDeciderTests.swift b/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultInternalUserDeciderTests.swift index 3e80c6929..c4da226b3 100644 --- a/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultInternalUserDeciderTests.swift +++ b/Tests/BrowserServicesKitTests/FeatureFlagging/DefaultInternalUserDeciderTests.swift @@ -16,14 +16,13 @@ // limitations under the License. // -import Macros import XCTest @testable import BrowserServicesKit class DefaultInternalUserDeciderTests: XCTestCase { - let correctURL = #URL("http://use-login.duckduckgo.com") + let correctURL = URL(string: "http://use-login.duckduckgo.com")! let correctStatusCode = 200 func testShouldMarkUserAsInternalWhenURLAndStatusCodeCorrectThenReturnsTrue() { @@ -40,14 +39,14 @@ class DefaultInternalUserDeciderTests: XCTestCase { func testShouldMarkUserAsInternalWhenURLIsIncorrectButSubdomainIsCorrectAndStatusCodeIsCorrectThenReturnsFalse() { let featureFlagger = DefaultInternalUserDecider() - let url = #URL("http://login.fishtown.com") + let url = URL(string: "http://login.fishtown.com")! let result = featureFlagger.shouldMarkUserAsInternal(forUrl: url, statusCode: correctStatusCode) XCTAssertFalse(result) } func testShouldMarkUserAsInternalWhenURLIsIncorrectButdomainIsCorrectAndStatusCodeIsCorrectThenReturnsFalse() { let featureFlagger = DefaultInternalUserDecider() - let url = #URL("http://sso.duckduckgo.com") + let url = URL(string: "http://sso.duckduckgo.com")! let result = featureFlagger.shouldMarkUserAsInternal(forUrl: url, statusCode: correctStatusCode) XCTAssertFalse(result) } diff --git a/Tests/BrowserServicesKitTests/GPC/GPCTests.swift b/Tests/BrowserServicesKitTests/GPC/GPCTests.swift index a32c3a469..b5f5ef066 100644 --- a/Tests/BrowserServicesKitTests/GPC/GPCTests.swift +++ b/Tests/BrowserServicesKitTests/GPC/GPCTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import BrowserServicesKit @@ -48,32 +47,32 @@ final class GPCTests: XCTestCase { } func testWhenGPCEnableDomainIsHttpThenISGPCEnabledTrue() { - let result = GPCRequestFactory().isGPCEnabled(url: #URL("https://www.washingtonpost.com"), config: appConfig) + let result = GPCRequestFactory().isGPCEnabled(url: URL(string: "https://www.washingtonpost.com")!, config: appConfig) XCTAssertTrue(result) } func testWhenGPCEnableDomainIsHttpsThenISGPCEnabledTrue() { - let result = GPCRequestFactory().isGPCEnabled(url: #URL("http://www.washingtonpost.com"), config: appConfig) + let result = GPCRequestFactory().isGPCEnabled(url: URL(string: "http://www.washingtonpost.com")!, config: appConfig) XCTAssertTrue(result) } func testWhenGPCEnableDomainHasNoSubDomainThenISGPCEnabledTrue() { - let result = GPCRequestFactory().isGPCEnabled(url: #URL("http://washingtonpost.com"), config: appConfig) + let result = GPCRequestFactory().isGPCEnabled(url: URL(string: "http://washingtonpost.com")!, config: appConfig) XCTAssertTrue(result) } func testWhenGPCEnableDomainHasPathThenISGPCEnabledTrue() { - let result = GPCRequestFactory().isGPCEnabled(url: #URL("http://www.washingtonpost.com/test/somearticle.html"), config: appConfig) + let result = GPCRequestFactory().isGPCEnabled(url: URL(string: "http://www.washingtonpost.com/test/somearticle.html")!, config: appConfig) XCTAssertTrue(result) } func testWhenGPCEnableDomainHasCorrectSubdomainThenISGPCEnabledTrue() { - let result = GPCRequestFactory().isGPCEnabled(url: #URL("http://global-privacy-control.glitch.me"), config: appConfig) + let result = GPCRequestFactory().isGPCEnabled(url: URL(string: "http://global-privacy-control.glitch.me")!, config: appConfig) XCTAssertTrue(result) } func testWhenGPCEnableDomainHasWrongSubdomainThenISGPCEnabledFalse() { - let result = GPCRequestFactory().isGPCEnabled(url: #URL("http://glitch.me"), config: appConfig) + let result = GPCRequestFactory().isGPCEnabled(url: URL(string: "http://glitch.me")!, config: appConfig) XCTAssertFalse(result) } diff --git a/Tests/BrowserServicesKitTests/PrivacyConfig/AdClickAttributionFeatureTests.swift b/Tests/BrowserServicesKitTests/PrivacyConfig/AdClickAttributionFeatureTests.swift index 232479037..72b44867e 100644 --- a/Tests/BrowserServicesKitTests/PrivacyConfig/AdClickAttributionFeatureTests.swift +++ b/Tests/BrowserServicesKitTests/PrivacyConfig/AdClickAttributionFeatureTests.swift @@ -17,7 +17,6 @@ // import BrowserServicesKit -import Macros import XCTest class AdClickAttributionFeatureTests: XCTestCase { @@ -83,25 +82,25 @@ class AdClickAttributionFeatureTests: XCTestCase { XCTAssertEqual(Set(feature.allowlist.map { $0.entity }), Set(["bing.com", "ad-site.site", "ad-site.example"])) - XCTAssertTrue(feature.isMatchingAttributionFormat(#URL("https://good.first-party.site/y.js?test_param=test"))) + XCTAssertTrue(feature.isMatchingAttributionFormat(URL(string: "https://good.first-party.site/y.js?test_param=test")!)) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://good.first-party.site/y.js"))) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://good.first-party.site/y.js?u2=2"))) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://good.first-party.site/y.js.gif?u2=2"))) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://sub.good.first-party.site/y.js?u3=2"))) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://good.first-party.site/y.js")!)) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://good.first-party.site/y.js?u2=2")!)) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://good.first-party.site/y.js.gif?u2=2")!)) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://sub.good.first-party.site/y.js?u3=2")!)) // No ad domain param - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://good.first-party.example/y.js?test_param=test.com"))) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://good.first-party.example/y.js?test_param=test.com")!)) // Testing for hardcoded value - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://other.first-party.com/m.js?ad_domain=a.com"))) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://other.first-party.com/m.js?test_param=test.com"))) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://other.first-party.com/m.js?ad_domain=a.com")!)) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://other.first-party.com/m.js?test_param=test.com")!)) // Dropping parameters tests - XCTAssertTrue(feature.isMatchingAttributionFormat(#URL("https://different.party.com/y.js?test_param=&foo=&bar="))) - XCTAssertTrue(feature.isMatchingAttributionFormat(#URL("https://different.party.com/y.js?test_param=example.com&foo=&bar="))) - XCTAssertTrue(feature.isMatchingAttributionFormat(#URL("https://different.party.com/y.js?test_param=&foo=&bar=&u3=xyz"))) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://different.party.com/y.js?foo=&bar=&u3=xyz"))) - XCTAssertFalse(feature.isMatchingAttributionFormat(#URL("https://different.party.com/y.js?foo=&bar="))) + XCTAssertTrue(feature.isMatchingAttributionFormat(URL(string: "https://different.party.com/y.js?test_param=&foo=&bar=")!)) + XCTAssertTrue(feature.isMatchingAttributionFormat(URL(string: "https://different.party.com/y.js?test_param=example.com&foo=&bar=")!)) + XCTAssertTrue(feature.isMatchingAttributionFormat(URL(string: "https://different.party.com/y.js?test_param=&foo=&bar=&u3=xyz")!)) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://different.party.com/y.js?foo=&bar=&u3=xyz")!)) + XCTAssertFalse(feature.isMatchingAttributionFormat(URL(string: "https://different.party.com/y.js?foo=&bar=")!)) } } diff --git a/Tests/BrowserServicesKitTests/SecureVault/MockAutofillDatabaseProvider.swift b/Tests/BrowserServicesKitTests/SecureVault/MockAutofillDatabaseProvider.swift index 16335b9f6..28dde5d80 100644 --- a/Tests/BrowserServicesKitTests/SecureVault/MockAutofillDatabaseProvider.swift +++ b/Tests/BrowserServicesKitTests/SecureVault/MockAutofillDatabaseProvider.swift @@ -18,13 +18,12 @@ import Foundation import GRDB -import Macros import SecureStorage @testable import BrowserServicesKit private extension URL { - static let duckduckgo = #URL("https://duckduckgo.com/") + static let duckduckgo = URL(string: "https://duckduckgo.com/")! } internal class MockAutofillDatabaseProvider: AutofillDatabaseProvider { @@ -45,7 +44,7 @@ internal class MockAutofillDatabaseProvider: AutofillDatabaseProvider { } static func recreateDatabase(withKey key: Data) throws -> Self { - return try MockAutofillDatabaseProvider(file: #URL("https://duck.com"), key: Data()) as! Self + return try MockAutofillDatabaseProvider(file: URL(string: "https://duck.com")!, key: Data()) as! Self } func hasAccountFor(username: String?, domain: String?) throws -> Bool { diff --git a/Tests/BrowserServicesKitTests/SmarterEncryption/HTTPSUpgradeReferenceTests.swift b/Tests/BrowserServicesKitTests/SmarterEncryption/HTTPSUpgradeReferenceTests.swift index 8aa0d9a15..3e2bc9fbd 100644 --- a/Tests/BrowserServicesKitTests/SmarterEncryption/HTTPSUpgradeReferenceTests.swift +++ b/Tests/BrowserServicesKitTests/SmarterEncryption/HTTPSUpgradeReferenceTests.swift @@ -17,7 +17,6 @@ // import Foundation -import Macros import os.log import Common import XCTest @@ -140,7 +139,7 @@ final class HTTPSUpgradeReferenceTests: XCTestCase { let httpsUpgrade = HTTPSUpgrade(store: mockStore, privacyManager: makePrivacyManager(config: nil, unprotectedDomains: ["secure.thirdtest.com"])) await httpsUpgrade.loadData() - let url = #URL("http://secure.thirdtest.com") + let url = URL(string: "http://secure.thirdtest.com")! var resultURL = url let result = await httpsUpgrade.upgrade(url: url) @@ -155,7 +154,7 @@ final class HTTPSUpgradeReferenceTests: XCTestCase { let httpsUpgrade = HTTPSUpgrade(store: mockStore, privacyManager: makePrivacyManager(config: nil, unprotectedDomains: ["thirdtest.com"])) await httpsUpgrade.loadData() - let url = #URL("http://secure.thirdtest.com") + let url = URL(string: "http://secure.thirdtest.com")! var resultURL = url let result = await httpsUpgrade.upgrade(url: url) diff --git a/Tests/BrowserServicesKitTests/Suggestions/ScoreTests.swift b/Tests/BrowserServicesKitTests/Suggestions/ScoreTests.swift index 84ff54b8f..1d3094406 100644 --- a/Tests/BrowserServicesKitTests/Suggestions/ScoreTests.swift +++ b/Tests/BrowserServicesKitTests/Suggestions/ScoreTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import BrowserServicesKit @@ -46,7 +45,7 @@ final class ScoreTests: XCTestCase { func testWhenURLMatchesWithQuery_ThenScoreIsIncreased() { let query = "testcase.com/no" let score1 = Score(title: "Test case website", - url: #URL("https://www.testcase.com/notroot"), + url: URL(string: "https://www.testcase.com/notroot")!, visitCount: 100, query: query) @@ -56,12 +55,12 @@ final class ScoreTests: XCTestCase { func testWhenTitleMatchesFromTheBeginning_ThenScoreIsIncreased() { let query = "test" let score1 = Score(title: "Test case website", - url: #URL("https://www.website.com"), + url: URL(string: "https://www.website.com")!, visitCount: 100, query: query) let score2 = Score(title: "Case test website 2", - url: #URL("https://www.website2.com"), + url: URL(string: "https://www.website2.com")!, visitCount: 100, query: query) @@ -71,12 +70,12 @@ final class ScoreTests: XCTestCase { func testWhenDomainMatchesFromTheBeginning_ThenScoreIsIncreased() { let query = "test" let score1 = Score(title: "Website", - url: #URL("https://www.test.com"), + url: URL(string: "https://www.test.com")!, visitCount: 100, query: query) let score2 = Score(title: "Website 2", - url: #URL("https://www.websitetest.com"), + url: URL(string: "https://www.websitetest.com")!, visitCount: 100, query: query) @@ -86,12 +85,12 @@ final class ScoreTests: XCTestCase { func testWhenThereIsMoreVisitCount_ThenScoreIsIncreased() { let query = "website" let score1 = Score(title: "Website", - url: #URL("https://www.website.com"), + url: URL(string: "https://www.website.com")!, visitCount: 100, query: query) let score2 = Score(title: "Website 2", - url: #URL("https://www.website2.com"), + url: URL(string: "https://www.website2.com")!, visitCount: 101, query: query) diff --git a/Tests/BrowserServicesKitTests/Suggestions/SuggestionProcessingTests.swift b/Tests/BrowserServicesKitTests/Suggestions/SuggestionProcessingTests.swift index 76081d829..bfe7e3f32 100644 --- a/Tests/BrowserServicesKitTests/Suggestions/SuggestionProcessingTests.swift +++ b/Tests/BrowserServicesKitTests/Suggestions/SuggestionProcessingTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import BrowserServicesKit @@ -42,7 +41,7 @@ extension HistoryEntryMock { static var aHistory: [HistorySuggestion] { [ HistoryEntryMock(identifier: UUID(), - url: #URL("http://www.duckduckgo.com"), + url: URL(string: "http://www.duckduckgo.com")!, title: nil, numberOfVisits: 1000, lastVisit: Date(), diff --git a/Tests/BrowserServicesKitTests/Suggestions/SuggestionTests.swift b/Tests/BrowserServicesKitTests/Suggestions/SuggestionTests.swift index 930c44468..6101849e9 100644 --- a/Tests/BrowserServicesKitTests/Suggestions/SuggestionTests.swift +++ b/Tests/BrowserServicesKitTests/Suggestions/SuggestionTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import BrowserServicesKit @@ -183,8 +182,8 @@ final class SuggestionTests: XCTestCase { fileprivate extension URL { - static let aURL = #URL("https://www.duckduckgo.com") + static let aURL = URL(string: "https://www.duckduckgo.com")! static let aRootUrl = aURL - static let aNonRootUrl = #URL("https://www.duckduckgo.com/traffic") + static let aNonRootUrl = URL(string: "https://www.duckduckgo.com/traffic")! } diff --git a/Tests/CommonTests/Extensions/URLExtensionTests.swift b/Tests/CommonTests/Extensions/URLExtensionTests.swift index c385fa1e9..2cd877119 100644 --- a/Tests/CommonTests/Extensions/URLExtensionTests.swift +++ b/Tests/CommonTests/Extensions/URLExtensionTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import Common @@ -111,17 +110,17 @@ final class URLExtensionTests: XCTestCase { } func testWhenNakedIsCalled_ThenURLWithNoSchemeWWWPrefixAndLastSlashIsReturned() { - let url = #URL("http://duckduckgo.com") - let duplicate = #URL("https://www.duckduckgo.com/") + let url = URL(string: "http://duckduckgo.com")! + let duplicate = URL(string: "https://www.duckduckgo.com/")! XCTAssertEqual(url.naked, duplicate.naked) } func testWhenRootIsCalled_ThenURLWithNoPathQueryFragmentUserAndPasswordIsReturned() { - let url = #URL("https://dax:123456@www.duckduckgo.com/test.php?test=S&info=test#fragment") + let url = URL(string: "https://dax:123456@www.duckduckgo.com/test.php?test=S&info=test#fragment")! let rootUrl = url.root! - XCTAssertEqual(rootUrl, #URL("https://www.duckduckgo.com/")) + XCTAssertEqual(rootUrl, URL(string: "https://www.duckduckgo.com/")!) XCTAssert(rootUrl.isRoot) } @@ -198,47 +197,47 @@ final class URLExtensionTests: XCTestCase { } func testIsRoot() { - let url = #URL("https://www.server.com:8080/path?query=string#fragment") - let rootUrl = #URL("https://www.server.com:8080/") + let url = URL(string: "https://www.server.com:8080/path?query=string#fragment")! + let rootUrl = URL(string: "https://www.server.com:8080/")! XCTAssert(rootUrl.isRoot) XCTAssertFalse(url.isRoot) } func testWhenAddParameterIsCalled_ThenItDoesNotChangeExistingURL() { - let url = #URL("https://duckduckgo.com/?q=Battle%20star+Galactica%25a") + let url = URL(string: "https://duckduckgo.com/?q=Battle%20star+Galactica%25a")! XCTAssertEqual( url.appendingParameter(name: "ia", value: "web"), - #URL("https://duckduckgo.com/?q=Battle%20star+Galactica%25a&ia=web") + URL(string: "https://duckduckgo.com/?q=Battle%20star+Galactica%25a&ia=web")! ) } func testWhenAddParameterIsCalled_ThenItEncodesRFC3986QueryReservedCharactersInTheParameter() { - let url = #URL("https://duck.com/") - - XCTAssertEqual(url.appendingParameter(name: ":", value: ":"), #URL("https://duck.com/?%3A=%3A")) - XCTAssertEqual(url.appendingParameter(name: "/", value: "/"), #URL("https://duck.com/?%2F=%2F")) - XCTAssertEqual(url.appendingParameter(name: "?", value: "?"), #URL("https://duck.com/?%3F=%3F")) - XCTAssertEqual(url.appendingParameter(name: "#", value: "#"), #URL("https://duck.com/?%23=%23")) - XCTAssertEqual(url.appendingParameter(name: "[", value: "["), #URL("https://duck.com/?%5B=%5B")) - XCTAssertEqual(url.appendingParameter(name: "]", value: "]"), #URL("https://duck.com/?%5D=%5D")) - XCTAssertEqual(url.appendingParameter(name: "@", value: "@"), #URL("https://duck.com/?%40=%40")) - XCTAssertEqual(url.appendingParameter(name: "!", value: "!"), #URL("https://duck.com/?%21=%21")) - XCTAssertEqual(url.appendingParameter(name: "$", value: "$"), #URL("https://duck.com/?%24=%24")) - XCTAssertEqual(url.appendingParameter(name: "&", value: "&"), #URL("https://duck.com/?%26=%26")) - XCTAssertEqual(url.appendingParameter(name: "'", value: "'"), #URL("https://duck.com/?%27=%27")) - XCTAssertEqual(url.appendingParameter(name: "(", value: "("), #URL("https://duck.com/?%28=%28")) - XCTAssertEqual(url.appendingParameter(name: ")", value: ")"), #URL("https://duck.com/?%29=%29")) - XCTAssertEqual(url.appendingParameter(name: "*", value: "*"), #URL("https://duck.com/?%2A=%2A")) - XCTAssertEqual(url.appendingParameter(name: "+", value: "+"), #URL("https://duck.com/?%2B=%2B")) - XCTAssertEqual(url.appendingParameter(name: ",", value: ","), #URL("https://duck.com/?%2C=%2C")) - XCTAssertEqual(url.appendingParameter(name: ";", value: ";"), #URL("https://duck.com/?%3B=%3B")) - XCTAssertEqual(url.appendingParameter(name: "=", value: "="), #URL("https://duck.com/?%3D=%3D")) + let url = URL(string: "https://duck.com/")! + + XCTAssertEqual(url.appendingParameter(name: ":", value: ":"), URL(string: "https://duck.com/?%3A=%3A")!) + XCTAssertEqual(url.appendingParameter(name: "/", value: "/"), URL(string: "https://duck.com/?%2F=%2F")!) + XCTAssertEqual(url.appendingParameter(name: "?", value: "?"), URL(string: "https://duck.com/?%3F=%3F")!) + XCTAssertEqual(url.appendingParameter(name: "#", value: "#"), URL(string: "https://duck.com/?%23=%23")!) + XCTAssertEqual(url.appendingParameter(name: "[", value: "["), URL(string: "https://duck.com/?%5B=%5B")!) + XCTAssertEqual(url.appendingParameter(name: "]", value: "]"), URL(string: "https://duck.com/?%5D=%5D")!) + XCTAssertEqual(url.appendingParameter(name: "@", value: "@"), URL(string: "https://duck.com/?%40=%40")!) + XCTAssertEqual(url.appendingParameter(name: "!", value: "!"), URL(string: "https://duck.com/?%21=%21")!) + XCTAssertEqual(url.appendingParameter(name: "$", value: "$"), URL(string: "https://duck.com/?%24=%24")!) + XCTAssertEqual(url.appendingParameter(name: "&", value: "&"), URL(string: "https://duck.com/?%26=%26")!) + XCTAssertEqual(url.appendingParameter(name: "'", value: "'"), URL(string: "https://duck.com/?%27=%27")!) + XCTAssertEqual(url.appendingParameter(name: "(", value: "("), URL(string: "https://duck.com/?%28=%28")!) + XCTAssertEqual(url.appendingParameter(name: ")", value: ")"), URL(string: "https://duck.com/?%29=%29")!) + XCTAssertEqual(url.appendingParameter(name: "*", value: "*"), URL(string: "https://duck.com/?%2A=%2A")!) + XCTAssertEqual(url.appendingParameter(name: "+", value: "+"), URL(string: "https://duck.com/?%2B=%2B")!) + XCTAssertEqual(url.appendingParameter(name: ",", value: ","), URL(string: "https://duck.com/?%2C=%2C")!) + XCTAssertEqual(url.appendingParameter(name: ";", value: ";"), URL(string: "https://duck.com/?%3B=%3B")!) + XCTAssertEqual(url.appendingParameter(name: "=", value: "="), URL(string: "https://duck.com/?%3D=%3D")!) } func testWhenAddParameterIsCalled_ThenItAllowsUnescapedReservedCharactersAsSpecified() { - let url = #URL("https://duck.com/") + let url = URL(string: "https://duck.com/")! XCTAssertEqual( url.appendingParameter( @@ -246,7 +245,7 @@ final class URLExtensionTests: XCTestCase { value: "test.com,example.com/test,localhost:8000/api", allowedReservedCharacters: .init(charactersIn: ",:") ), - #URL("https://duck.com/?domains=test.com,example.com%2Ftest,localhost:8000%2Fapi") + URL(string: "https://duck.com/?domains=test.com,example.com%2Ftest,localhost:8000%2Fapi")! ) } @@ -370,88 +369,88 @@ final class URLExtensionTests: XCTestCase { } func testWhenParamExistsThengetParameterReturnsCorrectValue() throws { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue")! let expected = "secondValue" let actual = url.getParameter(named: "secondParam") XCTAssertEqual(actual, expected) } func testWhenParamDoesNotExistThengetParameterIsNil() throws { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue")! let result = url.getParameter(named: "someOtherParam") XCTAssertNil(result) } func testWhenParamExistsThenRemovingReturnUrlWithoutParam() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue") - let expected = #URL("http://test.com?secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue")! + let expected = URL(string: "http://test.com?secondParam=secondValue")! let actual = url.removeParameter(name: "firstParam") XCTAssertEqual(actual, expected) } func testWhenParamDoesNotExistThenRemovingReturnsSameUrl() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue")! let actual = url.removeParameter(name: "someOtherParam") XCTAssertEqual(actual, url) } func testWhenRemovingAParamThenRemainingUrlWebPlusesAreEncodedToEnsureTheyAreMaintainedAsSpaces() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=45+%2B+5") - let expected = #URL("http://test.com?secondParam=45+%2B+5") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=45+%2B+5")! + let expected = URL(string: "http://test.com?secondParam=45+%2B+5")! let actual = url.removeParameter(name: "firstParam") XCTAssertEqual(actual, expected) } func testWhenRemovingParamsThenRemovingReturnsUrlWithoutParams() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue&thirdParam=thirdValue") - let expected = #URL("http://test.com?secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue&thirdParam=thirdValue")! + let expected = URL(string: "http://test.com?secondParam=secondValue")! let actual = url.removingParameters(named: ["firstParam", "thirdParam"]) XCTAssertEqual(actual, expected) } func testWhenParamsDoNotExistThenRemovingReturnsSameUrl() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue")! let actual = url.removingParameters(named: ["someParam", "someOtherParam"]) XCTAssertEqual(actual, url) } func testWhenEmptyParamArrayIsUsedThenRemovingReturnsSameUrl() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=secondValue") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=secondValue")! let actual = url.removingParameters(named: []) XCTAssertEqual(actual, url) } func testWhenRemovingParamsThenRemainingUrlWebPlusesAreEncodedToEnsureTheyAreMaintainedAsSpaces() { - let url = #URL("http://test.com?firstParam=firstValue&secondParam=45+%2B+5") - let expected = #URL("http://test.com?secondParam=45+%2B+5") + let url = URL(string: "http://test.com?firstParam=firstValue&secondParam=45+%2B+5")! + let expected = URL(string: "http://test.com?secondParam=45+%2B+5")! let actual = url.removingParameters(named: ["firstParam"]) XCTAssertEqual(actual, expected) } func testWhenNoParamsThenAddingAppendsQuery() throws { - let url = #URL("http://test.com") - let expected = #URL("http://test.com?aParam=aValue") + let url = URL(string: "http://test.com")! + let expected = URL(string: "http://test.com?aParam=aValue")! let actual = url.appendingParameter(name: "aParam", value: "aValue") XCTAssertEqual(actual, expected) } func testWhenParamDoesNotExistThenAddingParamAppendsItToExistingQuery() throws { - let url = #URL("http://test.com?firstParam=firstValue") - let expected = #URL("http://test.com?firstParam=firstValue&anotherParam=anotherValue") + let url = URL(string: "http://test.com?firstParam=firstValue")! + let expected = URL(string: "http://test.com?firstParam=firstValue&anotherParam=anotherValue")! let actual = url.appendingParameter(name: "anotherParam", value: "anotherValue") XCTAssertEqual(actual, expected) } func testWhenParamHasInvalidCharactersThenAddingParamAppendsEncodedVersion() throws { - let url = #URL("http://test.com") - let expected = #URL("http://test.com?aParam=43%20%2B%205") + let url = URL(string: "http://test.com")! + let expected = URL(string: "http://test.com?aParam=43%20%2B%205")! let actual = url.appendingParameter(name: "aParam", value: "43 + 5") XCTAssertEqual(actual, expected) } func testWhenParamExistsThenAddingNewValueAppendsParam() throws { - let url = #URL("http://test.com?firstParam=firstValue") - let expected = #URL("http://test.com?firstParam=firstValue&firstParam=newValue") + let url = URL(string: "http://test.com?firstParam=firstValue")! + let expected = URL(string: "http://test.com?firstParam=firstValue&firstParam=newValue")! let actual = url.appendingParameter(name: "firstParam", value: "newValue") XCTAssertEqual(actual, expected) } diff --git a/Tests/DDGSyncTests/DDGSyncTests.swift b/Tests/DDGSyncTests/DDGSyncTests.swift index 37204ed3f..f20e22aed 100644 --- a/Tests/DDGSyncTests/DDGSyncTests.swift +++ b/Tests/DDGSyncTests/DDGSyncTests.swift @@ -18,7 +18,6 @@ import Combine import Common -import Macros import XCTest @testable import DDGSync @@ -51,9 +50,9 @@ final class DDGSyncTests: XCTestCase { dataProvidersSource = MockDataProvidersSource() dependencies = MockSyncDependencies() (dependencies.api as! RemoteAPIRequestCreatingMock).fakeRequests = [ - #URL("https://dev.null/sync/credentials"): HTTPRequestingMock(result: .init(data: "{\"credentials\":{\"last_modified\":\"1234\",\"entries\":[]}}".data(using: .utf8)!, response: .init())), - #URL("https://dev.null/sync/bookmarks"): HTTPRequestingMock(result: .init(data: "{\"bookmarks\":{\"last_modified\":\"1234\",\"entries\":[]}}".data(using: .utf8)!, response: .init())), - #URL("https://dev.null/sync/data"): HTTPRequestingMock(result: .init(data: "{\"bookmarks\":{\"last_modified\":\"1234\",\"entries\":[]},\"credentials\":{\"last_modified\":\"1234\",\"entries\":[]}}".data(using: .utf8)!, response: .init())) + URL(string: "https://dev.null/sync/credentials")!: HTTPRequestingMock(result: .init(data: "{\"credentials\":{\"last_modified\":\"1234\",\"entries\":[]}}".data(using: .utf8)!, response: .init())), + URL(string: "https://dev.null/sync/bookmarks")!: HTTPRequestingMock(result: .init(data: "{\"bookmarks\":{\"last_modified\":\"1234\",\"entries\":[]}}".data(using: .utf8)!, response: .init())), + URL(string: "https://dev.null/sync/data")!: HTTPRequestingMock(result: .init(data: "{\"bookmarks\":{\"last_modified\":\"1234\",\"entries\":[]},\"credentials\":{\"last_modified\":\"1234\",\"entries\":[]}}".data(using: .utf8)!, response: .init())) ] (dependencies.secureStore as! SecureStorageStub).theAccount = .mock @@ -457,7 +456,7 @@ final class DDGSyncTests: XCTestCase { dataProvidersSource.dataProviders = [dataProvider] (dependencies.api as! RemoteAPIRequestCreatingMock).fakeRequests = [:] - let http401Response = HTTPURLResponse(url: #URL("https://example.com"), statusCode: 401, httpVersion: nil, headerFields: [:])! + let http401Response = HTTPURLResponse(url: URL(string: "https://example.com")!, statusCode: 401, httpVersion: nil, headerFields: [:])! dependencies.request.result = HTTPResult(data: Data(), response: http401Response) let syncService = DDGSync(dataProvidersSource: dataProvidersSource, dependencies: dependencies) diff --git a/Tests/DDGSyncTests/Mocks/Mocks.swift b/Tests/DDGSyncTests/Mocks/Mocks.swift index 5973024ed..2a70bab97 100644 --- a/Tests/DDGSyncTests/Mocks/Mocks.swift +++ b/Tests/DDGSyncTests/Mocks/Mocks.swift @@ -20,7 +20,6 @@ import BrowserServicesKit import Combine import Common import Foundation -import Macros import Persistence import TestUtils @@ -197,7 +196,7 @@ class MockPrivacyConfiguration: PrivacyConfiguration { } struct MockSyncDependencies: SyncDependencies, SyncDependenciesDebuggingSupport { - var endpoints: Endpoints = Endpoints(baseURL: #URL("https://dev.null")) + var endpoints: Endpoints = Endpoints(baseURL: URL(string: "https://dev.null")!) var account: AccountManaging = AccountManagingMock() var api: RemoteAPIRequestCreating = RemoteAPIRequestCreatingMock() var secureStore: SecureStoring = SecureStorageStub() diff --git a/Tests/DDGSyncTests/SyncOperationTests.swift b/Tests/DDGSyncTests/SyncOperationTests.swift index 25d2323ca..4e604a338 100644 --- a/Tests/DDGSyncTests/SyncOperationTests.swift +++ b/Tests/DDGSyncTests/SyncOperationTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import DDGSync @@ -35,7 +34,7 @@ class SyncOperationTests: XCTestCase { apiMock = RemoteAPIRequestCreatingMock() request = HTTPRequestingMock() apiMock.request = request - endpoints = Endpoints(baseURL: #URL("https://example.com")) + endpoints = Endpoints(baseURL: URL(string: "https://example.com")!) storage = SecureStorageStub() crypter = CryptingMock() try storage.persistAccount( @@ -240,7 +239,7 @@ class SyncOperationTests: XCTestCase { let syncOperation = SyncOperation(dataProviders: [dataProvider], storage: storage, crypter: crypter, requestMaker: requestMaker) - request.result = .init(data: nil, response: HTTPURLResponse(url: #URL("https://example.com"), statusCode: 304, httpVersion: nil, headerFields: nil)!) + request.result = .init(data: nil, response: HTTPURLResponse(url: URL(string: "https://example.com")!, statusCode: 304, httpVersion: nil, headerFields: nil)!) try await syncOperation.sync(fetchOnly: false) diff --git a/Tests/DDGSyncTests/SyncQueueTests.swift b/Tests/DDGSyncTests/SyncQueueTests.swift index 60f3614a8..202e3bd06 100644 --- a/Tests/DDGSyncTests/SyncQueueTests.swift +++ b/Tests/DDGSyncTests/SyncQueueTests.swift @@ -16,7 +16,6 @@ // limitations under the License. // -import Macros import XCTest @testable import DDGSync @@ -35,7 +34,7 @@ class SyncQueueTests: XCTestCase { apiMock = RemoteAPIRequestCreatingMock() request = HTTPRequestingMock() apiMock.request = request - endpoints = Endpoints(baseURL: #URL("https://example.com")) + endpoints = Endpoints(baseURL: URL(string: "https://example.com")!) storage = SecureStorageStub() crypter = CryptingMock() try storage.persistAccount( diff --git a/Tests/NavigationTests/Helpers/DistributedNavigationDelegateTestsHelpers.swift b/Tests/NavigationTests/Helpers/DistributedNavigationDelegateTestsHelpers.swift index 6eef3cb0f..ab2002dd9 100644 --- a/Tests/NavigationTests/Helpers/DistributedNavigationDelegateTestsHelpers.swift +++ b/Tests/NavigationTests/Helpers/DistributedNavigationDelegateTestsHelpers.swift @@ -20,7 +20,6 @@ import Combine import Common -import Macros import Swifter import WebKit import XCTest @@ -105,15 +104,15 @@ extension DistributedNavigationDelegateTestsBase { } struct URLs { - let https = #URL("https://duckduckgo.com/") + let https = URL(string: "https://duckduckgo.com/")! let testScheme = URL(string: TestNavigationSchemeHandler.scheme + "://duckduckgo.com")! - let local = #URL("http://localhost:8084") - let local1 = #URL("http://localhost:8084/1") - let local2 = #URL("http://localhost:8084/2") - let local3 = #URL("http://localhost:8084/3") - let local4 = #URL("http://localhost:8084/4") + let local = URL(string: "http://localhost:8084")! + let local1 = URL(string: "http://localhost:8084/1")! + let local2 = URL(string: "http://localhost:8084/2")! + let local3 = URL(string: "http://localhost:8084/3")! + let local4 = URL(string: "http://localhost:8084/4")! let localHashed = URL(string: "http://localhost:8084#")! let localHashed1 = URL(string: "http://localhost:8084#navlink")! @@ -127,7 +126,7 @@ extension DistributedNavigationDelegateTestsBase { let aboutBlank = URL(string: "about:blank")! - let post3 = #URL("http://localhost:8084/post3.html") + let post3 = URL(string: "http://localhost:8084/post3.html")! } struct DataSource { diff --git a/Tests/NavigationTests/Helpers/NavigationTestHelpers.swift b/Tests/NavigationTests/Helpers/NavigationTestHelpers.swift index bae9234df..4659fdd1e 100644 --- a/Tests/NavigationTests/Helpers/NavigationTestHelpers.swift +++ b/Tests/NavigationTests/Helpers/NavigationTestHelpers.swift @@ -19,7 +19,6 @@ import Combine import Common import Foundation -import Macros import Navigation import WebKit @@ -362,7 +361,7 @@ var defaultHeaders: [String: String] = { let delegate = DefaultHeadersRetreiverNavigationDelegate() webView.navigationDelegate = delegate - webView.load(URLRequest(url: #URL("https://duckduckgo.com"))) + webView.load(URLRequest(url: URL(string: "https://duckduckgo.com")!)) while delegate.headers == nil { RunLoop.current.run(until: Date().addingTimeInterval(0.05)) } diff --git a/Tests/SecureStorageTests/TestMocks.swift b/Tests/SecureStorageTests/TestMocks.swift index 5a57766a8..0faeab3df 100644 --- a/Tests/SecureStorageTests/TestMocks.swift +++ b/Tests/SecureStorageTests/TestMocks.swift @@ -18,7 +18,6 @@ import Foundation import GRDB -import Macros import SecureStorage protocol MockDatabaseProvider: SecureStorageDatabaseProvider { @@ -30,7 +29,7 @@ protocol MockDatabaseProvider: SecureStorageDatabaseProvider { } private extension URL { - static let duckduckgo = #URL("https://duckduckgo.com/") + static let duckduckgo = URL(string: "https://duckduckgo.com/")! } final class ConcreteMockDatabaseProvider: MockDatabaseProvider {