diff --git a/MatrixSDK.podspec b/MatrixSDK.podspec index 901190e95..4ecfaa3af 100644 --- a/MatrixSDK.podspec +++ b/MatrixSDK.podspec @@ -45,7 +45,7 @@ Pod::Spec.new do |s| ss.dependency 'OLMKit', '~> 3.2.5' ss.dependency 'Realm', '10.27.0' ss.dependency 'libbase58', '~> 0.1.4' - ss.dependency 'MatrixSDKCrypto', '0.2.0', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true + ss.dependency 'MatrixSDKCrypto', '0.2.1', :configurations => ["DEBUG", "RELEASE"], :inhibit_warnings => true end s.subspec 'JingleCallStack' do |ss| diff --git a/MatrixSDKTests/Crypto/MXCryptoV2FactoryTests.swift b/MatrixSDKTests/Crypto/MXCryptoV2FactoryTests.swift index e38908d56..fb5057ff5 100644 --- a/MatrixSDKTests/Crypto/MXCryptoV2FactoryTests.swift +++ b/MatrixSDKTests/Crypto/MXCryptoV2FactoryTests.swift @@ -76,6 +76,8 @@ class MXCryptoV2FactoryTests: XCTestCase { let legacyStore = MXRealmCryptoStore.init(credentials: session.credentials) XCTAssertNotNil(legacyStore) XCTAssertEqual(legacyStore?.cryptoVersion, .versionLegacyDeprecated) + + await env.close() } func test_migratesExistingUser() async throws { @@ -95,6 +97,8 @@ class MXCryptoV2FactoryTests: XCTestCase { // Assert we still have legacy store but it is now marked as deprecated XCTAssertNotNil(legacyStore) XCTAssertEqual(legacyStore?.cryptoVersion, .versionLegacyDeprecated) + + await env.close() } func test_doesNotMigrateDeprecatedStore() async throws { @@ -114,5 +118,7 @@ class MXCryptoV2FactoryTests: XCTestCase { // Assert we still have legacy store which is still marked as deprecated XCTAssertNotNil(legacyStore) XCTAssertEqual(legacyStore?.cryptoVersion, .versionLegacyDeprecated) + + await env.close() } } diff --git a/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift b/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift index 9ea9f15c6..e20e41541 100644 --- a/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift +++ b/MatrixSDKTests/Crypto/Migration/MXCryptoMigrationV2Tests.swift @@ -74,35 +74,36 @@ class MXCryptoMigrationV2Tests: XCTestCase { func test_migratesAccountDetails() async throws { let env = try await e2eData.startE2ETest() let legacySession = env.session - + let machine = try self.migratedOlmMachine(session: env.session) - + XCTAssertEqual(machine.userId, legacySession.myUserId) XCTAssertEqual(machine.deviceId, legacySession.myDeviceId) XCTAssertEqual(machine.deviceCurve25519Key, legacySession.crypto.deviceCurve25519Key) XCTAssertEqual(machine.deviceEd25519Key, legacySession.crypto.deviceEd25519Key) + + await env.close() } - // Temporary disable test that fails to run on CI - func xtest_canDecryptMegolmMessageAfterMigration() async throws { + func test_canDecryptMegolmMessageAfterMigration() async throws { let env = try await e2eData.startE2ETest() guard let room = env.session.room(withRoomId: env.roomId) else { throw Error.missingDependencies } - + // Send a new message in encrypted room let event = try await room.sendTextMessage("Hi bob") - + // Erase cleartext and make sure the event was indeed encrypted event.setClearData(nil) XCTAssertTrue(event.isEncrypted) XCTAssertEqual(event.content["algorithm"] as? String, kMXCryptoMegolmAlgorithm) XCTAssertNotNil(event.content["ciphertext"]) - + // Migrate the session to crypto v2 let machine = try self.migratedOlmMachine(session: env.session) - + // Decrypt the event using crypto v2 let decrypted = try machine.decryptRoomEvent(event) let result = try MXEventDecryptionResult(event: decrypted) @@ -111,6 +112,8 @@ class MXCryptoMigrationV2Tests: XCTestCase { // At this point we should be able to read back the original message after // having decrypted the event with room keys migrated earlier XCTAssertEqual(content?["body"] as? String, "Hi bob") + + await env.close() } func test_notCrossSignedAfterMigration() async throws { @@ -129,6 +132,8 @@ class MXCryptoMigrationV2Tests: XCTestCase { // As expected we cannot cross sign in v2 either XCTAssertFalse(crossSigningV2.canCrossSign) XCTAssertFalse(crossSigningV2.hasAllPrivateKeys) + + await env.close() } func test_migratesCrossSigningStatus() async throws { @@ -148,6 +153,8 @@ class MXCryptoMigrationV2Tests: XCTestCase { // And confirm that cross signing is ready XCTAssertTrue(crossSigningV2.canCrossSign) XCTAssertTrue(crossSigningV2.hasAllPrivateKeys) + + await env.close() } } diff --git a/MatrixSDKTests/MatrixSDKTestsE2EData.swift b/MatrixSDKTests/MatrixSDKTestsE2EData.swift index 63b414eef..33e217ae8 100644 --- a/MatrixSDKTests/MatrixSDKTestsE2EData.swift +++ b/MatrixSDKTests/MatrixSDKTestsE2EData.swift @@ -30,15 +30,15 @@ extension MatrixSDKTestsE2EData { self.roomId = roomId } - deinit { - let session = session - DispatchQueue.main.async { - session.close() - } + @MainActor + func close() { + session.close() } } + @MainActor func startE2ETest() async throws -> Environment { + return try await withCheckedThrowingContinuation { continuation in doE2ETestWithAlice(inARoom: nil) { session, roomId, _ in guard let session = session, let roomId = roomId else { diff --git a/Podfile b/Podfile index 3dc917aee..6a5f5ca52 100644 --- a/Podfile +++ b/Podfile @@ -16,7 +16,7 @@ abstract_target 'MatrixSDK' do pod 'Realm', '10.27.0' pod 'libbase58', '~> 0.1.4' - pod 'MatrixSDKCrypto', "0.2.0", :inhibit_warnings => true + pod 'MatrixSDKCrypto', "0.2.1", :inhibit_warnings => true target 'MatrixSDK-iOS' do platform :ios, '11.0' diff --git a/Podfile.lock b/Podfile.lock index d78807365..d34cb1595 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -16,7 +16,7 @@ PODS: - AFNetworking/NSURLSession - GZIP (1.3.0) - libbase58 (0.1.4) - - MatrixSDKCrypto (0.2.0) + - MatrixSDKCrypto (0.2.1) - OHHTTPStubs (9.1.0): - OHHTTPStubs/Default (= 9.1.0) - OHHTTPStubs/Core (9.1.0) @@ -44,7 +44,7 @@ DEPENDENCIES: - AFNetworking (~> 4.0.0) - GZIP (~> 1.3.0) - libbase58 (~> 0.1.4) - - MatrixSDKCrypto (= 0.2.0) + - MatrixSDKCrypto (= 0.2.1) - OHHTTPStubs (~> 9.1.0) - OLMKit (~> 3.2.5) - Realm (= 10.27.0) @@ -65,12 +65,12 @@ SPEC CHECKSUMS: AFNetworking: 3bd23d814e976cd148d7d44c3ab78017b744cd58 GZIP: 416858efbe66b41b206895ac6dfd5493200d95b3 libbase58: 7c040313537b8c44b6e2d15586af8e21f7354efd - MatrixSDKCrypto: e1ef22aae76b5a6f030ace21a47be83864f4ff44 + MatrixSDKCrypto: 477d818bf2cc37b6cf702a290eb647bc8cf3cb1b OHHTTPStubs: 90eac6d8f2c18317baeca36698523dc67c513831 OLMKit: da115f16582e47626616874e20f7bb92222c7a51 Realm: 9ca328bd7e700cc19703799785e37f77d1a130f2 SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82 -PODFILE CHECKSUM: 22dbe406b768ebe51e6de5fe02348d35a4d3d9f6 +PODFILE CHECKSUM: e6ea6492ce460203d61def97cf6ceb27f8827d70 COCOAPODS: 1.11.3 diff --git a/changelog.d/pr-1725.change b/changelog.d/pr-1725.change new file mode 100644 index 000000000..3355201a1 --- /dev/null +++ b/changelog.d/pr-1725.change @@ -0,0 +1 @@ +Update MatrixSDKCrypto