mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Add an AccountProvider type and use it within the authentication flow. (#6103)
* Add an AccountProvider type and use it within AppSettings. * Use the AccountProvider type within the Authentication flow too. * Fix unit test compilation with Swift 6.4 * Make sure defaultAccountProvider takes allowOtherAccountProviders into account. * Document a caveat on using AuthenticationService.homeserver.value.accountProvider.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
@testable import ElementX
|
||||
import Testing
|
||||
|
||||
struct AppSettingsTests {
|
||||
@Test
|
||||
func defaultAccountProvider() {
|
||||
let appSettings = AppSettings.volatile()
|
||||
#expect(appSettings.defaultAccountProvider == appSettings.accountProviders[0])
|
||||
|
||||
appSettings.previousServers = ["example.com"]
|
||||
#expect(appSettings.defaultAccountProvider == .generic("example.com"))
|
||||
|
||||
appSettings.override(allowOtherAccountProviders: false)
|
||||
#expect(appSettings.defaultAccountProvider == appSettings.accountProviders[0])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
private extension AppSettings {
|
||||
func override(allowOtherAccountProviders: Bool) {
|
||||
override(accountProviders: accountProviders,
|
||||
allowOtherAccountProviders: allowOtherAccountProviders,
|
||||
hideBrandChrome: hideBrandChrome,
|
||||
pushGatewayBaseURL: pushGatewayBaseURL,
|
||||
oAuthRedirectURL: oAuthRedirectURL,
|
||||
oAuthClientURIPath: oAuthClientURIPath,
|
||||
websiteURL: websiteURL,
|
||||
logoURL: logoURL,
|
||||
copyrightURL: copyrightURL,
|
||||
acceptableUseURL: acceptableUseURL,
|
||||
privacyURL: privacyURL,
|
||||
encryptionURL: encryptionURL,
|
||||
deviceVerificationURL: deviceVerificationURL,
|
||||
chatBackupDetailsURL: chatBackupDetailsURL,
|
||||
identityPinningViolationDetailsURL: identityPinningViolationDetailsURL,
|
||||
historySharingDetailsURL: historySharingDetailsURL,
|
||||
elementWebHosts: elementWebHosts,
|
||||
accountProvisioningHost: accountProvisioningHost,
|
||||
bugReportApplicationID: bugReportApplicationID,
|
||||
analyticsTermsURL: analyticsTermsURL,
|
||||
mapTilerConfiguration: mapTilerConfiguration.publisher.value)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user