|
1 | 1 | require 'test_helper' |
2 | | -require 'minitest/stub_const' |
3 | 2 |
|
4 | 3 | describe Features::CandlepinDatabase do |
5 | 4 | include DefinitionsTestHelper |
6 | 5 | subject { Features::CandlepinDatabase.new } |
7 | | - let(:subject_ins) { Features::CandlepinDatabase.any_instance } |
8 | 6 |
|
9 | 7 | let(:cp_config_dir) do |
10 | 8 | File.expand_path('../../support', __dir__) |
11 | 9 | end |
12 | 10 |
|
13 | | - def stub_with_ssl_config(&block) |
14 | | - Features::CandlepinDatabase.stub_const(:CANDLEPIN_DB_CONFIG, |
15 | | - cp_config_dir + '/candlepin_with_ssl.conf', &block) |
16 | | - end |
17 | | - |
18 | | - def stub_without_ssl_config(&block) |
19 | | - Features::CandlepinDatabase.stub_const(:CANDLEPIN_DB_CONFIG, |
20 | | - cp_config_dir + '/candlepin_without_ssl.conf', &block) |
| 11 | + def stub_config(&block) |
| 12 | + subject.stub(:raw_config, File.read(File.join(cp_config_dir, config)), &block) |
21 | 13 | end |
22 | 14 |
|
23 | 15 | describe '.configuration' do |
24 | | - it 'The url includes ssl attributes when ssl is enabled' do |
25 | | - stub_with_ssl_config do |
26 | | - url = subject.configuration['url'] |
27 | | - assert_includes url, 'ssl=true' |
28 | | - assert_includes url, 'sslrootcert=/usr/share/foreman/root.crt' |
| 16 | + let(:configuration) { subject.configuration } |
| 17 | + |
| 18 | + describe 'with ssl' do |
| 19 | + let(:config) { 'candlepin_with_ssl.conf' } |
| 20 | + |
| 21 | + it 'sets ssl to true' do |
| 22 | + stub_config do |
| 23 | + assert_includes configuration['url'], 'ssl=true' |
| 24 | + assert configuration['ssl'] |
| 25 | + end |
29 | 26 | end |
30 | 27 | end |
31 | 28 |
|
32 | | - it 'The url does not include ssl attributes when ssl is disabled' do |
33 | | - stub_without_ssl_config do |
34 | | - url = subject.configuration['url'] |
35 | | - refute_includes url, 'ssl=true' |
36 | | - refute_includes url, 'sslrootcert=/usr/share/foreman/root.crt' |
| 29 | + describe 'without ssl' do |
| 30 | + let(:config) { 'candlepin_without_ssl.conf' } |
| 31 | + |
| 32 | + it 'sets ssl to false' do |
| 33 | + stub_config do |
| 34 | + refute_includes configuration['url'], 'ssl=true' |
| 35 | + refute configuration['ssl'] |
| 36 | + end |
37 | 37 | end |
38 | 38 | end |
39 | 39 | end |
|
0 commit comments