Created
July 20, 2012 17:14
-
-
Save randysecrist/3151959 to your computer and use it in GitHub Desktop.
illustrate decryption issue / possible edge case / starting with regular json
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
context "multi-json exception" do | |
setup do | |
@encryptor = Ripple::Contrib::EncryptedSerializer.new(OpenSSL::Cipher.new("AES-256-CBC")) | |
@encryptor.key = 'mhealth123456789101112mhealth123' | |
end | |
should "decrypt using aes encryptor" do | |
input = File.read("test/fixtures/test_document/v2_error.txt") | |
input = JSON.parse(input) | |
expected = YAML.dump(input) | |
cipher_text = @encryptor.dump(input) | |
assert cipher_text != input | |
# do we have the same cipher text that failed on a local env? | |
cipher_text_from_app = File.read("test/fixtures/test_document/v2_error.json") | |
assert cipher_text == cipher_text_from_app | |
# failure expected below | |
result = YAML.dump(@encryptor.load(cipher_text)) | |
assert_equal expected, result | |
end | |
end |
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
# Running tests: | |
...E............... | |
Finished tests in 0.063275s, 300.2766 tests/s, 410.9048 assertions/s. | |
1) Error: | |
test_decrypt_using_aes_encryptor(TestEncryption::TestRippleContribEncryptedSerializer::TestMultiJsonException): | |
MultiJson::DecodeError: 743: unexpected token at '????!t?,O?Y5?@?D;??J???E?d?? | |
???????k?D?mf??j1`7?F | |
?3ej+??????_?%?????H?θ>????K | |
??? | |
???`?5?'?? + X?XGxU???勯g|x?O^U<%??3???֭???e??K ???: ??9?{?A?m'???????B?c????W?_^?Sp???>???B?"??G???|I??7?b?T?]????!}bV?b>6??L?!'?kl? | |
Et?Fk1?5?ۄ4P?j!C?~ | |
s?f?k~B???E????1 ?s?'\.|@ | |
c???~f?0w?9&?w??????2?o????\}_???Fނ??0?ox?/S?7?*mU???N?x_ա ?Е?v1?zn???u??|?$ɥ1,p5 | |
?zcoZ????*??n?1??*?' | |
/Users/randy/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/multi_json-1.0.4/lib/multi_json/engines/json_common.rb:9:in `decode' | |
/Users/randy/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/multi_json-1.0.4/lib/multi_json.rb:76:in `decode' | |
/Users/randy/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/riak-ruby-client-1db6fb9c57fe/lib/riak/json.rb:18:in `parse' | |
/Users/randy/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/riak-ruby-client-1db6fb9c57fe/lib/riak/serializers.rb:54:in `load' | |
/Users/randy/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/bundler/gems/riak-ruby-client-1db6fb9c57fe/lib/riak/serializers.rb:19:in `deserialize' | |
/Users/randy/Documents/dev/views/mhealth/ripple-contrib/lib/ripple-contrib/encrypted_serializer.rb:62:in `load' | |
/Users/randy/Documents/dev/views/mhealth/ripple-contrib/test/test_unit_encryption.rb:115:in `block (3 levels) in <class:TestEncryption>' | |
19 tests, 26 assertions, 0 failures, 1 errors, 0 skips | |
rake aborted! | |
Command failed with status (1): [/Users/randy/.rbenv/versions/1.9.3-p125/bi...] |
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
{"version":"0.0.2","iv":"ABYLnUHWE/fIwE2gKYC6hg==\n","data":"szHms3/oVLUj6oLVXIQGSexnDBd6VblbJUEnzc3Jrh33ZoJ+ounRhQ+DeHLI\noFpsgttFeiF3uQRgzljCS9AnhX3ApJ5VWks3J7v4d4zI5YULUx2TBzQ7ZQMe\ndCVSgmNoo6WPxUjfJE1qTUVDePzauP47eTYhaOcerxXTUF7YjyPSXHRoxXBK\nfOeFanA6/FIgpdcefDQ04LciavoiiQb1yOnE22yPczXs0za2UE6UPeH+QgHn\n1JPwqHSMMKhlBFfoRwj7WJ8OtK0VRa6a/ACjq7DNIkRO7DDr7E4BLffYSUUV\nkl5v6J21Q+RGxS12fFFkb0iU/3gsXXBCK97HuAR82vfdz1tE5fokqKn8D8vW\naFxx+WfciaD3IayFlmI+Jiy93vBKp1ab3++2PRUfTyhnZg==\n"} |
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
{"user_key":"Xu2UOI0pjQJKkSU2ebZxA0ljO0J","product_key":"fitbit","name":"total_distance","date":"2012-05-06","measure_type":"distance","_type":"MHealth::Models::DailyLog","measures":[{"raw_value":8.66145,"timestamp":"2012-05-06T06:00:00Z","original_unit":"mile","_type":"MHealth::Models::Measure"}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment