Merge the AuthenticationService with the QRCodeLoginService. (#4323)

* Merge the AuthenticationServer with the QRCodeLoginService.

* Merge AuthenticationClientBuilderFactory and AuthenticationClientBuilder into AuthenticationClientFactory

The separation is no longer needed now that password/OIDC login and QR code login have a similar API shape.
This commit is contained in:
Doug
2025-07-15 17:59:15 +01:00
committed by GitHub
parent 17000687b5
commit 448bc2d4e3
20 changed files with 275 additions and 502 deletions
@@ -8,15 +8,39 @@
import Foundation
import MatrixRustSDK
extension AuthenticationClientBuilderFactoryMock {
extension AuthenticationClientFactoryMock {
struct Configuration {
var builderConfiguration: AuthenticationClientBuilderMock.Configuration = .init()
var homeserverClients = [
"matrix.org": ClientSDKMock(configuration: .init()),
"example.com": ClientSDKMock(configuration: .init(serverAddress: "example.com",
homeserverURL: "https://matrix.example.com",
slidingSyncVersion: .native,
oidcLoginURL: nil,
supportsOIDCCreatePrompt: false,
supportsPasswordLogin: true)),
"company.com": ClientSDKMock(configuration: .init(serverAddress: "company.com",
homeserverURL: "https://matrix.company.com",
slidingSyncVersion: .native,
oidcLoginURL: "https://auth.company.com/oidc",
supportsOIDCCreatePrompt: false,
supportsPasswordLogin: false)),
"server.net": ClientSDKMock(configuration: .init(serverAddress: "server.net",
homeserverURL: "https://matrix.example.com",
slidingSyncVersion: .native,
oidcLoginURL: nil,
supportsOIDCCreatePrompt: false,
supportsPasswordLogin: false))
]
}
convenience init(configuration: Configuration) {
self.init()
let clientBuilder = AuthenticationClientBuilderMock(configuration: configuration.builderConfiguration)
makeBuilderSessionDirectoriesPassphraseClientSessionDelegateAppSettingsAppHooksReturnValue = clientBuilder
makeClientHomeserverAddressSessionDirectoriesPassphraseClientSessionDelegateAppSettingsAppHooksClosure = { address, _, _, _, _, _ in
guard let client = configuration.homeserverClients[address] else {
throw ClientBuildError.ServerUnreachable(message: "Not a known homeserver.")
}
return client
}
}
}