Skip to content

Commit 5d5f0f3

Browse files
New testcases for function set_version_to_options - TLS
Signed-off-by: Athishpranav2003 <[email protected]>
1 parent f83ff3a commit 5d5f0f3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/test_tls.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class UniqueIdTest < Test::Unit::TestCase
1010
'New TLS v1.2' => :'TLS1_2',
1111
'Old TLS v1.2' => :'TLSv1_2'
1212
}
13+
TEST_TLS1_3_CASES = {
14+
'New TLS v1.3' => :'TLS1_3',
15+
'Old TLS v1.3' => :'TLSv1_3'
16+
} if defined?(OpenSSL::SSL::TLS1_3_VERSION)
1317
TEST_TLS_CASES = TEST_TLS1_1_CASES.merge(TEST_TLS1_2_CASES)
1418

1519
sub_test_case 'constants' do
@@ -62,4 +66,26 @@ class UniqueIdTest < Test::Unit::TestCase
6266
}
6367
end
6468
end
69+
70+
sub_test_case 'set_version_to_options' do
71+
setup do
72+
@opt = {}
73+
end
74+
75+
test 'set min_version/max_version when supported' do
76+
omit "min_version=/max_version= is not supported" unless Fluent::TLS::MIN_MAX_AVAILABLE
77+
78+
ver = Fluent::TLS::DEFAULT_VERSION
79+
assert_raise(Fluent::ConfigError) {
80+
Fluent::TLS.set_version_to_options(@opt, ver, ver, nil)
81+
}
82+
assert_raise(Fluent::ConfigError) {
83+
Fluent::TLS.set_version_to_options(@opt, ver, nil, ver)
84+
}
85+
86+
ver = :'TLSv1_3' if defined?(OpenSSL::SSL::TLS1_3_VERSION)
87+
assert_equal Fluent::TLS.const_get(:METHODS_MAP)[ver], Fluent::TLS.set_version_to_options(@opt, ver, nil, nil)[:min_version]
88+
assert_equal Fluent::TLS.const_get(:METHODS_MAP)[ver], Fluent::TLS.set_version_to_options(@opt, ver, nil, nil)[:max_version]
89+
end
90+
end
6591
end

0 commit comments

Comments
 (0)