diff options
author | emboss <emboss@ruby-lang.org> | 2012-03-28 22:53:18 +0000 |
---|---|---|
committer | emboss <emboss@ruby-lang.org> | 2012-03-28 22:53:18 +0000 |
commit | 4d2dfac660549e3c18ad8d274134c43eefb35d2f (patch) | |
tree | c6eacd4ad8f466a280772ce7d1aac4eae522bdd7 /test | |
parent | 476075e3bbcafff0635d2bffa0c29d9954d56d60 (diff) | |
download | ruby-openssl-history-4d2dfac660549e3c18ad8d274134c43eefb35d2f.tar.gz |
* ext/openssl/ossl_asn1.c: raise TypeError when trying to encode nil
values for Primitive instances.
* test/openssl/test_asn1.rb: Assert consistent behavior when
encoding nil values: Primitives raise TypeError, Constructives
raise NoMethodError.
Fixes [ruby-core:43009][Bug #6102]
-This line, and those below, will be ignored--
M test/openssl/test_asn1.rb
M ext/openssl/ossl_asn1.c
M ChangeLog
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_asn1.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_asn1.rb b/test/test_asn1.rb index 0932476..811fe38 100644 --- a/test/test_asn1.rb +++ b/test/test_asn1.rb @@ -198,6 +198,18 @@ class OpenSSL::TestASN1 < Test::Unit::TestCase encode_decode_test(OpenSSL::ASN1::Integer, [72, -127, -128, 128, -1, 0, 1, -(2**12345), 2**12345]) end + def test_encode_nil + m = OpenSSL::ASN1 + [ + m::Boolean, m::Integer, m::BitString, m::OctetString, + m::ObjectId, m::Enumerated, m::UTF8String, m::UTCTime, + m::GeneralizedTime, m::Sequence, m::Set + ].each do |klass| + #Primitives raise TypeError, Constructives NoMethodError + assert_raise(TypeError, NoMethodError) { klass.send(:new, nil).to_der } + end + end + def encode_decode_test(type, values) values.each do |v| assert_equal(v, OpenSSL::ASN1.decode(type.new(v).to_der).value) |