File tree 2 files changed +19
-17
lines changed
main/java/org/jruby/ext/openssl
2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change @@ -1574,16 +1574,21 @@ static void initializeImpl(final ThreadContext context,
1574
1574
1575
1575
// NOTE: Primitive only
1576
1576
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 ;
1587
1592
}
1588
1593
1589
1594
self .setInstanceVariable ("@tag" , tag );
Original file line number Diff line number Diff line change @@ -1162,14 +1162,11 @@ def test_decode
1162
1162
#assert_equal calulated_sig, sig_val.value
1163
1163
end
1164
1164
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
1166
1166
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
+
1173
1170
obj = OpenSSL ::ASN1 ::BitString . new ( B ( %w{ F0 } ) )
1174
1171
obj . unused_bits = 4
1175
1172
encode_decode_test B ( %w{ 03 02 04 F0 } ) , obj
You can’t perform that action at this time.
0 commit comments