From c30b646974c507601c3b1f978a77f69df846d349 Mon Sep 17 00:00:00 2001 From: Matthew Mathias Date: Wed, 31 Jan 2024 14:54:16 -0800 Subject: [PATCH] Add availability check for useDataProtection in test so all platforms pass --- .../KeychainStore/GTMOAuth2CompatibilityTests.swift | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/GTMAppAuth/Tests/Unit/KeychainStore/GTMOAuth2CompatibilityTests.swift b/GTMAppAuth/Tests/Unit/KeychainStore/GTMOAuth2CompatibilityTests.swift index 26b5562..5245d9f 100644 --- a/GTMAppAuth/Tests/Unit/KeychainStore/GTMOAuth2CompatibilityTests.swift +++ b/GTMAppAuth/Tests/Unit/KeychainStore/GTMOAuth2CompatibilityTests.swift @@ -29,11 +29,15 @@ class GTMOAuth2CompatibilityTests: XCTestCase { private lazy var testPersistenceString: String = { return "access_token=\(TestingConstants.testAccessToken)&refresh_token=\(TestingConstants.testRefreshToken)&scope=\(TestingConstants.testScope2)&serviceProvider=\(TestingConstants.testServiceProvider)&userEmail=foo%40foo.com&userEmailIsVerified=y&userID=\(TestingConstants.testUserID)" }() - private let keychainHelperWithAttributes = KeychainHelperFake( - keychainAttributes: [.useDataProtectionKeychain, - .keychainAccessGroup(name: TestingConstants.testAccessGroup)] - ) private lazy var keychainStoreWithAttributes: KeychainStore = { + let attributes: Set + if #available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) { + attributes = [.useDataProtectionKeychain, + .keychainAccessGroup(name: TestingConstants.testAccessGroup)] + } else { + attributes = [.keychainAccessGroup(name: TestingConstants.testAccessGroup)] + } + let keychainHelperWithAttributes = KeychainHelperFake(keychainAttributes: attributes) return KeychainStore( itemName: TestingConstants.testKeychainItemName, keychainHelper: keychainHelperWithAttributes