Automatic discovery of the sliding sync proxy. (#535)

* Automatic discovery of the sliding sync proxy.

* Handle homeserver detection from a MXID.

* Update sliding sync info link, SDK and bump patch.

Add a migration on the new version. The change in restoration token format requires the user to sign in again, but this will fail with the existing device ID.
This commit is contained in:
Doug
2023-02-08 19:07:02 +00:00
committed by GitHub
parent f7fbdcc32c
commit 4d87701ae9
22 changed files with 115 additions and 44 deletions
@@ -32,7 +32,13 @@ class KeychainControllerTests: XCTestCase {
// When adding an restoration token.
let username = "@test:example.com"
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken", refreshToken: "refreshToken", userId: "userId", deviceId: "deviceId", homeserverUrl: "homeserverUrl", isSoftLogout: false))
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken",
refreshToken: "refreshToken",
userId: "userId",
deviceId: "deviceId",
homeserverUrl: "homeserverUrl",
isSoftLogout: false,
slidingSyncProxy: "https://my.sync.proxy"))
keychain.setRestorationToken(restorationToken, forUsername: username)
// Then the restoration token should be stored in the keychain.
@@ -42,7 +48,13 @@ class KeychainControllerTests: XCTestCase {
func testRemovingRestorationToken() {
// Given a keychain with a stored restoration token.
let username = "@test:example.com"
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken", refreshToken: "refreshToken", userId: "userId", deviceId: "deviceId", homeserverUrl: "homeserverUrl", isSoftLogout: false))
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken",
refreshToken: "refreshToken",
userId: "userId",
deviceId: "deviceId",
homeserverUrl: "homeserverUrl",
isSoftLogout: false,
slidingSyncProxy: "https://my.sync.proxy"))
keychain.setRestorationToken(restorationToken, forUsername: username)
XCTAssertEqual(keychain.restorationTokens().count, 1, "The keychain should have 1 restoration token.")
XCTAssertEqual(keychain.restorationTokenForUsername(username), restorationToken, "The initial restoration token should match the value that was stored.")
@@ -58,7 +70,13 @@ class KeychainControllerTests: XCTestCase {
func testRemovingAllRestorationTokens() {
// Given a keychain with 5 stored restoration tokens.
for index in 0..<5 {
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken", refreshToken: "refreshToken", userId: "userId", deviceId: "deviceId", homeserverUrl: "homeserverUrl", isSoftLogout: false))
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken",
refreshToken: "refreshToken",
userId: "userId",
deviceId: "deviceId",
homeserverUrl: "homeserverUrl",
isSoftLogout: false,
slidingSyncProxy: "https://my.sync.proxy"))
keychain.setRestorationToken(restorationToken, forUsername: "@test\(index):example.com")
}
XCTAssertEqual(keychain.restorationTokens().count, 5, "The keychain should have 5 restoration tokens.")
@@ -73,7 +91,13 @@ class KeychainControllerTests: XCTestCase {
func testRemovingSingleRestorationTokens() {
// Given a keychain with 5 stored restoration tokens.
for index in 0..<5 {
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken", refreshToken: "refreshToken", userId: "userId", deviceId: "deviceId", homeserverUrl: "homeserverUrl", isSoftLogout: false))
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken",
refreshToken: "refreshToken",
userId: "userId",
deviceId: "deviceId",
homeserverUrl: "homeserverUrl",
isSoftLogout: false,
slidingSyncProxy: "https://my.sync.proxy"))
keychain.setRestorationToken(restorationToken, forUsername: "@test\(index):example.com")
}
XCTAssertEqual(keychain.restorationTokens().count, 5, "The keychain should have 5 restoration tokens.")