File tree Expand file tree Collapse file tree
main/java/org/jruby/ext/openssl Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1574,16 +1574,21 @@ static void initializeImpl(final ThreadContext context,
15741574
15751575 // NOTE: Primitive only
15761576 final String baseName = self .getMetaClass ().getRealClass ().getBaseName ();
1577- if ( "ObjectId" .equals ( baseName ) ) {
1578- final String name ;
1579- try {
1580- name = oid2Sym ( runtime , getObjectID (runtime , value .toString ()), true );
1581- }
1582- catch (IllegalArgumentException e ) {
1583- // e.g. in case of nil "string not an OID"
1584- throw runtime .newTypeError (e .getMessage ());
1585- }
1586- if ( name != null ) value = runtime .newString (name );
1577+ switch (baseName ) {
1578+ case "ObjectId" :
1579+ final String name ;
1580+ try {
1581+ name = oid2Sym ( runtime , getObjectID (runtime , value .toString ()), true );
1582+ }
1583+ catch (IllegalArgumentException e ) {
1584+ // e.g. in case of nil "string not an OID"
1585+ throw runtime .newTypeError (e .getMessage ());
1586+ }
1587+ if ( name != null ) value = runtime .newString (name );
1588+ break ;
1589+ case "BitString" :
1590+ self .setInstanceVariable ("@unused_bits" , runtime .newFixnum (0 ));
1591+ break ;
15871592 }
15881593
15891594 self .setInstanceVariable ("@tag" , tag );
Original file line number Diff line number Diff line change @@ -1162,14 +1162,11 @@ def test_decode
11621162 #assert_equal calulated_sig, sig_val.value
11631163 end
11641164
1165- # This is from the upstream MRI tests, might be superseded by `test_bit_string_infinite_length`?
1165+ # This is from the upstream MRI tests
11661166 def test_bitstring
1167- # TODO: Import Issue
1168- # fails <nil> expected but was <0>
1169- #encode_decode_test B(%w{ 03 01 00 }), OpenSSL::ASN1::BitString.new(B(%w{}))
1170- # TODO: Import Issue
1171- # fails with <nil> expected but was <0>
1172- #encode_decode_test B(%w{ 03 02 00 01 }), OpenSSL::ASN1::BitString.new(B(%w{ 01 }))
1167+ encode_decode_test B ( %w{ 03 01 00 } ) , OpenSSL ::ASN1 ::BitString . new ( B ( %w{ } ) )
1168+ encode_decode_test B ( %w{ 03 02 00 01 } ) , OpenSSL ::ASN1 ::BitString . new ( B ( %w{ 01 } ) )
1169+
11731170 obj = OpenSSL ::ASN1 ::BitString . new ( B ( %w{ F0 } ) )
11741171 obj . unused_bits = 4
11751172 encode_decode_test B ( %w{ 03 02 04 F0 } ) , obj
You can’t perform that action at this time.
0 commit comments