diff options
author | Florian Frank <flori@ping.de> | 2013-02-04 23:28:30 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2013-02-11 19:08:20 +0100 |
commit | d0a62f3ced7560daba2ad546d83f0479a5ae2cf2 (patch) | |
tree | 5405697053a6daba987c3dbd18a5aece25ebdee1 /tests/test_json_generic_object.rb | |
parent | 771e08b7a96c5d4c962e3e2f258df2f680c60dc0 (diff) | |
download | json-d0a62f3ced7560daba2ad546d83f0479a5ae2cf2.tar.gz |
Security fix create_additons/JSON::GenericObjectv1.7.7
Diffstat (limited to 'tests/test_json_generic_object.rb')
-rw-r--r-- | tests/test_json_generic_object.rb | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/tests/test_json_generic_object.rb b/tests/test_json_generic_object.rb index 83093b8..77ef22e 100644 --- a/tests/test_json_generic_object.rb +++ b/tests/test_json_generic_object.rb @@ -20,17 +20,22 @@ class TestJSONGenericObject < Test::Unit::TestCase end def test_generate_json - assert_equal @go, JSON(JSON(@go)) + switch_json_creatable do + assert_equal @go, JSON(JSON(@go), :create_additions => true) + end end def test_parse_json - assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }') - assert_equal 1, l.a - assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject) - assert_equal 1, l.a - assert_equal GenericObject[:a => GenericObject[:b => 2]], - l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject) - assert_equal 2, l.a.b + assert_kind_of Hash, JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true) + switch_json_creatable do + assert_equal @go, l = JSON('{ "json_class": "JSON::GenericObject", "a": 1, "b": 2 }', :create_additions => true) + assert_equal 1, l.a + assert_equal @go, l = JSON('{ "a": 1, "b": 2 }', :object_class => GenericObject) + assert_equal 1, l.a + assert_equal GenericObject[:a => GenericObject[:b => 2]], + l = JSON('{ "a": { "b": 2 } }', :object_class => GenericObject) + assert_equal 2, l.a.b + end end def test_from_hash @@ -43,4 +48,13 @@ class TestJSONGenericObject < Test::Unit::TestCase assert_equal true, result.foo.quux.first.foobar assert_equal true, GenericObject.from_hash(true) end + + private + + def switch_json_creatable + JSON::GenericObject.json_creatable = true + yield + ensure + JSON::GenericObject.json_creatable = false + end end |