mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Create sessions through the user session manager
Sign-in now creates and stores its session through the UserSessionManagerProtocol rather than the UserSessionStore, so the AppCoordinator no longer holds the store. - The manager forwards clientSessionDelegate and userSession(for:sessionDirectories:passphrase:) to its store. As with restoring, the new session isn't registered until the AppCoordinator adds it. - AuthenticationService takes the manager, for both sign-in and soft logout. - The store mock's configuration moves to the manager mock.
This commit is contained in:
@@ -15,7 +15,7 @@ import Testing
|
||||
struct AuthenticationServiceTests {
|
||||
var client: ClientSDKMock!
|
||||
var encryption: EncryptionSDKMock!
|
||||
var userSessionStore: UserSessionStoreMock!
|
||||
var userSessionManager: UserSessionManagerMock!
|
||||
var encryptionKeyProvider: MockEncryptionKeyProvider!
|
||||
var service: AuthenticationService!
|
||||
|
||||
@@ -36,8 +36,8 @@ struct AuthenticationServiceTests {
|
||||
switch await service.login(username: "alice", password: "12345678", initialDeviceName: nil, deviceID: nil) {
|
||||
case .success:
|
||||
#expect(client.loginUsernamePasswordInitialDeviceNameDeviceIdCallsCount == 1)
|
||||
#expect(userSessionStore.userSessionForSessionDirectoriesPassphraseCallsCount == 1)
|
||||
#expect(userSessionStore.userSessionForSessionDirectoriesPassphraseReceivedArguments?.passphrase == encryptionKeyProvider.generateKey())
|
||||
#expect(userSessionManager.userSessionForSessionDirectoriesPassphraseCallsCount == 1)
|
||||
#expect(userSessionManager.userSessionForSessionDirectoriesPassphraseReceivedArguments?.passphrase == encryptionKeyProvider.generateKey())
|
||||
case .failure(let error):
|
||||
Issue.record("Unexpected failure: \(error)")
|
||||
}
|
||||
@@ -138,14 +138,14 @@ struct AuthenticationServiceTests {
|
||||
encryption = EncryptionSDKMock()
|
||||
client.encryptionReturnValue = encryption
|
||||
|
||||
userSessionStore = UserSessionStoreMock(.init())
|
||||
userSessionManager = UserSessionManagerMock(.init())
|
||||
encryptionKeyProvider = MockEncryptionKeyProvider()
|
||||
|
||||
let classicAppManager = ClassicAppManagerMock(.init(accounts: classicAppAccounts,
|
||||
availableSecrets: availableSecrets,
|
||||
secretsBundle: SecretsBundleWithUserIdSDKMock()))
|
||||
|
||||
service = AuthenticationService(userSessionStore: userSessionStore,
|
||||
service = AuthenticationService(userSessionManager: userSessionManager,
|
||||
encryptionKeyProvider: encryptionKeyProvider,
|
||||
classicAppManager: classicAppManager,
|
||||
clientFactory: clientFactory,
|
||||
|
||||
@@ -296,7 +296,7 @@ final class AuthenticationStartScreenViewModelTests {
|
||||
notificationCenter = NotificationCenter()
|
||||
|
||||
clientFactory = ClientFactoryMock(configuration)
|
||||
authenticationService = AuthenticationService(userSessionStore: UserSessionStoreMock(.init()),
|
||||
authenticationService = AuthenticationService(userSessionManager: UserSessionManagerMock(.init()),
|
||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||
classicAppManager: classicAppManager,
|
||||
clientFactory: clientFactory,
|
||||
|
||||
@@ -230,7 +230,7 @@ struct LoginScreenViewModelTests {
|
||||
let appSettings = AppSettings.volatile()
|
||||
|
||||
clientFactory = ClientFactoryMock(.init())
|
||||
service = AuthenticationService(userSessionStore: UserSessionStoreMock(.init()),
|
||||
service = AuthenticationService(userSessionManager: UserSessionManagerMock(.init()),
|
||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||
classicAppManager: nil,
|
||||
clientFactory: clientFactory,
|
||||
|
||||
@@ -363,7 +363,7 @@ struct ServerSelectionScreenViewModelTests {
|
||||
client = factoryConfiguration.homeserverClients["matrix.org"]
|
||||
clientFactory = ClientFactoryMock(factoryConfiguration)
|
||||
|
||||
service = AuthenticationService(userSessionStore: UserSessionStoreMock(.init()),
|
||||
service = AuthenticationService(userSessionManager: UserSessionManagerMock(.init()),
|
||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||
classicAppManager: nil,
|
||||
clientFactory: clientFactory,
|
||||
|
||||
Reference in New Issue
Block a user