From 4b4305ce6150a6a65a47ecc3ac108d12fd268d74 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Fri, 1 Nov 2024 13:55:30 +0000 Subject: [PATCH] Change subscription manager to use environment variable token --- .../DataBrokerProtectionSubscriptionManaging.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Authentication/DataBrokerProtectionSubscriptionManaging.swift b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Authentication/DataBrokerProtectionSubscriptionManaging.swift index 513b948ac2..0661e3c05d 100644 --- a/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Authentication/DataBrokerProtectionSubscriptionManaging.swift +++ b/LocalPackages/DataBrokerProtection/Sources/DataBrokerProtection/Authentication/DataBrokerProtectionSubscriptionManaging.swift @@ -19,6 +19,7 @@ import Foundation import Subscription import Common +import AppKitExtensions public protocol DataBrokerProtectionSubscriptionManaging { var isUserAuthenticated: Bool { get } @@ -31,12 +32,16 @@ public final class DataBrokerProtectionSubscriptionManager: DataBrokerProtection let subscriptionManager: SubscriptionManager public var isUserAuthenticated: Bool { - return true - subscriptionManager.accountManager.accessToken != nil + accessToken != nil } public var accessToken: String? { - subscriptionManager.accountManager.accessToken + // We use a staging token for privacy pro supplied through a github secret/action + // for PIR end to end tests + if NSApplication.runType == .integrationTests, let token = ProcessInfo.processInfo.environment["PRIVACYPRO_STAGING_TOKEN"] { + return token + } + return subscriptionManager.accountManager.accessToken } public init(subscriptionManager: SubscriptionManager) { @@ -44,7 +49,6 @@ public final class DataBrokerProtectionSubscriptionManager: DataBrokerProtection } public func hasValidEntitlement() async throws -> Bool { - return true switch await subscriptionManager.accountManager.hasEntitlement(forProductName: .dataBrokerProtection, cachePolicy: .reloadIgnoringLocalCacheData) { case let .success(result):