From 6f487524ddedec1115123af8cecec1b2169a4a6a Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Sat, 8 Aug 2020 18:37:46 -0700 Subject: [PATCH] Renaming --- Development Assets/DevelopmentModels.swift | 4 ++-- ...uthSession.swift => MockWebAuthSession.swift} | 6 +++--- Metatext.xcodeproj/project.pbxproj | 16 ++++++++-------- Shared/MetatextApp.swift | 2 +- Shared/Model/AppEnvironment.swift | 2 +- Shared/Networking/WebAuthSession.swift | 8 ++++---- Shared/View Models/AddIdentityViewModel.swift | 2 +- .../View Models/AddIdentityViewModelTests.swift | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) rename Development Assets/{StubbingWebAuthSession.swift => MockWebAuthSession.swift} (90%) diff --git a/Development Assets/DevelopmentModels.swift b/Development Assets/DevelopmentModels.swift index 964d696..b780246 100644 --- a/Development Assets/DevelopmentModels.swift +++ b/Development Assets/DevelopmentModels.swift @@ -75,7 +75,7 @@ extension AppEnvironment { identityDatabase: IdentityDatabase = .fresh(), defaults: Defaults = .fresh(), secrets: Secrets = .fresh(), - webAuthSessionType: WebAuthSession.Type = SuccessfulStubbingWebAuthSession.self) -> AppEnvironment { + webAuthSessionType: WebAuthSessionType.Type = SuccessfulMockWebAuthSession.self) -> AppEnvironment { AppEnvironment( URLSessionConfiguration: URLSessionConfiguration, identityDatabase: identityDatabase, @@ -89,7 +89,7 @@ extension AppEnvironment { identityDatabase: .development, defaults: .development, secrets: .development, - webAuthSessionType: SuccessfulStubbingWebAuthSession.self) + webAuthSessionType: SuccessfulMockWebAuthSession.self) } extension IdentityService { diff --git a/Development Assets/StubbingWebAuthSession.swift b/Development Assets/MockWebAuthSession.swift similarity index 90% rename from Development Assets/StubbingWebAuthSession.swift rename to Development Assets/MockWebAuthSession.swift index c249d81..93f0fe9 100644 --- a/Development Assets/StubbingWebAuthSession.swift +++ b/Development Assets/MockWebAuthSession.swift @@ -2,7 +2,7 @@ import Foundation -class StubbingWebAuthSession: WebAuthSession { +class MockWebAuthSession: WebAuthSessionType { let completionHandler: WebAuthSessionCompletionHandler let url: URL let callbackURLScheme: String? @@ -32,7 +32,7 @@ class StubbingWebAuthSession: WebAuthSession { } } -class SuccessfulStubbingWebAuthSession: StubbingWebAuthSession { +class SuccessfulMockWebAuthSession: MockWebAuthSession { private let redirectURL: URL required init( @@ -59,7 +59,7 @@ class SuccessfulStubbingWebAuthSession: StubbingWebAuthSession { } } -class CanceledLoginStubbingWebAuthSession: StubbingWebAuthSession { +class CanceledLoginMockWebAuthSession: MockWebAuthSession { override var completionHandlerError: Error? { WebAuthSessionError(.canceledLogin) } diff --git a/Metatext.xcodeproj/project.pbxproj b/Metatext.xcodeproj/project.pbxproj index 677eea2..2ac1381 100644 --- a/Metatext.xcodeproj/project.pbxproj +++ b/Metatext.xcodeproj/project.pbxproj @@ -84,8 +84,8 @@ D06B492024D3FB8000642749 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D06B491E24D3F7FE00642749 /* Localizable.strings */; }; D06B492324D4611300642749 /* KingfisherSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = D06B492224D4611300642749 /* KingfisherSwiftUI */; }; D06B492524D4612400642749 /* KingfisherSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = D06B492424D4612400642749 /* KingfisherSwiftUI */; }; - D074577724D29006004758DB /* StubbingWebAuthSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074577624D29006004758DB /* StubbingWebAuthSession.swift */; }; - D074577824D29006004758DB /* StubbingWebAuthSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074577624D29006004758DB /* StubbingWebAuthSession.swift */; }; + D074577724D29006004758DB /* MockWebAuthSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074577624D29006004758DB /* MockWebAuthSession.swift */; }; + D074577824D29006004758DB /* MockWebAuthSession.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074577624D29006004758DB /* MockWebAuthSession.swift */; }; D074577A24D29366004758DB /* URLSessionConfiguration+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074577924D29366004758DB /* URLSessionConfiguration+Extensions.swift */; }; D074577B24D29366004758DB /* URLSessionConfiguration+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D074577924D29366004758DB /* URLSessionConfiguration+Extensions.swift */; }; D081A40524D0F1A8001B016E /* String+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D081A40424D0F1A8001B016E /* String+Extensions.swift */; }; @@ -218,7 +218,7 @@ D0666A6E24C6DFB300F3F04B /* AccessToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccessToken.swift; sourceTree = ""; }; D0666A7124C6E0D300F3F04B /* Secrets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Secrets.swift; sourceTree = ""; }; D06B491E24D3F7FE00642749 /* Localizable.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; - D074577624D29006004758DB /* StubbingWebAuthSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StubbingWebAuthSession.swift; sourceTree = ""; }; + D074577624D29006004758DB /* MockWebAuthSession.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MockWebAuthSession.swift; sourceTree = ""; }; D074577924D29366004758DB /* URLSessionConfiguration+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSessionConfiguration+Extensions.swift"; sourceTree = ""; }; D081A40424D0F1A8001B016E /* String+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extensions.swift"; sourceTree = ""; }; D0A1CA7324DAC2F1003063E9 /* KingfisherOptionsInfo+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KingfisherOptionsInfo+Extensions.swift"; sourceTree = ""; }; @@ -536,13 +536,13 @@ isa = PBXGroup; children = ( D04FD74124D4AA34007D572D /* DevelopmentModels.swift */, - D0DC177624D0CF2600A75C65 /* MockKeychainService.swift */, - D052BBC824D74B6400A80A7A /* MockUserDefaults.swift */, D0DC175724D0130800A75C65 /* HTTPStubs.swift */, D0DC174824CFF13700A75C65 /* Mastodon API Stubs */, + D0DC177624D0CF2600A75C65 /* MockKeychainService.swift */, + D052BBC824D74B6400A80A7A /* MockUserDefaults.swift */, + D074577624D29006004758DB /* MockWebAuthSession.swift */, D0DC174C24CFF1F100A75C65 /* Stubbing.swift */, D0DC174524CFEC2000A75C65 /* StubbingURLProtocol.swift */, - D074577624D29006004758DB /* StubbingWebAuthSession.swift */, D074577924D29366004758DB /* URLSessionConfiguration+Extensions.swift */, ); path = "Development Assets"; @@ -803,7 +803,7 @@ D0091B6E24DD68090040E8D2 /* PreferencesView.swift in Sources */, D0159F8F24DE743700E78478 /* IdentitiesView.swift in Sources */, D0DB6EF424C5228A00D965FE /* AddIdentityView.swift in Sources */, - D074577724D29006004758DB /* StubbingWebAuthSession.swift in Sources */, + D074577724D29006004758DB /* MockWebAuthSession.swift in Sources */, D0159FA524DE989700E78478 /* NSMutableAttributedString+Extensions.swift in Sources */, D0ED1BCE24CF768200B4899C /* MastodonEndpoint.swift in Sources */, D074577A24D29366004758DB /* URLSessionConfiguration+Extensions.swift in Sources */, @@ -876,7 +876,7 @@ D019E6EA24DF72E700697C7D /* InstanceEndpoint.swift in Sources */, D0159F9C24DE748C00E78478 /* SidebarNavigationView.swift in Sources */, D019E6F124DF7C2F00697C7D /* DatabaseError.swift in Sources */, - D074577824D29006004758DB /* StubbingWebAuthSession.swift in Sources */, + D074577824D29006004758DB /* MockWebAuthSession.swift in Sources */, D0ED1BCF24CF768200B4899C /* MastodonEndpoint.swift in Sources */, D074577B24D29366004758DB /* URLSessionConfiguration+Extensions.swift in Sources */, D0ED1BB824CE47F400B4899C /* WebAuthSession.swift in Sources */, diff --git a/Shared/MetatextApp.swift b/Shared/MetatextApp.swift index 19c6480..0916c42 100644 --- a/Shared/MetatextApp.swift +++ b/Shared/MetatextApp.swift @@ -20,7 +20,7 @@ struct MetatextApp: App { identityDatabase: identityDatabase, defaults: Defaults(userDefaults: .standard), secrets: Secrets(keychainService: KeychainService(serviceName: "com.metabolist.metatext")), - webAuthSessionType: RealWebAuthSession.self) + webAuthSessionType: WebAuthSession.self) } var body: some Scene { diff --git a/Shared/Model/AppEnvironment.swift b/Shared/Model/AppEnvironment.swift index ed5cba0..be5d43d 100644 --- a/Shared/Model/AppEnvironment.swift +++ b/Shared/Model/AppEnvironment.swift @@ -7,5 +7,5 @@ struct AppEnvironment { let identityDatabase: IdentityDatabase let defaults: Defaults let secrets: Secrets - let webAuthSessionType: WebAuthSession.Type + let webAuthSessionType: WebAuthSessionType.Type } diff --git a/Shared/Networking/WebAuthSession.swift b/Shared/Networking/WebAuthSession.swift index 88f6fc8..7eb90fc 100644 --- a/Shared/Networking/WebAuthSession.swift +++ b/Shared/Networking/WebAuthSession.swift @@ -4,7 +4,7 @@ import Foundation import AuthenticationServices import Combine -protocol WebAuthSession: AnyObject { +protocol WebAuthSessionType: AnyObject { init(url URL: URL, callbackURLScheme: String?, completionHandler: @escaping WebAuthSessionCompletionHandler) @@ -12,7 +12,7 @@ protocol WebAuthSession: AnyObject { @discardableResult func start() -> Bool } -extension WebAuthSession { +extension WebAuthSessionType { static func publisher( url: URL, callbackURLScheme: String?, @@ -44,6 +44,6 @@ class WebAuthSessionContextProvider: NSObject, ASWebAuthenticationPresentationCo typealias WebAuthSessionCompletionHandler = ASWebAuthenticationSession.CompletionHandler typealias WebAuthSessionError = ASWebAuthenticationSessionError typealias WebAuthPresentationContextProviding = ASWebAuthenticationPresentationContextProviding -typealias RealWebAuthSession = ASWebAuthenticationSession +typealias WebAuthSession = ASWebAuthenticationSession -extension RealWebAuthSession: WebAuthSession {} +extension WebAuthSession: WebAuthSessionType {} diff --git a/Shared/View Models/AddIdentityViewModel.swift b/Shared/View Models/AddIdentityViewModel.swift index 349207a..55b7a73 100644 --- a/Shared/View Models/AddIdentityViewModel.swift +++ b/Shared/View Models/AddIdentityViewModel.swift @@ -114,7 +114,7 @@ private extension Publisher where Output == AppAuthorization { private extension Publisher where Output == (AppAuthorization, URL), Failure == Error { func authenticate( - webAuthSessionType: WebAuthSession.Type, + webAuthSessionType: WebAuthSessionType.Type, contextProvider: WebAuthSessionContextProvider, callbackURLScheme: String) -> AnyPublisher<(AppAuthorization, URL), Error> { flatMap { appAuthorization, url in diff --git a/Tests/View Models/AddIdentityViewModelTests.swift b/Tests/View Models/AddIdentityViewModelTests.swift index c3404ee..e60c29a 100644 --- a/Tests/View Models/AddIdentityViewModelTests.swift +++ b/Tests/View Models/AddIdentityViewModelTests.swift @@ -61,7 +61,7 @@ class AddIdentityViewModelTests: XCTestCase { } func testDoesNotAlertCanceledLogin() throws { - let environment = AppEnvironment.fresh(webAuthSessionType: CanceledLoginStubbingWebAuthSession.self) + let environment = AppEnvironment.fresh(webAuthSessionType: CanceledLoginMockWebAuthSession.self) let sut = AddIdentityViewModel(environment: environment) let recorder = sut.$alertItem.record()