Skip to content

Commit 2dbd46a

Browse files
committed
update GIDAuthStateMMigration to treat catalyst apps as iOS apps
1 parent 594f8b7 commit 2dbd46a

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

GoogleSignIn/Sources/GIDAuthStateMigration.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,24 @@ - (void)migrateIfNeededWithTokenURL:(NSURL *)tokenURL
7171
// performed.
7272
if (isFreshInstall) {
7373
NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults];
74-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
74+
#if TARGET_OS_OSX
7575
[defaults setBool:YES forKey:kDataProtectedMigrationCheckPerformedKey];
7676
#elif TARGET_OS_IOS
7777
[defaults setBool:YES forKey:kGTMAppAuthMigrationCheckPerformedKey];
78-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
78+
#endif // TARGET_OS_OSX
7979
return;
8080
}
8181

82-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
82+
#if TARGET_OS_OSX
8383
[self performDataProtectedMigrationIfNeeded];
8484
#elif TARGET_OS_IOS
8585
[self performGIDMigrationIfNeededWithTokenURL:tokenURL
8686
callbackPath:callbackPath
8787
keychainName:keychainName];
88-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
88+
#endif // TARGET_OS_OSX
8989
}
9090

91-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
91+
#if TARGET_OS_OSX
9292
// Migrate from the fileBasedKeychain to dataProtectedKeychain with GTMAppAuth 5.0.
9393
- (void)performDataProtectedMigrationIfNeeded {
9494
// See if we've performed the migration check previously.
@@ -246,7 +246,7 @@ + (nullable NSString *)passwordForService:(NSString *)service {
246246
NSString *password = [[NSString alloc] initWithData:passwordData encoding:NSUTF8StringEncoding];
247247
return password;
248248
}
249-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
249+
#endif // TARGET_OS_OSX
250250

251251
@end
252252

GoogleSignIn/Tests/Unit/GIDAuthStateMigrationTest.m

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
#import "GoogleSignIn/Sources/GIDAuthStateMigration.h"
1818
#import "GoogleSignIn/Sources/GIDSignInCallbackSchemes.h"
19-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
19+
#if TARGET_OS_OSX
2020
#import "GoogleSignIn/Tests/Unit/OIDAuthState+Testing.h"
21-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
21+
#endif // TARGET_OS_OSX
2222

2323
@import GTMAppAuth;
2424

@@ -84,9 +84,9 @@ @implementation GIDAuthStateMigrationTest {
8484
id _mockNSBundle;
8585
id _mockGIDSignInCallbackSchemes;
8686
id _mockGTMOAuth2Compatibility;
87-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
87+
#if TARGET_OS_OSX
8888
id _realLegacyGTMKeychainStore;
89-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
89+
#endif // TARGET_OS_OSX
9090
}
9191

9292
- (void)setUp {
@@ -100,12 +100,12 @@ - (void)setUp {
100100
_mockNSBundle = OCMStrictClassMock([NSBundle class]);
101101
_mockGIDSignInCallbackSchemes = OCMStrictClassMock([GIDSignInCallbackSchemes class]);
102102
_mockGTMOAuth2Compatibility = OCMStrictClassMock([GTMOAuth2Compatibility class]);
103-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
103+
#if TARGET_OS_OSX
104104
GTMKeychainAttribute *fileBasedKeychain = [GTMKeychainAttribute useFileBasedKeychain];
105105
NSSet *attributes = [NSSet setWithArray:@[fileBasedKeychain]];
106106
_realLegacyGTMKeychainStore = [[GTMKeychainStore alloc] initWithItemName:kKeychainName
107107
keychainAttributes:attributes];
108-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
108+
#endif // TARGET_OS_OSX
109109
}
110110

111111
- (void)tearDown {
@@ -125,16 +125,16 @@ - (void)tearDown {
125125
[_mockGIDSignInCallbackSchemes stopMocking];
126126
[_mockGTMOAuth2Compatibility verify];
127127
[_mockGTMOAuth2Compatibility stopMocking];
128-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
128+
#if TARGET_OS_OSX
129129
[_realLegacyGTMKeychainStore removeAuthSessionWithError:nil];
130-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
130+
#endif // TARGET_OS_OSX
131131

132132
[super tearDown];
133133
}
134134

135135
#pragma mark - Tests
136136

137-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
137+
#if TARGET_OS_OSX
138138
- (void)testMigrateIfNeeded_NoPreviousMigration_DataProtectedMigration {
139139
[[[_mockUserDefaults stub] andReturn:_mockUserDefaults] standardUserDefaults];
140140
[[[_mockUserDefaults expect] andReturnValue:@NO] boolForKey:kDataProtectedMigrationCheckPerformedKey];
@@ -242,17 +242,17 @@ - (void)testExtractAuthorization_HostedDomain {
242242

243243
XCTAssertNotNil(authorization);
244244
}
245-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
245+
#endif // TARGET_OS_OSX
246246

247247
- (void)testMigrateIfNeeded_HasPreviousMigration {
248248
[[[_mockUserDefaults stub] andReturn:_mockUserDefaults] standardUserDefaults];
249-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
249+
#if TARGET_OS_OSX
250250
[[[_mockUserDefaults expect] andReturnValue:@YES] boolForKey:kDataProtectedMigrationCheckPerformedKey];
251251
[[_mockUserDefaults reject] setBool:YES forKey:kDataProtectedMigrationCheckPerformedKey];
252252
#else
253253
[[[_mockUserDefaults expect] andReturnValue:@YES] boolForKey:kGTMAppAuthMigrationCheckPerformedKey];
254254
[[_mockUserDefaults reject] setBool:YES forKey:kGTMAppAuthMigrationCheckPerformedKey];
255-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
255+
#endif // TARGET_OS_OSX
256256

257257
GIDAuthStateMigration *migration =
258258
[[GIDAuthStateMigration alloc] initWithKeychainStore:_mockGTMKeychainStore];
@@ -264,11 +264,11 @@ - (void)testMigrateIfNeeded_HasPreviousMigration {
264264

265265
- (void)testMigrateIfNeeded_isFreshInstall {
266266
[[[_mockUserDefaults stub] andReturn:_mockUserDefaults] standardUserDefaults];
267-
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
267+
#if TARGET_OS_OSX
268268
[[_mockUserDefaults expect] setBool:YES forKey:kDataProtectedMigrationCheckPerformedKey];
269269
#else
270270
[[_mockUserDefaults expect] setBool:YES forKey:kGTMAppAuthMigrationCheckPerformedKey];
271-
#endif // TARGET_OS_OSX || TARGET_OS_MACCATALYST
271+
#endif // TARGET_OS_OSX
272272

273273
GIDAuthStateMigration *migration =
274274
[[GIDAuthStateMigration alloc] initWithKeychainStore:_mockGTMKeychainStore];

0 commit comments

Comments
 (0)