Skip to content

Commit 7aa9fa7

Browse files
committed
Keep sending notification with UserAccountManager, test clean up
1 parent 4224e15 commit 7aa9fa7

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

libs/SalesforceSDKCore/SalesforceSDKCore/Classes/OAuth/SFOAuthSessionRefresher.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ - (void)completeWithSuccess {
118118
SFOAuthInfo *authInfo = [[SFOAuthInfo alloc] initWithAuthType:SFOAuthTypeRefresh];
119119
[userInfo setValue:authInfo forKey:kSFNotificationUserInfoAuthTypeKey];
120120
[[NSNotificationCenter defaultCenter] postNotificationName:kSFNotificationUserDidRefreshToken
121-
object:self
121+
object:[SFUserAccountManager sharedInstance]
122122
userInfo:userInfo];
123123
self.completionBlock(self.credentials);
124124
}

libs/SalesforceSDKCore/SalesforceSDKCoreTests/SFSDKAuthUtilTests.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ class SFSDKAuthUtilTests: XCTestCase {
189189
XCTAssertNotEqual(account.credentials.accessToken, originalAccessToken,
190190
"Access token should be rotated after refresh")
191191
XCTAssertNotNil(account.credentials.refreshToken)
192-
print("original refresh token: \(originalRefreshToken)")
193-
print("current refresh token: \(account.credentials.refreshToken)")
194192
XCTAssertNotEqual(account.credentials.refreshToken, originalRefreshToken,
195193
"Refresh token should be rotated after refresh")
196194
}
@@ -242,7 +240,7 @@ class SFSDKAuthUtilTests: XCTestCase {
242240
let notificationCount = Mutex<Int>(0)
243241

244242
let observer = NotificationCenter.default.addObserver(
245-
forName: .init(rawValue: "SFNotificationOAuthUserDidRefreshToken"),
243+
forName: UserAccountManager.didRefreshToken,
246244
object: nil,
247245
queue: nil
248246
) { _ in

libs/SalesforceSDKCore/SalesforceSDKCoreTests/SFSDKTokenRefreshCoordinatorTests.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ - (void)refreshSessionWithCompletion:(void (^)(SFOAuthCredentials *))completionB
9595

9696
NSMutableDictionary *userInfo = [NSMutableDictionary new];
9797
[[NSNotificationCenter defaultCenter] postNotificationName:kSFNotificationUserDidRefreshToken
98-
object:self
98+
object:[SFUserAccountManager sharedInstance]
9999
userInfo:userInfo];
100100
if (completionBlock) {
101101
completionBlock(self.credentials);
@@ -584,6 +584,9 @@ - (void)testIntegrationSingleNetworkCallForConcurrentRefreshes {
584584

585585
[self waitForExpectationsWithTimeout:5.0 handler:nil];
586586

587+
// Guard: verify the mock was actually exercised (not vacuously passing)
588+
XCTAssertGreaterThan(mockClient.accessTokenForRefreshCallCount, 0,
589+
@"Mock authClient was never called — the test is not exercising the intended path");
587590
// THE KEY ASSERTION: Only one network call was made
588591
XCTAssertEqual(mockClient.accessTokenForRefreshCallCount, 1,
589592
@"Only one accessTokenForRefresh: call should have been made despite 5 concurrent callers");

0 commit comments

Comments
 (0)