Skip to content

Commit

Permalink
Merge branch 'release/0.26.9/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave committed Apr 18, 2023
2 parents a12a559 + 161f0fe commit 9f1b4ba
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 6 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Changes in 0.26.9 (2023-04-18)

🐛 Bugfixes

- Cross-signing: Setup cross-signing with empty auth session ([#1774](https://github.com/matrix-org/matrix-ios-sdk/pull/1774))


## Changes in 0.26.8 (2023-04-18)

🙌 Improvements
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.26.8"
s.version = "0.26.9"
s.summary = "The iOS SDK to build apps compatible with Matrix (https://www.matrix.org)"

s.description = <<-DESC
Expand Down
5 changes: 3 additions & 2 deletions MatrixSDK/Crypto/CrossSigning/MXCrossSigningV2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ class MXCrossSigningV2: NSObject, MXCrossSigning {
let session = authSession.session,
let userId = restClient.credentials?.userId
else {
log.error("Missing parameters")
throw Error.missingAuthSession
// Try to setup cross-signing without authentication parameters in case if a grace period is enabled
log.warning("Setting up cross-signing without authentication parameters")
return [:]
}

return [
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MatrixSDKVersion.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

#import <Foundation/Foundation.h>

NSString *const MatrixSDKVersion = @"0.26.8";
NSString *const MatrixSDKVersion = @"0.26.9";
61 changes: 59 additions & 2 deletions MatrixSDKTests/Crypto/CrossSigning/MXCrossSigningV2UnitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,74 @@ import MatrixSDKCrypto

class MXCrossSigningV2UnitTests: XCTestCase {

class RestClientStub: MXRestClientStub {
var stubbedAuthSession: MXAuthenticationSession?

override var credentials: MXCredentials! {
let cred = MXCredentials()
cred.userId = "Alice"
cred.deviceId = "XYZ"
return cred
}

override func authSession(
toUploadDeviceSigningKeys success: ((MXAuthenticationSession?) -> Void)!,
failure: ((Error?) -> Void)!
) -> MXHTTPOperation! {
success(stubbedAuthSession)
return MXHTTPOperation()
}
}

var crypto: CryptoCrossSigningStub!
var crossSigning: MXCrossSigningV2!
var restClient: MXRestClientStub!
var restClient: RestClientStub!

override func setUp() {
crypto = CryptoCrossSigningStub()
restClient = MXRestClientStub()
restClient = RestClientStub()
crossSigning = MXCrossSigningV2(
crossSigning: crypto,
restClient: restClient
)
}

// MARK: - Setup

func test_setup_canSetupWithoutAuthSession() {
let exp = expectation(description: "exp")
crossSigning.setup(withPassword: "pass") {
XCTAssertEqual(self.crypto.spyAuthParams as? [String: String], [:])
exp.fulfill()
} failure: {
XCTFail("Failed setting up cross signing with error - \($0)")
exp.fulfill()
}
waitForExpectations(timeout: 1)
}

func test_setup_canSetupWitAuthSession() {
let exp = expectation(description: "exp")
restClient.stubbedAuthSession = MXAuthenticationSession()
restClient.stubbedAuthSession?.session = "123"

crossSigning.setup(withPassword: "pass") {
XCTAssertEqual(self.crypto.spyAuthParams as? [String: String], [
"session": "123",
"user": "Alice",
"password": "pass",
"type": kMXLoginFlowTypePassword
])
exp.fulfill()
} failure: {
XCTFail("Failed setting up cross signing with error - \($0)")
exp.fulfill()
}
waitForExpectations(timeout: 1)
}

// MARK: - State

func test_state_notBootstrapped() {
XCTAssertEqual(crossSigning.state, .notBootstrapped)
}
Expand Down Expand Up @@ -104,6 +159,8 @@ class MXCrossSigningV2UnitTests: XCTestCase {
}
}

// MARK: - Devices

func test_crossSignDevice_verifiesUntrustedDevice() async throws {
let userId = "Alice"
let deviceId = "ABCD"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ class CryptoCrossSigningStub: CryptoIdentityStub, MXCryptoCrossSigning {
return stubbedStatus
}

var spyAuthParams: [AnyHashable: Any]?
func bootstrapCrossSigning(authParams: [AnyHashable : Any]) async throws {
self.spyAuthParams = authParams
}

func exportCrossSigningKeys() -> CrossSigningKeyExport? {
Expand Down

0 comments on commit 9f1b4ba

Please sign in to comment.