Skip to content

Commit 7c555a0

Browse files
committed
fix(auth): decode MFA unenroll response id field
1 parent 63eec09 commit 7c555a0

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Sources/Auth/Types.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ public typealias AuthMFAVerifyResponse = Session
757757

758758
public struct AuthMFAUnenrollResponse: Decodable, Hashable, Sendable {
759759
/// ID of the factor that was successfully unenrolled.
760-
public let factorId: String
760+
public let id: String
761761
}
762762

763763
public struct AuthMFAListFactorsResponse: Decodable, Hashable, Sendable {

Tests/AuthTests/AuthClientTests.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,8 +1804,8 @@ final class AuthClientTests: XCTestCase {
18041804
func testMFAUnenroll() async throws {
18051805
Mock(
18061806
url: clientURL.appendingPathComponent("factors/123"),
1807-
statusCode: 204,
1808-
data: [.delete: Data(#"{"factor_id":"123"}"#.utf8)]
1807+
statusCode: 200,
1808+
data: [.delete: Data(#"{"id":"123"}"#.utf8)]
18091809
)
18101810
.snapshotRequest {
18111811
#"""
@@ -1824,9 +1824,9 @@ final class AuthClientTests: XCTestCase {
18241824

18251825
Dependencies[sut.clientID].sessionStorage.store(.validSession)
18261826

1827-
let factorId = try await sut.mfa.unenroll(params: .init(factorId: "123")).factorId
1827+
let id = try await sut.mfa.unenroll(params: .init(factorId: "123")).id
18281828

1829-
expectNoDifference(factorId, "123")
1829+
expectNoDifference(id, "123")
18301830
}
18311831

18321832
func testMFAChallengeAndVerify() async throws {
@@ -2229,7 +2229,10 @@ final class AuthClientTests: XCTestCase {
22292229
XCTAssertNil(Dependencies[sut.clientID].sessionStorage.get())
22302230
}
22312231

2232-
func testRemoveSessionAndSignoutIfRefreshTokenNotFoundErrorReturned_withEmitLocalSessionAsInitialSession() async throws {
2232+
func
2233+
testRemoveSessionAndSignoutIfRefreshTokenNotFoundErrorReturned_withEmitLocalSessionAsInitialSession()
2234+
async throws
2235+
{
22332236
let sut = makeSUT(emitLocalSessionAsInitialSession: true)
22342237

22352238
Mock(
@@ -2676,7 +2679,9 @@ final class AuthClientTests: XCTestCase {
26762679
XCTAssertNotNil(result.claims.aud)
26772680
}
26782681

2679-
private func makeSUT(flowType: AuthFlowType = .pkce, emitLocalSessionAsInitialSession: Bool = false) -> AuthClient {
2682+
private func makeSUT(
2683+
flowType: AuthFlowType = .pkce, emitLocalSessionAsInitialSession: Bool = false
2684+
) -> AuthClient {
26802685
let sessionConfiguration = URLSessionConfiguration.default
26812686
sessionConfiguration.protocolClasses = [MockingURLProtocol.self]
26822687
let session = URLSession(configuration: sessionConfiguration)

0 commit comments

Comments
 (0)