aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-06-28 23:38:05 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-04 21:38:36 +0900
commit6dc9b914cae52c8af6e1b4d1156613bcd914eaf5 (patch)
tree1c08759e790e6daa81cda32a063d6b20b26a9b31 /test
parentbf120798efa43c9db6c68e75037fc0a0c4735703 (diff)
downloadruby-openssl-6dc9b914cae52c8af6e1b4d1156613bcd914eaf5.tar.gz
Implement missing initialize_copytopic/fix-initialize-copy
Implement initialize_copy for: - OpenSSL::PKCS12 - OpenSSL::SSL::SSLSession - OpenSSL::X509::Attribute - OpenSSL::X509::Extension - OpenSSL::X509::Name - OpenSSL::X509::Revoked Remove initialize_copy from: - OpenSSL::SSL::SSLContext - OpenSSL::SSL::SSLSocket - OpenSSL::Engine - OpenSSL::X509::Store - OpenSSL::X509::StoreContext [Bug #12381]
Diffstat (limited to 'test')
-rw-r--r--test/test_engine.rb7
-rw-r--r--test/test_pkcs12.rb5
-rw-r--r--test/test_ssl.rb15
-rw-r--r--test/test_ssl_session.rb6
-rw-r--r--test/test_x509attr.rb8
-rw-r--r--test/test_x509ext.rb6
-rw-r--r--test/test_x509name.rb5
-rw-r--r--test/test_x509req.rb5
-rw-r--r--test/test_x509store.rb7
9 files changed, 63 insertions, 1 deletions
diff --git a/test/test_engine.rb b/test/test_engine.rb
index 1aa105f1..c236bd69 100644
--- a/test/test_engine.rb
+++ b/test/test_engine.rb
@@ -72,6 +72,13 @@ class OpenSSL::TestEngine < OpenSSL::TestCase
end;
end
+ def test_dup
+ with_openssl <<-'end;'
+ engine = get_engine
+ assert_raise(NoMethodError) { engine.dup }
+ end;
+ end
+
private
# this is required because OpenSSL::Engine methods change global state
diff --git a/test/test_pkcs12.rb b/test/test_pkcs12.rb
index 61fb4474..7ab501c4 100644
--- a/test/test_pkcs12.rb
+++ b/test/test_pkcs12.rb
@@ -180,6 +180,11 @@ Li8JsX5yIiuVYaBg/6ha3tOg4TCa5K/3r3tVliRZ2Es=
end
end
+ def test_dup
+ p12 = OpenSSL::PKCS12.create("pass", "name", TEST_KEY_RSA1024, @mycert)
+ assert_equal p12.to_der, p12.dup.to_der
+ end
+
private
def assert_cert expected, actual
[
diff --git a/test/test_ssl.rb b/test/test_ssl.rb
index 385eaee0..e7af8232 100644
--- a/test/test_ssl.rb
+++ b/test/test_ssl.rb
@@ -879,7 +879,7 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
return unless OpenSSL::SSL::SSLSocket.instance_methods.include?(:hostname)
ctx_proc = Proc.new do |ctx, ssl|
- foo_ctx = ctx.dup
+ foo_ctx = OpenSSL::SSL::SSLContext.new
ctx.servername_cb = Proc.new do |ssl2, hostname|
case hostname
@@ -1314,6 +1314,19 @@ end
pend "FIXME: SSLContext#key= currently does not raise because SSL_CTX_use_certificate() is delayed"
end
+ def test_dup
+ ctx = OpenSSL::SSL::SSLContext.new
+ sock1, sock2 = socketpair
+ ssl = OpenSSL::SSL::SSLSocket.new(sock1, ctx)
+
+ assert_raise(NoMethodError) { ctx.dup }
+ assert_raise(NoMethodError) { ssl.dup }
+ ensure
+ ssl.close if ssl
+ sock1.close
+ sock2.close
+ end
+
private
def start_server_version(version, ctx_proc=nil, server_proc=nil, &blk)
diff --git a/test/test_ssl_session.rb b/test/test_ssl_session.rb
index 84686f6b..9bcec101 100644
--- a/test/test_ssl_session.rb
+++ b/test/test_ssl_session.rb
@@ -369,6 +369,12 @@ __EOS__
assert(called[:get1])
assert(called[:get2])
end
+
+ def test_dup
+ sess_orig = OpenSSL::SSL::Session.new(DUMMY_SESSION)
+ sess_dup = sess_orig.dup
+ assert_equal(sess_orig.to_der, sess_dup.to_der)
+ end
end
end
diff --git a/test/test_x509attr.rb b/test/test_x509attr.rb
index 1ba8a875..69b8189b 100644
--- a/test/test_x509attr.rb
+++ b/test/test_x509attr.rb
@@ -51,6 +51,14 @@ class OpenSSL::TestX509Attribute < OpenSSL::TestCase
}
assert_equal(test_der, attr.to_der)
end
+
+ def test_dup
+ val = OpenSSL::ASN1::Set([
+ OpenSSL::ASN1::UTF8String("abc123")
+ ])
+ attr = OpenSSL::X509::Attribute.new("challengePassword", val)
+ assert_equal(attr.to_der, attr.dup.to_der)
+ end
end
end
diff --git a/test/test_x509ext.rb b/test/test_x509ext.rb
index 99e2eda5..33989873 100644
--- a/test/test_x509ext.rb
+++ b/test/test_x509ext.rb
@@ -62,6 +62,12 @@ class OpenSSL::TestX509Extension < OpenSSL::TestCase
%r{URI:ldap://ldap.example.com/cn=ca\?certificateRevocationList;binary},
cdp.value)
end
+
+ def test_dup
+ ext = OpenSSL::X509::Extension.new(@basic_constraints.to_der)
+ assert_equal(@basic_constraints.to_der, ext.to_der)
+ assert_equal(ext.to_der, ext.dup.to_der)
+ end
end
end
diff --git a/test/test_x509name.rb b/test/test_x509name.rb
index b87d415d..250f1d09 100644
--- a/test/test_x509name.rb
+++ b/test/test_x509name.rb
@@ -355,6 +355,11 @@ class OpenSSL::TestX509Name < OpenSSL::TestCase
expected = (d[0].ord & 0xff) | (d[1].ord & 0xff) << 8 | (d[2].ord & 0xff) << 16 | (d[3].ord & 0xff) << 24
assert_equal(expected, name_hash(name))
end
+
+ def test_dup
+ name = OpenSSL::X509::Name.parse("/CN=ruby-lang.org")
+ assert_equal(name.to_der, name.dup.to_der)
+ end
end
end
diff --git a/test/test_x509req.rb b/test/test_x509req.rb
index 287e2c18..086ccfbd 100644
--- a/test/test_x509req.rb
+++ b/test/test_x509req.rb
@@ -147,6 +147,11 @@ class OpenSSL::TestX509Request < OpenSSL::TestCase
issue_csr(0, @dn, @dsa512, OpenSSL::Digest::MD5.new) }
end
+ def test_dup
+ req = issue_csr(0, @dn, @rsa1024, OpenSSL::Digest::SHA1.new)
+ assert_equal(req.to_der, req.dup.to_der)
+ end
+
private
def request_error_returns_false
diff --git a/test/test_x509store.rb b/test/test_x509store.rb
index 8dee1679..e0fa07ac 100644
--- a/test/test_x509store.rb
+++ b/test/test_x509store.rb
@@ -222,6 +222,13 @@ class OpenSSL::TestX509Store < OpenSSL::TestCase
}
end
end
+
+ def test_dup
+ store = OpenSSL::X509::Store.new
+ assert_raise(NoMethodError) { store.dup }
+ ctx = OpenSSL::X509::StoreContext.new(store)
+ assert_raise(NoMethodError) { ctx.dup }
+ end
end
end