mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Fix the restoration of a SSS session. (#3081)
This commit is contained in:
parent
bf22250b45
commit
013240e9b1
@ -47,7 +47,8 @@ extension MatrixRustSDK.Session: Codable {
|
|||||||
deviceId: container.decode(String.self, forKey: .deviceId),
|
deviceId: container.decode(String.self, forKey: .deviceId),
|
||||||
homeserverUrl: container.decode(String.self, forKey: .homeserverUrl),
|
homeserverUrl: container.decode(String.self, forKey: .homeserverUrl),
|
||||||
oidcData: container.decodeIfPresent(String.self, forKey: .oidcData),
|
oidcData: container.decodeIfPresent(String.self, forKey: .oidcData),
|
||||||
slidingSyncProxy: container.decode(String.self, forKey: .slidingSyncProxy))
|
// Note: the proxy is optional now that we support Simplified Sliding Sync.
|
||||||
|
slidingSyncProxy: container.decodeIfPresent(String.self, forKey: .slidingSyncProxy))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(to encoder: Encoder) throws {
|
public func encode(to encoder: Encoder) throws {
|
||||||
|
@ -127,6 +127,28 @@ class KeychainControllerTests: XCTestCase {
|
|||||||
XCTAssertNotNil(keychain.restorationTokenForUsername("@test4:example.com"), "The restoration token should not have been deleted.")
|
XCTAssertNotNil(keychain.restorationTokenForUsername("@test4:example.com"), "The restoration token should not have been deleted.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testSimplifiedSlidingSyncRestorationToken() {
|
||||||
|
// Given an empty keychain.
|
||||||
|
XCTAssertTrue(keychain.restorationTokens().isEmpty, "The keychain should be empty to begin with.")
|
||||||
|
|
||||||
|
// When adding an restoration token that doesn't contain a sliding sync proxy (e.g. for SSS).
|
||||||
|
let username = "@test:example.com"
|
||||||
|
let restorationToken = RestorationToken(session: .init(accessToken: "accessToken",
|
||||||
|
refreshToken: "refreshToken",
|
||||||
|
userId: "userId",
|
||||||
|
deviceId: "deviceId",
|
||||||
|
homeserverUrl: "homeserverUrl",
|
||||||
|
oidcData: "oidcData",
|
||||||
|
slidingSyncProxy: nil),
|
||||||
|
sessionDirectory: .homeDirectory.appending(component: UUID().uuidString),
|
||||||
|
passphrase: "passphrase",
|
||||||
|
pusherNotificationClientIdentifier: "pusherClientID")
|
||||||
|
keychain.setRestorationToken(restorationToken, forUsername: username)
|
||||||
|
|
||||||
|
// Then decoding the restoration token from the keychain should still work.
|
||||||
|
XCTAssertEqual(keychain.restorationTokenForUsername(username), restorationToken, "The retrieved restoration token should match the value that was stored.")
|
||||||
|
}
|
||||||
|
|
||||||
func testAddPINCode() throws {
|
func testAddPINCode() throws {
|
||||||
// Given a keychain without a PIN code set.
|
// Given a keychain without a PIN code set.
|
||||||
try XCTAssertFalse(keychain.containsPINCode(), "A new keychain shouldn't contain a PIN code.")
|
try XCTAssertFalse(keychain.containsPINCode(), "A new keychain shouldn't contain a PIN code.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user