summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2020-02-19 04:44:31 +0000
committerKazuki Yamaguchi <k@rhe.jp>2021-03-16 19:16:10 +0900
commit67f5847c617e49a314400cb8f1ff1d559492682c (patch)
tree59c50892caf1500941bc71ee4a9eeb9b71110f89 /test
parent4d8bce227c85ef4d1f8b794a8c96a7b23e4cf357 (diff)
[ruby/openssl] config: remove deprecated methods
Remove 4 deprecated methods. The following two methods have been marked as deprecated since 2003, by r4531 (ruby.git commit 78ff3833fb67c8005a9b851037e74b3eea940aa3). - OpenSSL::Config#value - OpenSSL::Config#section Other two methods are removed because the corresponding functions disappeared in OpenSSL 1.1.0. - OpenSSL::Config#add_value - OpenSSL::Config#[]= https://github.com/ruby/openssl/commit/9783d7f21c
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4275
Diffstat (limited to 'test')
-rw-r--r--test/openssl/test_config.rb128
1 files changed, 16 insertions, 112 deletions
diff --git a/test/openssl/test_config.rb b/test/openssl/test_config.rb
index f65392c18d..984a1150e6 100644
--- a/test/openssl/test_config.rb
+++ b/test/openssl/test_config.rb
@@ -214,28 +214,6 @@ __EOC__
assert_equal(ENV[key], @it.get_value('ENV', key))
end
- def test_value
- # suppress deprecation warnings
- EnvUtil.suppress_warning do
- assert_equal('CA_default', @it.value('ca', 'default_ca'))
- assert_equal(nil, @it.value('ca', 'no such key'))
- assert_equal(nil, @it.value('no such section', 'no such key'))
- assert_equal('.', @it.value('', 'HOME'))
- assert_equal('.', @it.value(nil, 'HOME'))
- assert_equal('.', @it.value('HOME'))
- # fallback to 'default' ugly...
- assert_equal('.', @it.value('unknown', 'HOME'))
- end
- end
-
- def test_value_ENV
- EnvUtil.suppress_warning do
- key = ENV.keys.first
- assert_not_nil(key) # make sure we have at least one ENV var.
- assert_equal(ENV[key], @it.value('ENV', key))
- end
- end
-
def test_aref
assert_equal({'HOME' => '.'}, @it['default'])
assert_equal({'dir' => './demoCA', 'certs' => './certs'}, @it['CA_default'])
@@ -243,65 +221,19 @@ __EOC__
assert_equal({}, @it[''])
end
- def test_section
- EnvUtil.suppress_warning do
- assert_equal({'HOME' => '.'}, @it.section('default'))
- assert_equal({'dir' => './demoCA', 'certs' => './certs'}, @it.section('CA_default'))
- assert_equal({}, @it.section('no_such_section'))
- assert_equal({}, @it.section(''))
- end
- end
-
def test_sections
assert_equal(['CA_default', 'ca', 'default'], @it.sections.sort)
- # OpenSSL::Config#[]= is deprecated
- EnvUtil.suppress_warning do
- @it['new_section'] = {'foo' => 'bar'}
- assert_equal(['CA_default', 'ca', 'default', 'new_section'], @it.sections.sort)
- @it['new_section'] = {}
- assert_equal(['CA_default', 'ca', 'default', 'new_section'], @it.sections.sort)
- end
- end
-
- def test_add_value
- # OpenSSL::Config#add_value is deprecated
- EnvUtil.suppress_warning do
- c = OpenSSL::Config.new
- assert_equal("", c.to_s)
- # add key
- c.add_value('default', 'foo', 'bar')
- assert_equal("[ default ]\nfoo=bar\n\n", c.to_s)
- # add another key
- c.add_value('default', 'baz', 'qux')
- assert_equal('bar', c['default']['foo'])
- assert_equal('qux', c['default']['baz'])
- # update the value
- c.add_value('default', 'baz', 'quxxx')
- assert_equal('bar', c['default']['foo'])
- assert_equal('quxxx', c['default']['baz'])
- # add section and key
- c.add_value('section', 'foo', 'bar')
- assert_equal('bar', c['default']['foo'])
- assert_equal('quxxx', c['default']['baz'])
- assert_equal('bar', c['section']['foo'])
- end
- end
-
- def test_aset
- # OpenSSL::Config#[]= is deprecated
- EnvUtil.suppress_warning do
- @it['foo'] = {'bar' => 'baz'}
- assert_equal({'bar' => 'baz'}, @it['foo'])
- @it['foo'] = {'bar' => 'qux', 'baz' => 'quxx'}
- assert_equal({'bar' => 'qux', 'baz' => 'quxx'}, @it['foo'])
-
- # OpenSSL::Config is add only for now.
- @it['foo'] = {'foo' => 'foo'}
- assert_equal({'foo' => 'foo', 'bar' => 'qux', 'baz' => 'quxx'}, @it['foo'])
- # you cannot override or remove any section and key.
- @it['foo'] = {}
- assert_equal({'foo' => 'foo', 'bar' => 'qux', 'baz' => 'quxx'}, @it['foo'])
- end
+ Tempfile.create("openssl.cnf") { |f|
+ f.write File.read(@tmpfile.path)
+ f.puts "[ new_section ]"
+ f.puts "foo = bar"
+ f.puts "[ empty_section ]"
+ f.close
+
+ c = OpenSSL::Config.new(f.path)
+ assert_equal(['CA_default', 'ca', 'default', 'empty_section', 'new_section'],
+ c.sections.sort)
+ }
end
def test_each
@@ -323,40 +255,12 @@ __EOC__
assert_match(/#<OpenSSL::Config sections=\[.*\]>/, @it.inspect)
end
- def test_freeze
- @it.freeze
-
- # Modifying OpenSSL::Config produces a warning
- EnvUtil.suppress_warning do
- bug = '[ruby-core:18377]'
- # RuntimeError for 1.9, TypeError for 1.8
- e = assert_raise(TypeError, bug) do
- @it['foo'] = [['key', 'wrong']]
- end
- assert_match(/can't modify/, e.message, bug)
- end
- end
-
def test_dup
- assert(!@it.sections.empty?)
- c = @it.dup
- assert_equal(@it.sections.sort, c.sections.sort)
- # OpenSSL::Config#[]= is deprecated
- EnvUtil.suppress_warning do
- @it['newsection'] = {'a' => 'b'}
- assert_not_equal(@it.sections.sort, c.sections.sort)
- end
- end
-
- def test_clone
- assert(!@it.sections.empty?)
- c = @it.clone
- assert_equal(@it.sections.sort, c.sections.sort)
- # OpenSSL::Config#[]= is deprecated
- EnvUtil.suppress_warning do
- @it['newsection'] = {'a' => 'b'}
- assert_not_equal(@it.sections.sort, c.sections.sort)
- end
+ assert_equal(['CA_default', 'ca', 'default'], @it.sections.sort)
+ c1 = @it.dup
+ assert_equal(@it.sections.sort, c1.sections.sort)
+ c2 = @it.clone
+ assert_equal(@it.sections.sort, c2.sections.sort)
end
private