Skip to content

Commit 2d1e82f

Browse files
committed
add migration code
1 parent 7c44268 commit 2d1e82f

5 files changed

Lines changed: 254 additions & 5 deletions

File tree

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1600"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "GoogleSignIn"
19+
BuildableName = "GoogleSignIn"
20+
BlueprintName = "GoogleSignIn"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
<BuildActionEntry
25+
buildForTesting = "YES"
26+
buildForRunning = "YES"
27+
buildForProfiling = "YES"
28+
buildForArchiving = "YES"
29+
buildForAnalyzing = "YES">
30+
<BuildableReference
31+
BuildableIdentifier = "primary"
32+
BlueprintIdentifier = "GoogleSignInSwift"
33+
BuildableName = "GoogleSignInSwift"
34+
BlueprintName = "GoogleSignInSwift"
35+
ReferencedContainer = "container:">
36+
</BuildableReference>
37+
</BuildActionEntry>
38+
</BuildActionEntries>
39+
</BuildAction>
40+
<TestAction
41+
buildConfiguration = "Debug"
42+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
43+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
44+
shouldUseLaunchSchemeArgsEnv = "YES"
45+
shouldAutocreateTestPlan = "YES">
46+
<Testables>
47+
<TestableReference
48+
skipped = "NO">
49+
<BuildableReference
50+
BuildableIdentifier = "primary"
51+
BlueprintIdentifier = "GoogleSignIn-UnitTests"
52+
BuildableName = "GoogleSignIn-UnitTests"
53+
BlueprintName = "GoogleSignIn-UnitTests"
54+
ReferencedContainer = "container:">
55+
</BuildableReference>
56+
</TestableReference>
57+
<TestableReference
58+
skipped = "NO">
59+
<BuildableReference
60+
BuildableIdentifier = "primary"
61+
BlueprintIdentifier = "GoogleSignInSwift-UnitTests"
62+
BuildableName = "GoogleSignInSwift-UnitTests"
63+
BlueprintName = "GoogleSignInSwift-UnitTests"
64+
ReferencedContainer = "container:">
65+
</BuildableReference>
66+
</TestableReference>
67+
</Testables>
68+
</TestAction>
69+
<LaunchAction
70+
buildConfiguration = "Debug"
71+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
72+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
73+
launchStyle = "0"
74+
useCustomWorkingDirectory = "NO"
75+
ignoresPersistentStateOnLaunch = "NO"
76+
debugDocumentVersioning = "YES"
77+
debugServiceExtension = "internal"
78+
allowLocationSimulation = "YES">
79+
</LaunchAction>
80+
<ProfileAction
81+
buildConfiguration = "Release"
82+
shouldUseLaunchSchemeArgsEnv = "YES"
83+
savedToolIdentifier = ""
84+
useCustomWorkingDirectory = "NO"
85+
debugDocumentVersioning = "YES">
86+
<MacroExpansion>
87+
<BuildableReference
88+
BuildableIdentifier = "primary"
89+
BlueprintIdentifier = "GoogleSignIn"
90+
BuildableName = "GoogleSignIn"
91+
BlueprintName = "GoogleSignIn"
92+
ReferencedContainer = "container:">
93+
</BuildableReference>
94+
</MacroExpansion>
95+
</ProfileAction>
96+
<AnalyzeAction
97+
buildConfiguration = "Debug">
98+
</AnalyzeAction>
99+
<ArchiveAction
100+
buildConfiguration = "Release"
101+
revealArchiveInOrganizer = "YES">
102+
</ArchiveAction>
103+
</Scheme>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1600"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "GoogleSignIn"
19+
BuildableName = "GoogleSignIn"
20+
BlueprintName = "GoogleSignIn"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "GoogleSignIn"
54+
BuildableName = "GoogleSignIn"
55+
BlueprintName = "GoogleSignIn"
56+
ReferencedContainer = "container:">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1600"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "GoogleSignInSwift"
19+
BuildableName = "GoogleSignInSwift"
20+
BlueprintName = "GoogleSignInSwift"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
</TestAction>
33+
<LaunchAction
34+
buildConfiguration = "Debug"
35+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37+
launchStyle = "0"
38+
useCustomWorkingDirectory = "NO"
39+
ignoresPersistentStateOnLaunch = "NO"
40+
debugDocumentVersioning = "YES"
41+
debugServiceExtension = "internal"
42+
allowLocationSimulation = "YES">
43+
</LaunchAction>
44+
<ProfileAction
45+
buildConfiguration = "Release"
46+
shouldUseLaunchSchemeArgsEnv = "YES"
47+
savedToolIdentifier = ""
48+
useCustomWorkingDirectory = "NO"
49+
debugDocumentVersioning = "YES">
50+
<MacroExpansion>
51+
<BuildableReference
52+
BuildableIdentifier = "primary"
53+
BlueprintIdentifier = "GoogleSignInSwift"
54+
BuildableName = "GoogleSignInSwift"
55+
BlueprintName = "GoogleSignInSwift"
56+
ReferencedContainer = "container:">
57+
</BuildableReference>
58+
</MacroExpansion>
59+
</ProfileAction>
60+
<AnalyzeAction
61+
buildConfiguration = "Debug">
62+
</AnalyzeAction>
63+
<ArchiveAction
64+
buildConfiguration = "Release"
65+
revealArchiveInOrganizer = "YES">
66+
</ArchiveAction>
67+
</Scheme>

GoogleSignIn/Sources/GIDAuthStateMigration.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ - (void)migrateIfNeededWithTokenURL:(NSURL *)tokenURL
7373
// action and go on to mark the migration check as having been performed.
7474
if (!isFreshInstall) {
7575
GTMAuthSession *authSession = nil;
76-
#if TARGET_OS_MAC || TARGET_OS_MACCATALYST
76+
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
7777
// Migrate from the fileBasedKeychain to dataProtectedKeychain with GTMAppAuth 5.0.
7878
GTMKeychainAttribute *fileBasedKeychain = [GTMKeychainAttribute useFileBasedKeychain];
7979
NSSet *attributes = [NSSet setWithArray:@[fileBasedKeychain]];
8080
GTMKeychainStore *keychainStoreLegacy =
8181
[[GTMKeychainStore alloc] initWithItemName:self.keychainStore.itemName
8282
keychainAttributes:attributes];
8383
authSession = [keychainStoreLegacy retrieveAuthSessionWithError:nil];
84-
#else // TARGET_OS_IOS && !TARGET_OS_MACCATALYST
84+
#elif TARGET_OS_IOS
8585
// Migrate from GPPSignIn 1.x or GIDSignIn 1.0 - 4.x to the GTMAppAuth storage introduced in
8686
// GIDSignIn 5.0.
8787
authSession = [self extractAuthSessionWithTokenURL:tokenURL callbackPath:callbackPath];
@@ -94,7 +94,7 @@ - (void)migrateIfNeededWithTokenURL:(NSURL *)tokenURL
9494
if (err) {
9595
return;
9696
};
97-
#if TARGET_OS_MAC || TARGET_OS_MACCATALYST
97+
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
9898
[keychainStoreLegacy removeAuthSessionWithError:nil];
9999
#endif
100100
}

GoogleSignIn/Tests/Unit/GIDAuthStateMigrationTest.m

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

1717
#import "GoogleSignIn/Sources/GIDAuthStateMigration.h"
1818
#import "GoogleSignIn/Sources/GIDSignInCallbackSchemes.h"
19+
#import "GoogleSignIn/Tests/Unit/OIDAuthState+Testing.h"
1920

2021
@import GTMAppAuth;
2122

@@ -122,12 +123,23 @@ - (void)testMigrateIfNeeded_NoPreviousMigration {
122123
[[[_mockUserDefaults expect] andReturnValue:@NO] boolForKey:kMigrationCheckPerformedKey];
123124
[[_mockUserDefaults expect] setBool:YES forKey:kMigrationCheckPerformedKey];
124125

126+
#if TARGET_OS_OSX || TARGET_OS_MACCATALYST
127+
[[[_mockGTMKeychainStore expect] andReturn:@"auth"] itemName];
128+
[[[_mockGTMKeychainStore expect] andReturn:_mockGTMKeychainStore] initWithItemName:OCMOCK_ANY
129+
keychainAttributes:OCMOCK_ANY];
130+
OIDAuthState *authState = [OIDAuthState testInstance];
131+
GTMAuthSession *authSession = [[GTMAuthSession alloc] initWithAuthState:authState];
132+
[[[_mockGTMKeychainStore expect] andReturn:authSession] retrieveAuthSessionWithError:nil];
133+
// [[[_mockGTMKeychainStore initWithKeychainStore:OCMOCK_ANY] andReturn:_mockGTMKeychainStore];
134+
// [[OCMStub([_mockGTMKeychainStore retrieveAuthSessionWithError:OCMOCK_ANY]) andReturn:(id)];
135+
#endif
136+
125137
[[_mockGTMKeychainStore expect] saveAuthSession:OCMOCK_ANY error:OCMArg.anyObjectRef];
126138

127-
[self setUpCommonExtractAuthorizationMocksWithFingerPrint:kSavedFingerprint];
139+
// [self setUpCommonExtractAuthorizationMocksWithFingerPrint:kSavedFingerprint];
128140

129141
GIDAuthStateMigration *migration =
130-
[[GIDAuthStateMigration alloc] initWithKeychainStore:_mockGTMKeychainStore];
142+
[[GIDAuthStateMigration alloc] initWithKeychainStore:_mockGTMKeychainStore];
131143
[migration migrateIfNeededWithTokenURL:[NSURL URLWithString:kTokenURL]
132144
callbackPath:kCallbackPath
133145
keychainName:kKeychainName

0 commit comments

Comments
 (0)