Exclude interactive login from v2 (#852)
This commit is contained in:
parent
1dfb013115
commit
4ac524eb01
|
@ -42,9 +42,14 @@ public enum AppFeature: String, CaseIterable {
|
||||||
|
|
||||||
case sharing
|
case sharing
|
||||||
|
|
||||||
public static let allButAppleTV: [AppFeature] = allCases.filter {
|
public static let fullV2Features: [AppFeature] = [
|
||||||
$0 != .appleTV
|
.dns,
|
||||||
}
|
.httpProxy,
|
||||||
|
.onDemand,
|
||||||
|
.providers,
|
||||||
|
.routing,
|
||||||
|
.sharing
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
extension AppFeature: Identifiable {
|
extension AppFeature: Identifiable {
|
||||||
|
|
|
@ -35,10 +35,10 @@ extension AppUserLevel: AppFeatureProviding {
|
||||||
case .beta:
|
case .beta:
|
||||||
return [.interactiveLogin, .sharing]
|
return [.interactiveLogin, .sharing]
|
||||||
|
|
||||||
case .fullVersion:
|
case .fullV2:
|
||||||
return AppFeature.allButAppleTV
|
return AppFeature.fullV2Features
|
||||||
|
|
||||||
case .fullVersionPlusTV:
|
case .subscriber:
|
||||||
return AppFeature.allCases
|
return AppFeature.allCases
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -71,18 +71,18 @@ extension AppProduct: AppFeatureProviding {
|
||||||
return [.onDemand]
|
return [.onDemand]
|
||||||
|
|
||||||
case .Full.allPlatforms:
|
case .Full.allPlatforms:
|
||||||
return AppFeature.allButAppleTV
|
return AppFeature.fullV2Features
|
||||||
|
|
||||||
case .Full.iOS:
|
case .Full.iOS:
|
||||||
#if os(iOS)
|
#if os(iOS)
|
||||||
return AppFeature.allButAppleTV
|
return AppFeature.fullV2Features
|
||||||
#else
|
#else
|
||||||
return []
|
return []
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case .Full.macOS:
|
case .Full.macOS:
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
return AppFeature.allButAppleTV
|
return AppFeature.fullV2Features
|
||||||
#else
|
#else
|
||||||
return []
|
return []
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -32,13 +32,13 @@ public enum AppUserLevel: Int, Sendable {
|
||||||
|
|
||||||
case beta = 1
|
case beta = 1
|
||||||
|
|
||||||
case fullVersion = 2
|
case fullV2 = 2
|
||||||
|
|
||||||
case fullVersionPlusTV = 3
|
case subscriber = 3
|
||||||
|
|
||||||
var isFullVersion: Bool {
|
var isFullVersion: Bool {
|
||||||
switch self {
|
switch self {
|
||||||
case .fullVersion, .fullVersionPlusTV:
|
case .fullV2, .subscriber:
|
||||||
return true
|
return true
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -53,7 +53,7 @@ extension IAPManagerTests {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertTrue(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertTrue(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenBuildProducts_whenNewer_thenFreeVersion() async {
|
func test_givenBuildProducts_whenNewer_thenFreeVersion() async {
|
||||||
|
@ -66,7 +66,7 @@ extension IAPManagerTests {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: Eligibility
|
// MARK: Eligibility
|
||||||
|
@ -75,13 +75,13 @@ extension IAPManagerTests {
|
||||||
let reader = MockAppReceiptReader()
|
let reader = MockAppReceiptReader()
|
||||||
let sut = IAPManager(receiptReader: reader)
|
let sut = IAPManager(receiptReader: reader)
|
||||||
|
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
|
|
||||||
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.allPlatforms])
|
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.allPlatforms])
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertTrue(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertTrue(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenPurchasedFeatures_thenIsOnlyEligibleForFeatures() async {
|
func test_givenPurchasedFeatures_thenIsOnlyEligibleForFeatures() async {
|
||||||
|
@ -97,7 +97,7 @@ extension IAPManagerTests {
|
||||||
XCTAssertFalse(sut.isEligible(for: .onDemand))
|
XCTAssertFalse(sut.isEligible(for: .onDemand))
|
||||||
XCTAssertTrue(sut.isEligible(for: .routing))
|
XCTAssertTrue(sut.isEligible(for: .routing))
|
||||||
XCTAssertFalse(sut.isEligible(for: .sharing))
|
XCTAssertFalse(sut.isEligible(for: .sharing))
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenPurchasedAndCancelledFeature_thenIsNotEligible() async {
|
func test_givenPurchasedAndCancelledFeature_thenIsNotEligible() async {
|
||||||
|
@ -110,7 +110,7 @@ extension IAPManagerTests {
|
||||||
let sut = IAPManager(receiptReader: reader)
|
let sut = IAPManager(receiptReader: reader)
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenFreeVersion_thenIsNotEligibleForAnyFeature() async {
|
func test_givenFreeVersion_thenIsNotEligibleForAnyFeature() async {
|
||||||
|
@ -120,7 +120,7 @@ extension IAPManagerTests {
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertFalse(sut.userLevel.isFullVersion)
|
XCTAssertFalse(sut.userLevel.isFullVersion)
|
||||||
AppFeature.allButAppleTV.forEach {
|
AppFeature.fullV2Features.forEach {
|
||||||
XCTAssertFalse(sut.isEligible(for: $0))
|
XCTAssertFalse(sut.isEligible(for: $0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,16 +134,24 @@ extension IAPManagerTests {
|
||||||
XCTAssertFalse(sut.isEligible(for: .appleTV))
|
XCTAssertFalse(sut.isEligible(for: .appleTV))
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenFullVersion_thenIsEligibleForAnyFeatureExceptAppleTV() async {
|
func test_givenFullV2Version_thenIsEligibleForAnyFeatureExceptExcluded() async {
|
||||||
let reader = MockAppReceiptReader()
|
let reader = MockAppReceiptReader()
|
||||||
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.allPlatforms])
|
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.allPlatforms])
|
||||||
let sut = IAPManager(receiptReader: reader)
|
let sut = IAPManager(receiptReader: reader)
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
AppFeature.allButAppleTV.forEach {
|
let excluded: Set<AppFeature> = [
|
||||||
|
.appleTV,
|
||||||
|
.interactiveLogin
|
||||||
|
]
|
||||||
|
AppFeature.allCases.forEach {
|
||||||
|
if AppFeature.fullV2Features.contains($0) {
|
||||||
XCTAssertTrue(sut.isEligible(for: $0))
|
XCTAssertTrue(sut.isEligible(for: $0))
|
||||||
|
} else {
|
||||||
|
XCTAssertTrue(excluded.contains($0))
|
||||||
|
XCTAssertFalse(sut.isEligible(for: $0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
XCTAssertFalse(sut.isEligible(for: .appleTV))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenAppleTV_thenIsEligibleForAppleTV() async {
|
func test_givenAppleTV_thenIsEligibleForAppleTV() async {
|
||||||
|
@ -162,11 +170,11 @@ extension IAPManagerTests {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.macOS, .Features.networkSettings])
|
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.macOS, .Features.networkSettings])
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertTrue(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertTrue(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
#else
|
#else
|
||||||
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.iOS, .Features.networkSettings])
|
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.iOS, .Features.networkSettings])
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertTrue(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertTrue(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,11 +185,11 @@ extension IAPManagerTests {
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.iOS, .Features.networkSettings])
|
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.iOS, .Features.networkSettings])
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
#else
|
#else
|
||||||
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.macOS, .Features.networkSettings])
|
await reader.setReceipt(withBuild: defaultBuildNumber, products: [.Full.macOS, .Features.networkSettings])
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertFalse(sut.isEligible(for: AppFeature.allButAppleTV))
|
XCTAssertFalse(sut.isEligible(for: AppFeature.fullV2Features))
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,39 +232,47 @@ extension IAPManagerTests {
|
||||||
XCTAssertTrue(sut.isEligible(for: eligible))
|
XCTAssertTrue(sut.isEligible(for: eligible))
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenFullApp_thenIsFullVersion() async {
|
func test_givenFullV2App_thenIsFullVersion() async {
|
||||||
let reader = MockAppReceiptReader()
|
let reader = MockAppReceiptReader()
|
||||||
let sut = IAPManager(customUserLevel: .fullVersion, receiptReader: reader)
|
let sut = IAPManager(customUserLevel: .fullV2, receiptReader: reader)
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertTrue(sut.userLevel.isFullVersion)
|
XCTAssertTrue(sut.userLevel.isFullVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenFullPlusTVApp_thenIsFullVersion() async {
|
func test_givenSubscriberApp_thenIsFullVersion() async {
|
||||||
let reader = MockAppReceiptReader()
|
let reader = MockAppReceiptReader()
|
||||||
let sut = IAPManager(customUserLevel: .fullVersionPlusTV, receiptReader: reader)
|
let sut = IAPManager(customUserLevel: .subscriber, receiptReader: reader)
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
XCTAssertTrue(sut.userLevel.isFullVersion)
|
XCTAssertTrue(sut.userLevel.isFullVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenFullApp_thenIsEligibleForAnyFeatureExceptAppleTV() async {
|
func test_givenFullV2App_thenIsEligibleForAnyFeatureExceptExcluded() async {
|
||||||
let reader = MockAppReceiptReader()
|
let reader = MockAppReceiptReader()
|
||||||
let sut = IAPManager(customUserLevel: .fullVersion, receiptReader: reader)
|
let sut = IAPManager(customUserLevel: .fullV2, receiptReader: reader)
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
AppFeature.allButAppleTV.forEach {
|
let excluded: Set<AppFeature> = [
|
||||||
|
.appleTV,
|
||||||
|
.interactiveLogin
|
||||||
|
]
|
||||||
|
AppFeature.allCases.forEach {
|
||||||
|
if AppFeature.fullV2Features.contains($0) {
|
||||||
XCTAssertTrue(sut.isEligible(for: $0))
|
XCTAssertTrue(sut.isEligible(for: $0))
|
||||||
|
} else {
|
||||||
|
XCTAssertTrue(excluded.contains($0))
|
||||||
|
XCTAssertFalse(sut.isEligible(for: $0))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
XCTAssertFalse(sut.isEligible(for: .appleTV))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func test_givenFullPlusTVApp_thenIsEligibleForAnyFeature() async {
|
func test_givenSubscriberApp_thenIsEligibleForAnyFeature() async {
|
||||||
let reader = MockAppReceiptReader()
|
let reader = MockAppReceiptReader()
|
||||||
let sut = IAPManager(customUserLevel: .fullVersionPlusTV, receiptReader: reader)
|
let sut = IAPManager(customUserLevel: .subscriber, receiptReader: reader)
|
||||||
|
|
||||||
await sut.reloadReceipt()
|
await sut.reloadReceipt()
|
||||||
AppFeature.allButAppleTV.forEach {
|
AppFeature.fullV2Features.forEach {
|
||||||
XCTAssertTrue(sut.isEligible(for: $0))
|
XCTAssertTrue(sut.isEligible(for: $0))
|
||||||
}
|
}
|
||||||
XCTAssertTrue(sut.isEligible(for: .appleTV))
|
XCTAssertTrue(sut.isEligible(for: .appleTV))
|
||||||
|
|
Loading…
Reference in New Issue