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..56eafd75c 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(String(describing: reason), description) + } + } func testEmailPersistence() { let internalAPI = InternalIterableAPI.initializeForTesting()