Do not test detail of oslo::cors

This change makes unit test cases for ironic::cors and
ironic::inspector::cors, so that these tests do not test behavir of
oslo::cors but how oslo::cors resource type is called by ironic::cors
and ironic::inspector::cors.

Change-Id: I2305f4052dcce40c70ae3a16ff2ee6fcd0bfb8d9
This commit is contained in:
Takashi Kajinami
2021-07-01 17:55:04 +09:00
parent 12bc9b1d5e
commit 3570d4c7ff
2 changed files with 34 additions and 29 deletions

View File

@@ -2,14 +2,16 @@ require 'spec_helper'
describe 'ironic::cors' do
shared_examples_for 'ironic cors' do
shared_examples_for 'ironic::cors' do
it 'configure cors default params' do
is_expected.to contain_ironic_config('cors/allowed_origin').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ironic_config('cors/allow_credentials').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ironic_config('cors/expose_headers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ironic_config('cors/max_age').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ironic_config('cors/allow_methods').with_value('<SERVICE DEFAULT>')
is_expected.to contain_ironic_config('cors/allow_headers').with_value('<SERVICE DEFAULT>')
is_expected.to contain_oslo__cors('ironic_config').with(
:allowed_origin => '<SERVICE DEFAULT>',
:allow_credentials => '<SERVICE DEFAULT>',
:expose_headers => '<SERVICE DEFAULT>',
:max_age => '<SERVICE DEFAULT>',
:allow_methods => '<SERVICE DEFAULT>',
:allow_headers => '<SERVICE DEFAULT>',
)
end
context 'with specific parameters' do
@@ -24,12 +26,14 @@ describe 'ironic::cors' do
end
it 'configure cors params' do
is_expected.to contain_ironic_config('cors/allowed_origin').with_value('*')
is_expected.to contain_ironic_config('cors/allow_credentials').with_value(true)
is_expected.to contain_ironic_config('cors/expose_headers').with_value('Content-Language,Expires')
is_expected.to contain_ironic_config('cors/max_age').with_value(3600)
is_expected.to contain_ironic_config('cors/allow_methods').with_value('GET,POST,PUT,DELETE,OPTIONS')
is_expected.to contain_ironic_config('cors/allow_headers').with_value('Content-Type,Cache-Control')
is_expected.to contain_oslo__cors('ironic_config').with(
:allowed_origin => '*',
:allow_credentials => true,
:expose_headers => 'Content-Language,Expires',
:max_age => 3600,
:allow_methods => 'GET,POST,PUT,DELETE,OPTIONS',
:allow_headers => 'Content-Type,Cache-Control',
)
end
end
end
@@ -42,7 +46,7 @@ describe 'ironic::cors' do
facts.merge!(OSDefaults.get_facts())
end
it_behaves_like 'ironic cors'
it_behaves_like 'ironic::cors'
end
end

View File

@@ -2,16 +2,16 @@ require 'spec_helper'
describe 'ironic::inspector::cors' do
shared_examples_for 'ironic inspector cors' do
shared_examples_for 'ironic::inspector::cors' do
it 'configure cors default params' do
is_expected.to contain_oslo__cors('ironic_inspector_config').with(
:allowed_origin => '<SERVICE DEFAULT>',
:allow_credentials => '<SERVICE DEFAULT>',
:expose_headers => '<SERVICE DEFAULT>',
:max_age => '<SERVICE DEFAULT>',
:allow_methods => '<SERVICE DEFAULT>',
:allow_headers => '<SERVICE DEFAULT>')
:allowed_origin => '<SERVICE DEFAULT>',
:allow_credentials => '<SERVICE DEFAULT>',
:expose_headers => '<SERVICE DEFAULT>',
:max_age => '<SERVICE DEFAULT>',
:allow_methods => '<SERVICE DEFAULT>',
:allow_headers => '<SERVICE DEFAULT>',
)
end
context 'with specific parameters' do
@@ -27,12 +27,13 @@ describe 'ironic::inspector::cors' do
it 'configure cors params' do
is_expected.to contain_oslo__cors('ironic_inspector_config').with(
:allowed_origin => '*',
:allow_credentials => true,
:expose_headers => 'Content-Language,Expires',
:max_age => 3600,
:allow_methods => 'GET,POST,PUT,DELETE,OPTIONS',
:allow_headers => 'Content-Type,Cache-Control')
:allowed_origin => '*',
:allow_credentials => true,
:expose_headers => 'Content-Language,Expires',
:max_age => 3600,
:allow_methods => 'GET,POST,PUT,DELETE,OPTIONS',
:allow_headers => 'Content-Type,Cache-Control',
)
end
end
end
@@ -45,7 +46,7 @@ describe 'ironic::inspector::cors' do
facts.merge!(OSDefaults.get_facts())
end
it_configures 'ironic inspector cors'
it_behaves_like 'ironic::inspector::cors'
end
end