Skip to content

Commit a8ceed7

Browse files
committed
refactor: extract resetAuthFlags helper in SalesforceSDKManager
Both -init and resetForUITesting set the same auth flags. Extract a private resetAuthFlags instance method so the values are defined once and can't diverge. simulatedDomainDiscoveryResult is reset only in resetForUITesting (it's a test-only property absent from -init).
1 parent fbf14b5 commit a8ceed7

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/Common/SalesforceSDKManager.m

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ + (void)initializeSDKWithClass:(Class)className {
229229
[SalesforceSDKManager sharedManager];
230230
}
231231

232+
- (void)resetAuthFlags {
233+
self.useEphemeralSessionForAdvancedAuth = YES;
234+
self.useWebServerAuthentication = YES;
235+
self.useHybridAuthentication = YES;
236+
self.useDPoP = NO;
237+
self.sdk_forceAdvancedAuthentication = YES;
238+
self.blockSalesforceIntegrationUser = NO;
239+
}
240+
232241
#if DEBUG
233242
+ (void)resetForUITesting {
234243
// 1. Log out all users — clears on-disk account data, DPoP keychain keys, in-memory maps.
@@ -249,14 +258,9 @@ + (void)resetForUITesting {
249258
[storage removeAllLoginHosts];
250259
[storage save];
251260

252-
// 5. Reset all auth flags to the values set in -init.
261+
// 5. Reset all auth flags to their -init defaults.
253262
SalesforceSDKManager *mgr = [SalesforceSDKManager sharedManager];
254-
mgr.useEphemeralSessionForAdvancedAuth = YES;
255-
mgr.useWebServerAuthentication = YES;
256-
mgr.useHybridAuthentication = YES;
257-
mgr.useDPoP = NO;
258-
mgr.sdk_forceAdvancedAuthentication = YES;
259-
mgr.blockSalesforceIntegrationUser = NO;
263+
[mgr resetAuthFlags];
260264
mgr.simulatedDomainDiscoveryResult = nil;
261265
}
262266
#endif
@@ -361,12 +365,7 @@ - (instancetype)init {
361365
[self computeWebViewUserAgent]; // web view user agent is computed asynchronously so very first call to self.userAgentString(...) will be missing it
362366
self.userAgentString = [self defaultUserAgentString];
363367
self.URLCacheType = kSFURLCacheTypeEncrypted;
364-
self.useEphemeralSessionForAdvancedAuth = YES;
365-
self.useWebServerAuthentication = YES;
366-
self.blockSalesforceIntegrationUser = NO;
367-
self.useHybridAuthentication = YES;
368-
self.useDPoP = NO;
369-
self.sdk_forceAdvancedAuthentication = YES;
368+
[self resetAuthFlags];
370369
[self setupServiceConfiguration];
371370
_snapshotViewControllers = [SFSDKSafeMutableDictionary new];
372371
_nativeLoginViewControllers = [SFSDKSafeMutableDictionary new];

0 commit comments

Comments
 (0)