Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,23 @@ + (SFSDKTestCredentialsData *)populateAuthCredentialsFromString:(NSString *)test
}

+ (void)synchronousAuthRefresh {
[self synchronousAuthRefreshWithUserDidLoginNotification:NO];
[self synchronousAuthRefreshWithRetries:3];
}

+ (void)synchronousAuthRefreshWithRetries:(NSInteger)maxRetries {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvement — Auth resilience for class setUp.

CI runs showed that when the test org is briefly unreachable during +setUp, ALL tests in SalesforceRestAPITests cascade-fail (50+ tests report "Setting up authentication failed"). This was the single most common failure pattern in overnight CI.

This adds a 3-attempt retry with 3s backoff. After exhausting attempts, it still throws — the test suite still fails if auth is genuinely broken. The NSLog on each retry provides CI visibility into recovery frequency.

Same end-state assertion: auth must succeed or the suite aborts.

This response was generated by an AI agent on behalf of @JohnsonEricAtSalesforce.

for (NSInteger attempt = 1; attempt <= maxRetries; attempt++) {
@try {
[self synchronousAuthRefreshWithUserDidLoginNotification:NO];
return;
} @catch (NSException *exception) {
if (attempt < maxRetries) {
NSLog(@"[TestSetupUtils] Auth refresh attempt %ld failed: %@. Retrying in 3s...", (long)attempt, exception.reason);
[NSThread sleepForTimeInterval:3.0];
} else {
@throw;
}
}
}
}

+ (void)synchronousAuthRefreshWithUserDidLoginNotification:(BOOL)postUserDidLogIn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class SFSDKAuthUtilTests: XCTestCase {
endpointResponse = response
expectation.fulfill()
}
self.wait(for: [expectation], timeout: 30)
self.wait(for: [expectation], timeout: 60)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timeout increase — same assertion, accommodates CI org load.

testAccessToken hits the live org's token endpoint. In CI runs with parallel test execution across iOS 18 + iOS 26 (4 simultaneous jobs hitting the same org), the endpoint regularly exceeded 30s. The test still asserts the same outcome (valid token, no error) — it just allows more time for the server to respond.

This response was generated by an AI agent on behalf of @JohnsonEricAtSalesforce.

let response = try XCTUnwrap(endpointResponse)
XCTAssertFalse(response.hasError)
XCTAssertNotNil(response.accessToken)
Expand Down
Loading
Loading