From 49284d57ce15df718b88d8e895300c63c42655a9 Mon Sep 17 00:00:00 2001 From: Sumeru Chatterjee Date: Fri, 5 Jun 2026 13:09:39 +0100 Subject: [PATCH 1/2] SDK-470 Add CustomDebugStringConvertible to AuthFailureReason AuthFailureReason is an Int-backed @objc enum, so logging an instance prints a raw number. Conform to CustomDebugStringConvertible so logs show the case name instead. The switch is exhaustive with no default, so adding a future case fails to compile until its label is added. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../Core/Utilities/AuthFailureReason.swift | 29 +++++++++++++++++++ tests/unit-tests/AuthTests.swift | 20 +++++++++++++ 2 files changed, 49 insertions(+) diff --git a/swift-sdk/Core/Utilities/AuthFailureReason.swift b/swift-sdk/Core/Utilities/AuthFailureReason.swift index dd4cff85c..8b40e79e2 100644 --- a/swift-sdk/Core/Utilities/AuthFailureReason.swift +++ b/swift-sdk/Core/Utilities/AuthFailureReason.swift @@ -20,3 +20,32 @@ import Foundation case authTokenGenerationError case authTokenMissing } + +extension AuthFailureReason: CustomDebugStringConvertible { + public var debugDescription: String { + switch self { + case .authTokenExpired: + return "authTokenExpired" + case .authTokenGenericError: + return "authTokenGenericError" + case .authTokenExpirationInvalid: + return "authTokenExpirationInvalid" + case .authTokenSignatureInvalid: + return "authTokenSignatureInvalid" + case .authTokenFormatInvalid: + return "authTokenFormatInvalid" + case .authTokenInvalidated: + return "authTokenInvalidated" + case .authTokenPayloadInvalid: + return "authTokenPayloadInvalid" + case .authTokenUserKeyInvalid: + return "authTokenUserKeyInvalid" + case .authTokenNull: + return "authTokenNull" + case .authTokenGenerationError: + return "authTokenGenerationError" + case .authTokenMissing: + return "authTokenMissing" + } + } +} diff --git a/tests/unit-tests/AuthTests.swift b/tests/unit-tests/AuthTests.swift index 74f5a5d87..bd5a8bab1 100644 --- a/tests/unit-tests/AuthTests.swift +++ b/tests/unit-tests/AuthTests.swift @@ -17,6 +17,26 @@ class AuthTests: XCTestCase { override func setUp() { super.setUp() } + + func testAuthFailureReasonDebugDescriptions() { + let expectedDescriptions: [(AuthFailureReason, String)] = [ + (.authTokenExpired, "authTokenExpired"), + (.authTokenGenericError, "authTokenGenericError"), + (.authTokenExpirationInvalid, "authTokenExpirationInvalid"), + (.authTokenSignatureInvalid, "authTokenSignatureInvalid"), + (.authTokenFormatInvalid, "authTokenFormatInvalid"), + (.authTokenInvalidated, "authTokenInvalidated"), + (.authTokenPayloadInvalid, "authTokenPayloadInvalid"), + (.authTokenUserKeyInvalid, "authTokenUserKeyInvalid"), + (.authTokenNull, "authTokenNull"), + (.authTokenGenerationError, "authTokenGenerationError"), + (.authTokenMissing, "authTokenMissing") + ] + + expectedDescriptions.forEach { reason, description in + XCTAssertEqual(reason.debugDescription, description) + } + } func testEmailPersistence() { let internalAPI = InternalIterableAPI.initializeForTesting() From cf8e2e8231650cd402c7e91c2fb0f67b9058f6e7 Mon Sep 17 00:00:00 2001 From: Sumeru Chatterjee Date: Fri, 12 Jun 2026 14:22:15 +0100 Subject: [PATCH 2/2] SDK-470 Assert String(describing:) in AuthFailureReason test Assert the customer-facing logging output instead of debugDescription directly. print(reason) and "\(reason)" resolve through String(describing:), which falls back to the enum debugDescription, so this guards the case-name output customers see in AuthDelegate logs. Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/unit-tests/AuthTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit-tests/AuthTests.swift b/tests/unit-tests/AuthTests.swift index bd5a8bab1..56eafd75c 100644 --- a/tests/unit-tests/AuthTests.swift +++ b/tests/unit-tests/AuthTests.swift @@ -34,7 +34,7 @@ class AuthTests: XCTestCase { ] expectedDescriptions.forEach { reason, description in - XCTAssertEqual(reason.debugDescription, description) + XCTAssertEqual(String(describing: reason), description) } }