Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the rest of the options to the security hash for the rundeck config. #329

Merged
merged 1 commit into from
Sep 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions spec/classes/config/global/rundeck_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,71 @@
facts
end

describe "rundeck::config::global::rundeck_config class with use hmac request tokens parameter on #{os}" do
value = true
security_hash = {
'useHMacRequestTokens' => value
}
let(:params) { { security_config: security_hash } }

it { is_expected.to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.useHMacRequestTokens = #{value}}) }
end

describe "rundeck::config::global::rundeck_config class with use api cookie access parameter on #{os}" do
value = true
security_hash = {
'apiCookieAccess' => value
}
let(:params) { { security_config: security_hash } }

it { is_expected.to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.apiCookieAccess\.enabled = #{value}}) }
end

describe "rundeck::config::global::rundeck_config class with api tokens duration parameter on #{os}" do
duration = '0'
security_hash = {
'apiTokensDuration' => duration
}
let(:params) { { security_config: security_hash } }

it { is_expected.to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.api\.tokens\.duration\.max = #{duration}}) }
end

describe "rundeck::config::global::rundeck_config class with csrf referrer filter method parameter on #{os}" do
value = 'NONE'
security_hash = {
'csrfRefererFilterMethod' => value
}
let(:params) { { security_config: security_hash } }

it { is_expected.to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.csrf\.referer\.filterMethod = #{value}}) }
end

describe "rundeck::config::global::rundeck_config class with csrf referrer require https parameter on #{os}" do
value = true
security_hash = {
'csrfRefererRequireHttps' => value
}
let(:params) { { security_config: security_hash } }

it { is_expected.to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.csrf\.referer\.requireHttps = #{value}}) }
end

describe "rundeck::config::global::rundeck_config class with no security parameters on #{os}" do
bool_value = true
filter_method_parameter = 'NONE'
duration = '0'
security_hash = {}
let(:params) { { security_config: security_hash } }

it { is_expected.not_to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.useHMacRequestTokens = #{bool_value}}) }
it { is_expected.not_to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.apiCookieAccess\.enabled = #{bool_value}}) }
it { is_expected.not_to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.api\.tokens\.duration\.max = #{duration}}) }
it { is_expected.not_to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.csrf\.referer\.filterMethod = #{filter_method_parameter}}) }
it { is_expected.not_to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.csrf\.referer\.allowApi = #{bool_value}}) }
it { is_expected.not_to contain_file('/etc/rundeck/rundeck-config.groovy').with_content(%r{rundeck\.security\.csrf\.referer\.requireHttps = #{bool_value}}) }
end

describe "rundeck::config::global::rundeck_config class without any parameters on #{os}" do
let(:params) { {} }

Expand Down
16 changes: 16 additions & 0 deletions templates/rundeck-config.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,24 @@ loglevel.default = "<%= @rd_loglevel %>"
rdeck.base = "<%= @rdeck_base %>"
rss.enabled = "<%= @rss_enabled %>"

<%- if @security_config.key?('useHMacRequestTokens') -%>
rundeck.security.useHMacRequestTokens = <%= @security_config['useHMacRequestTokens'] %>
<%- end -%>
<%- if @security_config.key?('apiCookieAccess') -%>
rundeck.security.apiCookieAccess.enabled = <%= @security_config['apiCookieAccess'] %>
<%- end -%>
<%- if @security_config.key?('apiTokensDuration') -%>
rundeck.api.tokens.duration.max = <%= @security_config['apiTokensDuration'] %>
<%- end -%>
<%- if @security_config.key?('csrfRefererFilterMethod') -%>
rundeck.security.csrf.referer.filterMethod = <%= @security_config['csrfRefererFilterMethod'] %>
<%- end -%>
<%- if @security_config.key?('csrfRefererAllowApi') -%>
rundeck.security.csrf.referer.allowApi = <%= @security_config['csrfRefererAllowApi'] %>
<%- end -%>
<%- if @security_config.key?('csrfRefererRequireHttps') -%>
rundeck.security.csrf.referer.requireHttps = <%= @security_config['csrfRefererRequireHttps'] %>
<%- end -%>

dataSource {
dbCreate = "<%= @database_config['dbCreate'] %>"
Expand Down