-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RTL7d #209
Merged
Merged
RTL7d #209
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1af62d3
Test suite: removed flag `allDebug`
ricardopereira fb3bb02
Test suite: catch realtime protocol messages before being processed
ricardopereira 9b16356
RTL7d
ricardopereira 7f7ffc4
RTL7d: pending
ricardopereira a6751fd
Fix RTL7d: check log error message and data is intact
ricardopereira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -799,6 +799,65 @@ class RealtimeClientChannel: QuickSpec { | |
} | ||
} | ||
|
||
// RTL7d | ||
pending("should deliver the message even if there is an error while decoding") { | ||
|
||
for cryptoTest in [CryptoTest.aes128, CryptoTest.aes256] { | ||
it("using \(cryptoTest) ") { | ||
let options = AblyTests.commonAppSetup() | ||
options.autoConnect = false | ||
let client = ARTRealtime(options: options) | ||
client.setTransportClass(TestProxyTransport.self) | ||
client.connect() | ||
defer { client.close() } | ||
|
||
let (keyData, ivData, messages) = AblyTests.loadCryptoTestData(cryptoTest) | ||
let testMessage = messages[0] | ||
|
||
let cipherParams = ARTCrypto.defaultParamsWithKey(keyData, iv: ivData) | ||
let channelOptions = ARTChannelOptions(encrypted: cipherParams) | ||
let channel = client.channels.get("test", options: channelOptions) | ||
|
||
let transport = client.transport as! TestProxyTransport | ||
|
||
transport.beforeProcessingSentMessage = { protocolMessage in | ||
if protocolMessage.action == .Message { | ||
expect(protocolMessage.messages![0].data as? String).to(equal(testMessage.encrypted.data)) | ||
expect(protocolMessage.messages![0].encoding).to(equal(testMessage.encrypted.encoding)) | ||
} | ||
} | ||
|
||
transport.beforeProcessingReceivedMessage = { protocolMessage in | ||
if protocolMessage.action == .Message { | ||
expect(protocolMessage.messages![0].data as? String).to(equal(testMessage.encrypted.data)) | ||
expect(protocolMessage.messages![0].encoding).to(equal(testMessage.encrypted.encoding)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
// Force an error decoding a message | ||
protocolMessage.messages![0].encoding = "bad_encoding_type" | ||
} | ||
} | ||
|
||
waitUntil(timeout: testTimeout) { done in | ||
let logTime = NSDate() | ||
|
||
channel.subscribe(testMessage.encoded.name) { message in | ||
expect(message.data as? String).to(equal(testMessage.encrypted.data)) | ||
|
||
let logs = querySyslog(forLogsAfter: logTime) | ||
let line = logs.reduce("") { $0 + "; " + $1 } //Reduce in one line | ||
expect(line).to(contain("ERROR: Failed to decode data as 'bad_encoding_type' encoding is unknown")) | ||
|
||
expect(channel.errorReason!.message).to(contain("Failed to decode data as 'bad_encoding_type' encoding is unknown")) | ||
|
||
done() | ||
} | ||
|
||
channel.publish(testMessage.encoded.name, data: testMessage.encoded.data) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
// RTL7f | ||
it("should exist ensuring published messages are not echoed back to the subscriber when echoMessages is false") { | ||
let options = AblyTests.commonAppSetup() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failing because:
expected to equal <utf-8/cipher+aes-128-cbc/base64>, got <cipher+aes-128-cbc/base64>
expected to equal <utf-8/cipher+aes-256-cbc/base64>, got <cipher+aes-256-cbc/base64>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be passing after #217.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tcard Can you pick 236b3a9? Then I rebase this one after #217 has been merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ricardopereira Done, although I had to fix something in your 236b3a9 and now it is 9301ccb. You should replace 236b3a9 by 9301ccb in this PR.