jruby-jruby-openssl 0.5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +34 -0
- data/License.txt +30 -0
- data/README.txt +24 -0
- data/lib/bcmail-jdk14-139.jar +0 -0
- data/lib/bcprov-jdk14-139.jar +0 -0
- data/lib/jopenssl.jar +0 -0
- data/lib/jopenssl/version.rb +5 -0
- data/lib/openssl.rb +24 -0
- data/lib/openssl/bn.rb +35 -0
- data/lib/openssl/buffering.rb +239 -0
- data/lib/openssl/cipher.rb +58 -0
- data/lib/openssl/digest.rb +48 -0
- data/lib/openssl/dummy.rb +34 -0
- data/lib/openssl/dummyssl.rb +13 -0
- data/lib/openssl/ssl.rb +135 -0
- data/lib/openssl/x509.rb +154 -0
- data/test/fixture/cacert.pem +23 -0
- data/test/fixture/cert_localhost.pem +19 -0
- data/test/fixture/localhost_keypair.pem +18 -0
- data/test/openssl/ssl_server.rb +99 -0
- data/test/openssl/test_asn1.rb +199 -0
- data/test/openssl/test_cipher.rb +174 -0
- data/test/openssl/test_digest.rb +88 -0
- data/test/openssl/test_hmac.rb +44 -0
- data/test/openssl/test_ns_spki.rb +69 -0
- data/test/openssl/test_pair.rb +149 -0
- data/test/openssl/test_pkcs7.rb +159 -0
- data/test/openssl/test_pkey_rsa.rb +49 -0
- data/test/openssl/test_ssl.rb +307 -0
- data/test/openssl/test_x509cert.rb +236 -0
- data/test/openssl/test_x509crl.rb +234 -0
- data/test/openssl/test_x509ext.rb +74 -0
- data/test/openssl/test_x509name.rb +265 -0
- data/test/openssl/test_x509req.rb +178 -0
- data/test/openssl/test_x509store.rb +245 -0
- data/test/openssl/utils.rb +135 -0
- data/test/pkcs7_mime_enveloped.message +19 -0
- data/test/pkcs7_mime_signed.message +30 -0
- data/test/pkcs7_multipart_signed.message +45 -0
- data/test/ref/a.out +0 -0
- data/test/ref/compile.rb +8 -0
- data/test/ref/pkcs1 +0 -0
- data/test/ref/pkcs1.c +21 -0
- data/test/test_cipher.rb +81 -0
- data/test/test_integration.rb +100 -0
- data/test/test_java.rb +98 -0
- data/test/test_java_attribute.rb +25 -0
- data/test/test_java_bio.rb +42 -0
- data/test/test_java_mime.rb +173 -0
- data/test/test_java_pkcs7.rb +769 -0
- data/test/test_java_smime.rb +177 -0
- data/test/test_openssl.rb +34 -0
- data/test/test_openssl_x509.rb +34 -0
- data/test/test_pkey.rb +46 -0
- data/test/ut_eof.rb +128 -0
- metadata +120 -0
@@ -0,0 +1,177 @@
|
|
1
|
+
module PKCS7Test
|
2
|
+
class TestJavaSMIME < Test::Unit::TestCase
|
3
|
+
def test_read_pkcs7_should_raise_error_when_parsing_headers_fails
|
4
|
+
bio = BIO.new
|
5
|
+
mime = Mime.new
|
6
|
+
mime.stubs(:parseHeaders).returns(nil)
|
7
|
+
|
8
|
+
begin
|
9
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
10
|
+
assert false
|
11
|
+
rescue PKCS7Exception => e
|
12
|
+
assert_equal PKCS7::F_SMIME_READ_PKCS7, e.cause.get_method
|
13
|
+
assert_equal PKCS7::R_MIME_PARSE_ERROR, e.cause.get_reason
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_read_pkcs7_should_raise_error_when_content_type_is_not_there
|
18
|
+
bio = BIO.new
|
19
|
+
mime = Mime.new
|
20
|
+
|
21
|
+
headers = ArrayList.new
|
22
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
23
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(nil)
|
24
|
+
|
25
|
+
begin
|
26
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
27
|
+
assert false
|
28
|
+
rescue PKCS7Exception => e
|
29
|
+
assert_equal PKCS7::F_SMIME_READ_PKCS7, e.cause.get_method
|
30
|
+
assert_equal PKCS7::R_NO_CONTENT_TYPE, e.cause.get_reason
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
mime = Mime.new
|
37
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
38
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(MimeHeader.new("content-type", nil))
|
39
|
+
|
40
|
+
begin
|
41
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
42
|
+
assert false
|
43
|
+
rescue PKCS7Exception => e
|
44
|
+
assert_equal PKCS7::F_SMIME_READ_PKCS7, e.cause.get_method
|
45
|
+
assert_equal PKCS7::R_NO_CONTENT_TYPE, e.cause.get_reason
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_read_pkcs7_should_set_the_second_arguments_contents_to_null_if_its_there
|
50
|
+
mime = Mime.new
|
51
|
+
mime.stubs(:parseHeaders).raises("getOutOfJailForFree")
|
52
|
+
|
53
|
+
bio2 = BIO.new
|
54
|
+
arr = [bio2].to_java BIO
|
55
|
+
|
56
|
+
begin
|
57
|
+
SMIME.new(mime).readPKCS7(nil, arr)
|
58
|
+
rescue
|
59
|
+
end
|
60
|
+
|
61
|
+
assert_nil arr[0]
|
62
|
+
|
63
|
+
|
64
|
+
arr = [bio2, bio2].to_java BIO
|
65
|
+
begin
|
66
|
+
SMIME.new(mime).readPKCS7(nil, arr)
|
67
|
+
rescue
|
68
|
+
end
|
69
|
+
|
70
|
+
assert_nil arr[0]
|
71
|
+
assert_equal bio2, arr[1]
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_read_pkcs7_should_call_methods_on_mime
|
75
|
+
bio = BIO.new
|
76
|
+
mime = Mime.new
|
77
|
+
|
78
|
+
headers = ArrayList.new
|
79
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
80
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(MimeHeader.new("content-type", "application/pkcs7-mime"))
|
81
|
+
|
82
|
+
begin
|
83
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
84
|
+
rescue java.lang.UnsupportedOperationException
|
85
|
+
# This error is expected, since the bio used is not a real one
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_read_pkcs7_throws_correct_exception_if_wrong_content_type
|
90
|
+
bio = BIO.new
|
91
|
+
mime = Mime.new
|
92
|
+
|
93
|
+
headers = ArrayList.new
|
94
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
95
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(MimeHeader.new("content-type", "foo"))
|
96
|
+
|
97
|
+
begin
|
98
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
99
|
+
assert false
|
100
|
+
rescue PKCS7Exception => e
|
101
|
+
assert_equal PKCS7::F_SMIME_READ_PKCS7, e.cause.get_method
|
102
|
+
assert_equal PKCS7::R_INVALID_MIME_TYPE, e.cause.get_reason
|
103
|
+
assert_equal "type: foo", e.cause.error_data
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_read_pkcs7_with_multipart_should_fail_if_no_boundary_found
|
108
|
+
bio = BIO.new
|
109
|
+
mime = Mime.new
|
110
|
+
|
111
|
+
headers = ArrayList.new
|
112
|
+
hdr = MimeHeader.new("content-type", "multipart/signed")
|
113
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
114
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(hdr)
|
115
|
+
|
116
|
+
mime.expects(:findParam).with(hdr, "boundary").returns(nil)
|
117
|
+
|
118
|
+
begin
|
119
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
120
|
+
assert false
|
121
|
+
rescue PKCS7Exception => e
|
122
|
+
assert_equal PKCS7::F_SMIME_READ_PKCS7, e.cause.get_method
|
123
|
+
assert_equal PKCS7::R_NO_MULTIPART_BOUNDARY, e.cause.get_reason
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_read_pkcs7_with_multipart_should_fail_if_null_boundary_value
|
128
|
+
bio = BIO.new
|
129
|
+
mime = Mime.new
|
130
|
+
|
131
|
+
headers = ArrayList.new
|
132
|
+
hdr = MimeHeader.new("content-type", "multipart/signed")
|
133
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
134
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(hdr)
|
135
|
+
|
136
|
+
mime.expects(:findParam).with(hdr, "boundary").returns(MimeParam.new("boundary", nil))
|
137
|
+
|
138
|
+
begin
|
139
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
140
|
+
assert false
|
141
|
+
rescue PKCS7Exception => e
|
142
|
+
assert_equal PKCS7::F_SMIME_READ_PKCS7, e.cause.get_method
|
143
|
+
assert_equal PKCS7::R_NO_MULTIPART_BOUNDARY, e.cause.get_reason
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# TODO: redo this test to be an integration test
|
148
|
+
def _test_read_pkcs7_happy_path_without_multipart
|
149
|
+
bio = BIO.new
|
150
|
+
mime = Mime.new
|
151
|
+
|
152
|
+
headers = ArrayList.new
|
153
|
+
mime.expects(:parseHeaders).with(bio).returns(headers)
|
154
|
+
mime.expects(:findHeader).with(headers, "content-type").returns(MimeHeader.new("content-type", "application/pkcs7-mime"))
|
155
|
+
|
156
|
+
SMIME.new(mime).readPKCS7(bio, nil)
|
157
|
+
end
|
158
|
+
|
159
|
+
def test_read_pkcs7_happy_path_multipart
|
160
|
+
bio = BIO::from_string(MultipartSignedString)
|
161
|
+
mime = Mime::DEFAULT
|
162
|
+
p7 = SMIME.new(mime).readPKCS7(bio, nil)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_read_pkcs7_happy_path_without_multipart_enveloped
|
166
|
+
bio = BIO::from_string(MimeEnvelopedString)
|
167
|
+
mime = Mime::DEFAULT
|
168
|
+
p7 = SMIME.new(mime).readPKCS7(bio, nil)
|
169
|
+
end
|
170
|
+
|
171
|
+
def test_read_pkcs7_happy_path_without_multipart_signed
|
172
|
+
bio = BIO::from_string(MimeSignedString)
|
173
|
+
mime = Mime::DEFAULT
|
174
|
+
p7 = SMIME.new(mime).readPKCS7(bio, nil)
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
if defined?(JRUBY_VERSION)
|
3
|
+
require "java"
|
4
|
+
base = File.join(File.dirname(__FILE__), '..')
|
5
|
+
$CLASSPATH << File.join(base, 'pkg', 'classes')
|
6
|
+
$CLASSPATH << File.join(base, 'lib', 'bcprov-jdk14-139.jar')
|
7
|
+
end
|
8
|
+
|
9
|
+
def protect_require(name)
|
10
|
+
require name
|
11
|
+
rescue Exception => e
|
12
|
+
$stderr.puts "Had exception in #{name}: #{e.inspect}"
|
13
|
+
$stderr.puts(*(e.backtrace))
|
14
|
+
end
|
15
|
+
|
16
|
+
protect_require 'openssl/test_asn1'
|
17
|
+
protect_require 'openssl/test_cipher'
|
18
|
+
protect_require 'openssl/test_digest'
|
19
|
+
protect_require 'openssl/test_hmac'
|
20
|
+
protect_require 'openssl/test_ns_spki'
|
21
|
+
protect_require 'openssl/test_pair'
|
22
|
+
protect_require 'openssl/test_pkcs7'
|
23
|
+
protect_require 'openssl/test_pkey_rsa'
|
24
|
+
protect_require 'openssl/test_ssl'
|
25
|
+
protect_require 'openssl/test_x509cert'
|
26
|
+
protect_require 'openssl/test_x509crl'
|
27
|
+
protect_require 'openssl/test_x509ext'
|
28
|
+
protect_require 'openssl/test_x509name'
|
29
|
+
protect_require 'openssl/test_x509req'
|
30
|
+
protect_require 'openssl/test_x509store'
|
31
|
+
protect_require 'test_cipher'
|
32
|
+
protect_require 'test_java'
|
33
|
+
protect_require 'test_integration'
|
34
|
+
protect_require 'test_pkey'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
# JRUBY-3468
|
5
|
+
class TestOpensslX509 < Test::Unit::TestCase
|
6
|
+
def test_jruby3468
|
7
|
+
pem_cert = <<END
|
8
|
+
-----BEGIN CERTIFICATE-----
|
9
|
+
MIIC/jCCAmegAwIBAgIBATANBgkqhkiG9w0BAQUFADBNMQswCQYDVQQGEwJKUDER
|
10
|
+
MA8GA1UECgwIY3Rvci5vcmcxFDASBgNVBAsMC0RldmVsb3BtZW50MRUwEwYDVQQD
|
11
|
+
DAxodHRwLWFjY2VzczIwHhcNMDcwOTExMTM1ODMxWhcNMDkwOTEwMTM1ODMxWjBN
|
12
|
+
MQswCQYDVQQGEwJKUDERMA8GA1UECgwIY3Rvci5vcmcxFDASBgNVBAsMC0RldmVs
|
13
|
+
b3BtZW50MRUwEwYDVQQDDAxodHRwLWFjY2VzczIwgZ8wDQYJKoZIhvcNAQEBBQAD
|
14
|
+
gY0AMIGJAoGBALi66ujWtUCQm5HpMSyr/AAIFYVXC/dmn7C8TR/HMiUuW3waY4uX
|
15
|
+
LFqCDAGOX4gf177pX+b99t3mpaiAjJuqc858D9xEECzhDWgXdLbhRqWhUOble4RY
|
16
|
+
c1yWYC990IgXJDMKx7VAuZ3cBhdBxtlE9sb1ZCzmHQsvTy/OoRzcJCrTAgMBAAGj
|
17
|
+
ge0wgeowDwYDVR0TAQH/BAUwAwEB/zAxBglghkgBhvhCAQ0EJBYiUnVieS9PcGVu
|
18
|
+
U1NMIEdlbmVyYXRlZCBDZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUJNE0GGaRKmN2qhnO
|
19
|
+
FyBWVl4Qj6owDgYDVR0PAQH/BAQDAgEGMHUGA1UdIwRuMGyAFCTRNBhmkSpjdqoZ
|
20
|
+
zhcgVlZeEI+qoVGkTzBNMQswCQYDVQQGEwJKUDERMA8GA1UECgwIY3Rvci5vcmcx
|
21
|
+
FDASBgNVBAsMC0RldmVsb3BtZW50MRUwEwYDVQQDDAxodHRwLWFjY2VzczKCAQEw
|
22
|
+
DQYJKoZIhvcNAQEFBQADgYEAH11tstSUuqFpMqoh/vM5l3Nqb8ygblbqEYQs/iG/
|
23
|
+
UeQkOZk/P1TxB6Ozn2htJ1srqDpUsncFVZ/ecP19GkeOZ6BmIhppcHhE5WyLBcPX
|
24
|
+
It5q1BW0PiAzT9LlEGoaiW0nw39so0Pr1whJDfc1t4fjdk+kSiMIzRHbTDvHWfpV
|
25
|
+
nTA=
|
26
|
+
-----END CERTIFICATE-----
|
27
|
+
END
|
28
|
+
|
29
|
+
cert = OpenSSL::X509::Certificate.new(pem_cert)
|
30
|
+
key_id = cert.extensions[2]
|
31
|
+
|
32
|
+
assert_equal "24:D1:34:18:66:91:2A:63:76:AA:19:CE:17:20:56:56:5E:10:8F:AA", key_id.value
|
33
|
+
end
|
34
|
+
end
|
data/test/test_pkey.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
if defined?(JRUBY_VERSION)
|
2
|
+
require "java"
|
3
|
+
base = File.dirname(__FILE__)
|
4
|
+
$CLASSPATH << File.join(base, '..', 'pkg', 'classes')
|
5
|
+
$CLASSPATH << File.join(base, '..', 'lib', 'bcprov-jdk14-139.jar')
|
6
|
+
end
|
7
|
+
|
8
|
+
begin
|
9
|
+
require "openssl"
|
10
|
+
rescue LoadError
|
11
|
+
end
|
12
|
+
|
13
|
+
require "test/unit"
|
14
|
+
|
15
|
+
class TestPKey < Test::Unit::TestCase
|
16
|
+
def test_has_correct_methods
|
17
|
+
pkey_methods = OpenSSL::PKey::PKey.instance_methods(false).sort - ["initialize"]
|
18
|
+
assert_equal ["sign", "verify"], pkey_methods
|
19
|
+
|
20
|
+
rsa_methods = OpenSSL::PKey::RSA.instance_methods(false).sort - ["initialize"]
|
21
|
+
assert_equal ["d", "d=", "dmp1", "dmp1=", "dmq1", "dmq1=", "e", "e=", "export", "iqmp", "iqmp=", "n", "n=", "p", "p=", "params", "private?", "private_decrypt", "private_encrypt", "public?", "public_decrypt", "public_encrypt", "public_key", "q", "q=", "to_der", "to_pem", "to_s", "to_text"], rsa_methods
|
22
|
+
|
23
|
+
assert_equal ["generate"], OpenSSL::PKey::RSA.methods(false)
|
24
|
+
|
25
|
+
# dsa_methods = OpenSSL::PKey::DSA.instance_methods(false).sort - ["initialize"]
|
26
|
+
# assert_equal ["export", "g", "g=", "p", "p=", "params", "priv_key", "priv_key=", "private?", "pub_key", "pub_key=", "public?", "public_key", "q", "q=", "syssign", "sysverify", "to_der", "to_pem", "to_s", "to_text"], dsa_methods
|
27
|
+
|
28
|
+
# assert_equal ["generate"], OpenSSL::PKey::DSA.methods(false)
|
29
|
+
end
|
30
|
+
|
31
|
+
#iqmp == coefficient
|
32
|
+
#e == public exponent
|
33
|
+
#n == modulus
|
34
|
+
#d == private exponent
|
35
|
+
#p == prime1
|
36
|
+
#q == prime2
|
37
|
+
#dmq1 == exponent2
|
38
|
+
#dmp1 == exponent1
|
39
|
+
|
40
|
+
def test_can_generate_rsa_key
|
41
|
+
OpenSSL::PKey::RSA.generate(512)
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_can_generate_dsa_key
|
45
|
+
end
|
46
|
+
end
|
data/test/ut_eof.rb
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
module TestEOF
|
4
|
+
def test_eof_0
|
5
|
+
open_file("") {|f|
|
6
|
+
assert_equal("", f.read(0))
|
7
|
+
assert_equal("", f.read(0))
|
8
|
+
assert_equal("", f.read)
|
9
|
+
assert_nil(f.read(0))
|
10
|
+
assert_nil(f.read(0))
|
11
|
+
}
|
12
|
+
open_file("") {|f|
|
13
|
+
assert_nil(f.read(1))
|
14
|
+
assert_equal("", f.read)
|
15
|
+
assert_nil(f.read(1))
|
16
|
+
}
|
17
|
+
open_file("") {|f|
|
18
|
+
s = "x"
|
19
|
+
assert_equal("", f.read(nil, s))
|
20
|
+
assert_equal("", s)
|
21
|
+
}
|
22
|
+
open_file("") {|f|
|
23
|
+
s = "x"
|
24
|
+
assert_nil(f.read(10, s))
|
25
|
+
assert_equal("", s)
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_eof_0_rw
|
30
|
+
return unless respond_to? :open_file_rw
|
31
|
+
open_file_rw("") {|f|
|
32
|
+
assert_equal("", f.read)
|
33
|
+
assert_equal("", f.read)
|
34
|
+
assert_equal(0, f.syswrite(""))
|
35
|
+
assert_equal("", f.read)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_eof_1
|
40
|
+
open_file("a") {|f|
|
41
|
+
assert_equal("", f.read(0))
|
42
|
+
assert_equal("a", f.read(1))
|
43
|
+
assert_equal("" , f.read(0))
|
44
|
+
assert_equal("" , f.read(0))
|
45
|
+
assert_equal("", f.read)
|
46
|
+
assert_nil(f.read(0))
|
47
|
+
assert_nil(f.read(0))
|
48
|
+
}
|
49
|
+
open_file("a") {|f|
|
50
|
+
assert_equal("a", f.read(1))
|
51
|
+
assert_nil(f.read(1))
|
52
|
+
}
|
53
|
+
open_file("a") {|f|
|
54
|
+
assert_equal("a", f.read(2))
|
55
|
+
assert_nil(f.read(1))
|
56
|
+
assert_equal("", f.read)
|
57
|
+
assert_nil(f.read(1))
|
58
|
+
}
|
59
|
+
open_file("a") {|f|
|
60
|
+
assert_equal("a", f.read)
|
61
|
+
assert_nil(f.read(1))
|
62
|
+
assert_equal("", f.read)
|
63
|
+
assert_nil(f.read(1))
|
64
|
+
}
|
65
|
+
open_file("a") {|f|
|
66
|
+
assert_equal("a", f.read(2))
|
67
|
+
assert_equal("", f.read)
|
68
|
+
assert_equal("", f.read)
|
69
|
+
}
|
70
|
+
open_file("a") {|f|
|
71
|
+
assert_equal("a", f.read)
|
72
|
+
assert_nil(f.read(0))
|
73
|
+
}
|
74
|
+
open_file("a") {|f|
|
75
|
+
s = "x"
|
76
|
+
assert_equal("a", f.read(nil, s))
|
77
|
+
assert_equal("a", s)
|
78
|
+
}
|
79
|
+
open_file("a") {|f|
|
80
|
+
s = "x"
|
81
|
+
assert_equal("a", f.read(10, s))
|
82
|
+
assert_equal("a", s)
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_eof_2
|
87
|
+
open_file("") {|f|
|
88
|
+
assert_equal("", f.read)
|
89
|
+
assert(f.eof?)
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_eof_3
|
94
|
+
open_file("") {|f|
|
95
|
+
assert(f.eof?)
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
module Seek
|
100
|
+
def open_file_seek(content, pos)
|
101
|
+
open_file(content) do |f|
|
102
|
+
f.seek(pos)
|
103
|
+
yield f
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_eof_0_seek
|
108
|
+
open_file_seek("", 10) {|f|
|
109
|
+
assert_equal(10, f.pos)
|
110
|
+
assert_equal("", f.read(0))
|
111
|
+
assert_equal("", f.read)
|
112
|
+
assert_nil(f.read(0))
|
113
|
+
assert_equal("", f.read)
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_eof_1_seek
|
118
|
+
open_file_seek("a", 10) {|f|
|
119
|
+
assert_equal("", f.read)
|
120
|
+
assert_equal("", f.read)
|
121
|
+
}
|
122
|
+
open_file_seek("a", 1) {|f|
|
123
|
+
assert_equal("", f.read)
|
124
|
+
assert_equal("", f.read)
|
125
|
+
}
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jruby-jruby-openssl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ola Bini and JRuby contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-06-11 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: = JRuby-OpenSSL
|
17
|
+
email: ola.bini@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- History.txt
|
24
|
+
- README.txt
|
25
|
+
- License.txt
|
26
|
+
files:
|
27
|
+
- History.txt
|
28
|
+
- README.txt
|
29
|
+
- License.txt
|
30
|
+
- lib/jopenssl.jar
|
31
|
+
- lib/bcmail-jdk14-139.jar
|
32
|
+
- lib/bcprov-jdk14-139.jar
|
33
|
+
- lib/openssl.rb
|
34
|
+
- lib/jopenssl/version.rb
|
35
|
+
- lib/openssl/bn.rb
|
36
|
+
- lib/openssl/buffering.rb
|
37
|
+
- lib/openssl/cipher.rb
|
38
|
+
- lib/openssl/digest.rb
|
39
|
+
- lib/openssl/dummy.rb
|
40
|
+
- lib/openssl/dummyssl.rb
|
41
|
+
- lib/openssl/ssl.rb
|
42
|
+
- lib/openssl/x509.rb
|
43
|
+
- test/pkcs7_mime_enveloped.message
|
44
|
+
- test/pkcs7_mime_signed.message
|
45
|
+
- test/pkcs7_multipart_signed.message
|
46
|
+
- test/test_cipher.rb
|
47
|
+
- test/test_integration.rb
|
48
|
+
- test/test_java.rb
|
49
|
+
- test/test_java_attribute.rb
|
50
|
+
- test/test_java_bio.rb
|
51
|
+
- test/test_java_mime.rb
|
52
|
+
- test/test_java_pkcs7.rb
|
53
|
+
- test/test_java_smime.rb
|
54
|
+
- test/test_openssl.rb
|
55
|
+
- test/test_openssl_x509.rb
|
56
|
+
- test/test_pkey.rb
|
57
|
+
- test/ut_eof.rb
|
58
|
+
- test/fixture/cacert.pem
|
59
|
+
- test/fixture/cert_localhost.pem
|
60
|
+
- test/fixture/localhost_keypair.pem
|
61
|
+
- test/openssl/ssl_server.rb
|
62
|
+
- test/openssl/test_asn1.rb
|
63
|
+
- test/openssl/test_cipher.rb
|
64
|
+
- test/openssl/test_digest.rb
|
65
|
+
- test/openssl/test_hmac.rb
|
66
|
+
- test/openssl/test_ns_spki.rb
|
67
|
+
- test/openssl/test_pair.rb
|
68
|
+
- test/openssl/test_pkcs7.rb
|
69
|
+
- test/openssl/test_pkey_rsa.rb
|
70
|
+
- test/openssl/test_ssl.rb
|
71
|
+
- test/openssl/test_x509cert.rb
|
72
|
+
- test/openssl/test_x509crl.rb
|
73
|
+
- test/openssl/test_x509ext.rb
|
74
|
+
- test/openssl/test_x509name.rb
|
75
|
+
- test/openssl/test_x509req.rb
|
76
|
+
- test/openssl/test_x509store.rb
|
77
|
+
- test/openssl/utils.rb
|
78
|
+
- test/ref/a.out
|
79
|
+
- test/ref/compile.rb
|
80
|
+
- test/ref/pkcs1
|
81
|
+
- test/ref/pkcs1.c
|
82
|
+
has_rdoc: false
|
83
|
+
homepage: http://jruby-extras.rubyforge.org/jruby-openssl
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options:
|
86
|
+
- --main
|
87
|
+
- README.txt
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
102
|
+
requirements: []
|
103
|
+
|
104
|
+
rubyforge_project: jruby-extras
|
105
|
+
rubygems_version: 1.2.0
|
106
|
+
signing_key:
|
107
|
+
specification_version: 3
|
108
|
+
summary: OpenSSL add-on for JRuby
|
109
|
+
test_files:
|
110
|
+
- test/test_cipher.rb
|
111
|
+
- test/test_integration.rb
|
112
|
+
- test/test_java.rb
|
113
|
+
- test/test_java_attribute.rb
|
114
|
+
- test/test_java_bio.rb
|
115
|
+
- test/test_java_mime.rb
|
116
|
+
- test/test_java_pkcs7.rb
|
117
|
+
- test/test_java_smime.rb
|
118
|
+
- test/test_openssl.rb
|
119
|
+
- test/test_openssl_x509.rb
|
120
|
+
- test/test_pkey.rb
|