Skip to content

Commit

Permalink
MBL-1234: Clean up code that was only used for PerimeterX
Browse files Browse the repository at this point in the history
  • Loading branch information
amy-at-kickstarter committed Feb 28, 2024
1 parent be87512 commit 85c1ee3
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 64 deletions.
4 changes: 0 additions & 4 deletions Configs/Secrets.swift.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public enum Secrets {
public static let password = "pswd"
}

public enum PerimeterX {
public static let appId = "deadbeef"
}

public enum Segment {
public static let staging = "write-key-staging"
public static let production = "write-key-production"
Expand Down
6 changes: 0 additions & 6 deletions Kickstarter-iOS/AppDelegateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,6 @@ public protocol AppDelegateViewModelOutputs {
/// Emits when the application should configure Firebase
var configureFirebase: Signal<(), Never> { get }

/// Emits when the application should configure Perimeter X
var configurePerimeterX: Signal<(), Never> { get }

/// Emits when the application should configure Segment with an instance of Braze.
var configureSegmentWithBraze: Signal<String, Never> { get }

Expand Down Expand Up @@ -688,8 +685,6 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi

self.configureFirebase = self.applicationLaunchOptionsProperty.signal.ignoreValues()

self.configurePerimeterX = self.applicationLaunchOptionsProperty.signal.ignoreValues()

self.configureAppCenterWithData = Signal.merge(
self.applicationLaunchOptionsProperty.signal.ignoreValues(),
self.userSessionStartedProperty.signal,
Expand Down Expand Up @@ -904,7 +899,6 @@ public final class AppDelegateViewModel: AppDelegateViewModelType, AppDelegateVi
public let applicationIconBadgeNumber: Signal<Int, Never>
public let configureAppCenterWithData: Signal<AppCenterConfigData, Never>
public let configureFirebase: Signal<(), Never>
public let configurePerimeterX: Signal<(), Never>
public let configureSegmentWithBraze: Signal<String, Never>
public let continueUserActivityReturnValue = MutableProperty(false)
public let emailVerificationCompleted: Signal<(String, Bool), Never>
Expand Down
10 changes: 0 additions & 10 deletions Kickstarter-iOS/AppDelegateViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ final class AppDelegateViewModelTests: TestCase {
private let applicationIconBadgeNumber = TestObserver<Int, Never>()
private let configureAppCenterWithData = TestObserver<AppCenterConfigData, Never>()
private let configureFirebase = TestObserver<(), Never>()
private let configurePerimeterX = TestObserver<(), Never>()
private let configureSegmentWithBraze = TestObserver<String, Never>()
private let didAcceptReceivingRemoteNotifications = TestObserver<(), Never>()
private let emailVerificationCompletedMessage = TestObserver<String, Never>()
Expand All @@ -27,8 +26,6 @@ final class AppDelegateViewModelTests: TestCase {
private let goToProfile = TestObserver<(), Never>()
private let goToMobileSafari = TestObserver<URL, Never>()
private let goToSearch = TestObserver<(), Never>()
private let perimeterXManagerReady = TestObserver<[String: String]?, Never>()
private let perimeterXRefreshedHeaders = TestObserver<[String: String]?, Never>()
private let postNotificationName = TestObserver<Notification.Name, Never>()
private let presentViewController = TestObserver<Int, Never>()
private let pushRegistrationStarted = TestObserver<(), Never>()
Expand Down Expand Up @@ -60,7 +57,6 @@ final class AppDelegateViewModelTests: TestCase {
self.vm.outputs.applicationIconBadgeNumber.observe(self.applicationIconBadgeNumber.observer)
self.vm.outputs.configureAppCenterWithData.observe(self.configureAppCenterWithData.observer)
self.vm.outputs.configureFirebase.observe(self.configureFirebase.observer)
self.vm.outputs.configurePerimeterX.observe(self.configurePerimeterX.observer)
self.vm.outputs.configureSegmentWithBraze.observe(self.configureSegmentWithBraze.observer)
self.vm.outputs.emailVerificationCompleted.map(first)
.observe(self.emailVerificationCompletedMessage.observer)
Expand Down Expand Up @@ -144,12 +140,6 @@ final class AppDelegateViewModelTests: TestCase {
self.configureFirebase.assertValueCount(1)
}

func testConfigurePerimeterX() {
self.vm.inputs.applicationDidFinishLaunching(application: UIApplication.shared, launchOptions: nil)

self.configurePerimeterX.assertValueCount(1)
}

// MARK: - AppCenter

func testConfigureAppCenter_AlphaApp_LoggedOut() {
Expand Down
4 changes: 0 additions & 4 deletions Kickstarter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@
4753C774264DC17900BB10B6 /* PostCommentMutation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4753C773264DC17900BB10B6 /* PostCommentMutation.swift */; };
4753C78F264EE1B100BB10B6 /* PostCommentInputTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4753C78E264EE1B100BB10B6 /* PostCommentInputTests.swift */; };
47554A5B2727314E003A0D45 /* ProjectFAQsAskAQuestionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47554A5A2727314E003A0D45 /* ProjectFAQsAskAQuestionCell.swift */; };
47567A5D25E40E500073AD6E /* ErrorHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 47567A5C25E40E500073AD6E /* ErrorHandler.swift */; };
4758484E26B31CF8005AAC1C /* FetchUserBackings.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 4758484D26B31CF8005AAC1C /* FetchUserBackings.graphql */; };
4758485026B32110005AAC1C /* GraphAPI.BackingState+BackingState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4758484F26B32110005AAC1C /* GraphAPI.BackingState+BackingState.swift */; };
475DEC0126B07BB9001B961B /* CancelBacking.graphql in Resources */ = {isa = PBXBuildFile; fileRef = 475DEC0026B07BB9001B961B /* CancelBacking.graphql */; };
Expand Down Expand Up @@ -1951,7 +1950,6 @@
4753C773264DC17900BB10B6 /* PostCommentMutation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCommentMutation.swift; sourceTree = "<group>"; };
4753C78E264EE1B100BB10B6 /* PostCommentInputTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCommentInputTests.swift; sourceTree = "<group>"; };
47554A5A2727314E003A0D45 /* ProjectFAQsAskAQuestionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectFAQsAskAQuestionCell.swift; sourceTree = "<group>"; };
47567A5C25E40E500073AD6E /* ErrorHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorHandler.swift; sourceTree = "<group>"; };
4758484D26B31CF8005AAC1C /* FetchUserBackings.graphql */ = {isa = PBXFileReference; lastKnownFileType = text; path = FetchUserBackings.graphql; sourceTree = "<group>"; };
4758484F26B32110005AAC1C /* GraphAPI.BackingState+BackingState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "GraphAPI.BackingState+BackingState.swift"; sourceTree = "<group>"; };
475D16F22773A944009E4354 /* HTMLParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTMLParser.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -6576,7 +6574,6 @@
isa = PBXGroup;
children = (
D01587531EEB2DE4006E7684 /* Info.plist */,
47567A5C25E40E500073AD6E /* ErrorHandler.swift */,
8ADCCD4E2654281E0079D308 /* GraphAPI.swift */,
D08CD1BF21910C97009F89F0 /* GraphIDBridging.swift */,
775DFA9C215E758400620CED /* GraphMutation.swift */,
Expand Down Expand Up @@ -8675,7 +8672,6 @@
D01588C91EEB2ED7006E7684 /* RewardLenses.swift in Sources */,
478E31C326C1C8A8004BF898 /* WatchProjectResponseEnvelope+UnwatchProjectMutation.Data.swift in Sources */,
19047FC92889BD8100BDD1A8 /* ClientSecretEnvelope+CreateSetupIntentMutation.Data.swift in Sources */,
47567A5D25E40E500073AD6E /* ErrorHandler.swift in Sources */,
77CD894921791B05003066DA /* ProjectStatsTemplate.swift in Sources */,
D01588B11EEB2ED7006E7684 /* ProjectLenses.swift in Sources */,
D777442F217A3382008D679F /* ChangeCurrencyInput.swift in Sources */,
Expand Down
13 changes: 0 additions & 13 deletions KsApi/ErrorHandler.swift

This file was deleted.

13 changes: 5 additions & 8 deletions KsApi/Service+RequestHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ extension Service {

return Service.session.rac_dataResponse(
preparedRequest(forURL: URL, method: properties.method, query: properties.query),
uploading: properties.file.map { ($1, $0.rawValue) },
and: nil
uploading: properties.file.map { ($1, $0.rawValue) }
)
.flatMap(self.decodeModelToSignal)
}
Expand All @@ -36,8 +35,7 @@ extension Service {

return Service.session.combine_dataResponse(
preparedRequest(forURL: URL, method: properties.method, query: properties.query),
uploading: properties.file.map { ($1, $0.rawValue) },
and: nil
uploading: properties.file.map { ($1, $0.rawValue) }
).handle_combine_dataResponse(service: self)
}

Expand All @@ -56,8 +54,7 @@ extension Service {

return Service.session.combine_dataResponse(
preparedRequest,
uploading: properties.file.map { ($1, $0.rawValue) },
and: nil
uploading: properties.file.map { ($1, $0.rawValue) }
).handle_combine_dataResponse(service: self)
}

Expand All @@ -68,7 +65,7 @@ extension Service {
}

return Service.session
.rac_dataResponse(preparedRequest(forURL: paginationUrl), and: nil)
.rac_dataResponse(preparedRequest(forURL: paginationUrl))
.flatMap(self.decodeModelToSignal)
}

Expand All @@ -79,7 +76,7 @@ extension Service {
}

return Service.session
.combine_dataResponse(preparedRequest(forURL: paginationUrl), and: nil)
.combine_dataResponse(preparedRequest(forURL: paginationUrl))
.handle_combine_dataResponse(service: self)
}
}
Expand Down
12 changes: 4 additions & 8 deletions KsApi/ServiceTypeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ final class ServiceTypeTests: XCTestCase {
),
language: "ksr",
buildVersion: "1234567890",
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF",
perimeterXClient: PerimeterXClient.mock
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF"
)

private let anonAdHocService = Service(
Expand All @@ -39,8 +38,7 @@ final class ServiceTypeTests: XCTestCase {
),
graphQLEndpointUrl: URL(string: "http://ksr.dev/graph")!
),
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF",
perimeterXClient: PerimeterXClient.mock
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF"
)

private let anonService = Service(
Expand All @@ -54,8 +52,7 @@ final class ServiceTypeTests: XCTestCase {
basicHTTPAuth: nil,
graphQLEndpointUrl: URL(string: "http://ksr.dev/graph")!
),
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF",
perimeterXClient: PerimeterXClient.mock
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF"
)

func testEquals() {
Expand Down Expand Up @@ -253,8 +250,7 @@ final class ServiceTypeTests: XCTestCase {
),
graphQLEndpointUrl: URL(string: "http://ksr.dev/graph")!
),
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF",
perimeterXClient: PerimeterXClient.mock
deviceIdentifier: "DEADBEEF-DEAD-BEEF-DEAD-DEADBEEFBEEF"
)

let url = URL(string: "http://api.ksr.com/v1/test?key=value")!
Expand Down
17 changes: 6 additions & 11 deletions KsApi/extensions/NSURLSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ internal extension URLSession {
}

// Wrap an URLSession producer with error envelope logic.
func rac_dataResponse(_ request: URLRequest, uploading file: (url: URL, name: String)? = nil,
and error: ErrorHandler? = nil)
func rac_dataResponse(_ request: URLRequest, uploading file: (url: URL, name: String)? = nil)
-> SignalProducer<Data, ErrorEnvelope> {
let producer = file.map { self.rac_requestWithFileUpload(request, uploading: $0, named: $1) }
?? self.reactive.data(with: request)
Expand All @@ -35,9 +34,6 @@ internal extension URLSession {
.flatMap(.concat) { data, response -> SignalProducer<Data, ErrorEnvelope> in
guard let response = response as? HTTPURLResponse else { fatalError() }

guard [nil, false].contains(error?.handleResponse(data: data, response: response))
else { return .empty }

guard self.isValidResponse(response: response) else {
if let json = parseJSONData(data) as? [String: Any] {
do {
Expand All @@ -61,8 +57,11 @@ internal extension URLSession {
}
}

func combine_dataResponse(_ request: URLRequest, uploading file: (url: URL, name: String)? = nil,
and error: ErrorHandler? = nil) -> AnyPublisher<Data, ErrorEnvelope> {
func combine_dataResponse(_ request: URLRequest,
uploading file: (url: URL, name: String)? = nil) -> AnyPublisher<
Data,
ErrorEnvelope
> {
let producer = file != nil ? self
.combine_requestWithFileUpload(request, uploading: file!.url, named: file!.name) :
DataTaskPublisher(request: request, session: self).eraseToAnyPublisher()
Expand All @@ -74,10 +73,6 @@ internal extension URLSession {
fatalError()
}

guard [nil, false].contains(error?.handleResponse(data: data, response: response)) else {
return Empty(outputType: Data.self, failureType: ErrorEnvelope.self).eraseToAnyPublisher()
}

guard self.isValidResponse(response: response) else {
if let json = parseJSONData(data) as? [String: Any] {
do {
Expand Down

0 comments on commit 85c1ee3

Please sign in to comment.