Skip to content

Commit bac1029

Browse files
authored
Merge pull request #4123 from wmathurin/W-23201582-app-attestation-dev-info
feat(W-23201582): surface App Attestation state in developer info screen
2 parents 6ff5cdb + 642283d commit bac1029

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,24 @@ - (NSString *)devInfoTitleString
710710
]];
711711
}
712712

713+
// section:App Attestation — app attestation observability
714+
[devInfos addObject:@"section:App Attestation"];
715+
{
716+
SFUserAccount *aaUser = [SFUserAccountManager sharedInstance].currentUser;
717+
BOOL attestationEnabled = [SFUserAccountManager sharedInstance].appAttestationEnabled;
718+
NSString *aaFeatureFlag;
719+
if (!aaUser) {
720+
aaFeatureFlag = @"N/A";
721+
} else {
722+
NSSet<NSString *> *features = [SFSDKAppFeatureMarkers appFeaturesForUser:aaUser];
723+
aaFeatureFlag = [features containsObject:kSFAppFeatureAppAttestation] ? @"YES" : @"NO";
724+
}
725+
[devInfos addObjectsFromArray:@[
726+
@"Attestation Enabled", attestationEnabled ? @"YES" : @"NO",
727+
@"Used in Last Auth", aaFeatureFlag
728+
]];
729+
}
730+
713731
return devInfos;
714732
}
715733

libs/SalesforceSDKCore/SalesforceSDKCoreTests/DevInfoViewControllerTests.swift

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,68 @@ class DevInfoViewControllerTests: XCTestCase {
517517
XCTAssertEqual(view.sections[2].rows[2].headline, "Scopes")
518518
XCTAssertEqual(view.sections[2].rows[2].text, "api web refresh_token")
519519
}
520+
521+
// MARK: - App Attestation section tests
522+
523+
func testAppAttestationSection_DisabledNoUser() {
524+
let infoData = [
525+
"section:App Attestation",
526+
"Attestation Enabled", "NO",
527+
"Used in Last Auth", "N/A"
528+
]
529+
let sections = DevInfoView.testExtractSections(from: infoData)
530+
531+
XCTAssertEqual(sections.count, 1)
532+
let rows = sections[0].rows
533+
XCTAssertEqual(sections[0].title, "App Attestation")
534+
XCTAssertEqual(rows.first(where: { $0.headline == "Attestation Enabled" })?.text, "NO")
535+
XCTAssertEqual(rows.first(where: { $0.headline == "Used in Last Auth" })?.text, "N/A")
536+
}
537+
538+
func testAppAttestationSection_DisabledWithUser_NoFlag() {
539+
let infoData = [
540+
"section:App Attestation",
541+
"Attestation Enabled", "NO",
542+
"Used in Last Auth", "NO"
543+
]
544+
let sections = DevInfoView.testExtractSections(from: infoData)
545+
546+
XCTAssertEqual(sections.count, 1)
547+
let rows = sections[0].rows
548+
XCTAssertEqual(rows.first(where: { $0.headline == "Attestation Enabled" })?.text, "NO")
549+
XCTAssertEqual(rows.first(where: { $0.headline == "Used in Last Auth" })?.text, "NO")
550+
}
551+
552+
func testAppAttestationSection_EnabledWithFeatureFlag() {
553+
let infoData = [
554+
"section:App Attestation",
555+
"Attestation Enabled", "YES",
556+
"Used in Last Auth", "YES"
557+
]
558+
let sections = DevInfoView.testExtractSections(from: infoData)
559+
560+
XCTAssertEqual(sections.count, 1)
561+
let rows = sections[0].rows
562+
XCTAssertEqual(rows.first(where: { $0.headline == "Attestation Enabled" })?.text, "YES")
563+
XCTAssertEqual(rows.first(where: { $0.headline == "Used in Last Auth" })?.text, "YES")
564+
}
565+
566+
func testAppAttestationSection_AppearsAfterRtrSection() {
567+
let infoData = [
568+
"section:RTR",
569+
"RTR Active", "NO",
570+
"Last Rotation", "Never",
571+
"section:App Attestation",
572+
"Attestation Enabled", "NO",
573+
"Used in Last Auth", "N/A"
574+
]
575+
let sections = DevInfoView.testExtractSections(from: infoData)
576+
577+
XCTAssertEqual(sections.count, 2)
578+
XCTAssertEqual(sections[0].title, "RTR")
579+
XCTAssertEqual(sections[1].title, "App Attestation")
580+
XCTAssertEqual(sections[1].rows.count, 2)
581+
}
520582
}
521583

522584
// MARK: - Test Helper Extension

0 commit comments

Comments
 (0)