-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathtest_config.rb
More file actions
50 lines (44 loc) · 1.23 KB
/
test_config.rb
File metadata and controls
50 lines (44 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding: US-ASCII
require File.expand_path('test_helper', File.dirname(__FILE__))
require "tempfile"
class TestSSL < TestCase
def setup
super
file = Tempfile.open("openssl.cnf")
file << <<__EOD__
HOME = .
[ ca ]
default_ca = CA_default
[ CA_default ]
dir = ./demoCA
certs = ./certs
__EOD__
file.close
@tmpfile = file
@it = OpenSSL::Config.new(file.path)
end
def test_s_parse
c = OpenSSL::Config.parse('')
assert_equal("[ default ]\n\n", c.to_s)
c = OpenSSL::Config.parse(@it.to_s)
assert_equal(['CA_default', 'ca', 'default'], c.sections.sort)
end
def test_s_parse_config
ret = OpenSSL::Config.parse_config(@it.to_s)
assert_equal(@it.sections.sort, ret.keys.sort)
assert_equal(@it["default"], ret["default"])
end
def test_sections
assert_equal(['CA_default', 'ca', 'default'], @it.sections.sort)
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
end