Merge branch 'mlin/PR/ExposeUnsealedContent'
This commit is contained in:
commit
90f1776e63
@ -12,6 +12,7 @@ public struct SecretSessionKnownSenderError: Error {
|
||||
public let senderDeviceId: UInt32
|
||||
public let cipherType: CiphertextMessage.MessageType
|
||||
public let groupId: Data?
|
||||
public let unsealedContent: Data
|
||||
public let contentHint: UnidentifiedSenderMessageContent.ContentHint
|
||||
public let underlyingError: Error
|
||||
|
||||
@ -20,6 +21,7 @@ public struct SecretSessionKnownSenderError: Error {
|
||||
self.senderDeviceId = messageContent.senderCertificate.sender.deviceId
|
||||
self.cipherType = messageContent.messageType
|
||||
self.groupId = messageContent.groupId.map { Data($0) }
|
||||
self.unsealedContent = Data(messageContent.contents)
|
||||
self.contentHint = messageContent.contentHint
|
||||
self.underlyingError = underlyingError
|
||||
}
|
||||
|
||||
@ -128,6 +128,14 @@ class SMKSecretSessionCipherTest: XCTestCase {
|
||||
XCTAssert(knownSenderError.underlyingError is SMKCertificateError )
|
||||
XCTAssertEqual(knownSenderError.contentHint, aliceContentHint)
|
||||
XCTAssertEqual(knownSenderError.groupId, aliceGroupId)
|
||||
XCTAssertNoThrow(
|
||||
try DecryptionErrorMessage(
|
||||
originalMessageBytes: knownSenderError.unsealedContent,
|
||||
type: knownSenderError.cipherType,
|
||||
timestamp: 31335,
|
||||
originalSenderDeviceId: knownSenderError.senderDeviceId
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
XCTFail("Unexpected error: \(error)")
|
||||
}
|
||||
@ -195,6 +203,14 @@ class SMKSecretSessionCipherTest: XCTestCase {
|
||||
XCTAssert(knownSenderError.underlyingError is SMKCertificateError )
|
||||
XCTAssertEqual(knownSenderError.contentHint, aliceContentHint)
|
||||
XCTAssertEqual(knownSenderError.groupId, aliceGroupId)
|
||||
XCTAssertNoThrow(
|
||||
try DecryptionErrorMessage(
|
||||
originalMessageBytes: knownSenderError.unsealedContent,
|
||||
type: knownSenderError.cipherType,
|
||||
timestamp: 31338,
|
||||
originalSenderDeviceId: knownSenderError.senderDeviceId
|
||||
)
|
||||
)
|
||||
} catch {
|
||||
XCTFail("Unexpected error: \(error)")
|
||||
}
|
||||
@ -385,6 +401,14 @@ class SMKSecretSessionCipherTest: XCTestCase {
|
||||
XCTAssertEqual(knownSenderError.senderDeviceId, UInt32(aliceMockClient.deviceId))
|
||||
XCTAssertEqual(Data(knownSenderError.groupId!), "inyalowda".data(using: String.Encoding.utf8)!)
|
||||
XCTAssertEqual(knownSenderError.contentHint, .resendable)
|
||||
XCTAssertNoThrow(
|
||||
try DecryptionErrorMessage(
|
||||
originalMessageBytes: knownSenderError.unsealedContent,
|
||||
type: knownSenderError.cipherType,
|
||||
timestamp: 31335,
|
||||
originalSenderDeviceId: knownSenderError.senderDeviceId
|
||||
)
|
||||
)
|
||||
|
||||
if case SignalError.invalidState(_) = knownSenderError.underlyingError {
|
||||
// Expected
|
||||
|
||||
Loading…
Reference in New Issue
Block a user