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

fix undef variable check puppet6 #480

Closed
wants to merge 3 commits into from
Closed
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
117 changes: 117 additions & 0 deletions spec/classes/config/global/auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,123 @@
end
end

describe 'ldap force_binding_use_root' do
context 'by default' do
let(:params) do
{
auth_types: %w[ldap],
}
end

it { is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(%r{forceBindingLoginUseRootContextForRoles="false"}) }
end

context 'when set' do
let(:params) do
{
auth_types: %w[ldap],
auth_config: {
'ldap' => {
'force_binding_use_root' => true,
}
}
}
end

it { is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(%r{forceBindingLoginUseRootContextForRoles="true"}) }
end
end

describe 'when ldap and set bind_dn' do
let(:params) do
{
auth_types: %w[ldap],
auth_config: { 'ldap' => { 'bind_dn' => 'toto' } }
}
end

it do
is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(
%r{bindDn="toto"}
)
end
end

describe 'when ldap and set bind_password' do
let(:params) do
{
auth_types: %w[ldap],
auth_config: { 'ldap' => { 'bind_password' => 'toto' } }
}
end

it do
is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(
%r{bindPassword="toto"}
)
end
end

describe 'when pam and clear_pass' do
let(:params) do
{
auth_types: %w[pam],
auth_config: { 'pam' => { 'clear_pass' => 'toto' } }
}
end

it do
is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(
%r{clearPass="toto"}
)
end
end

describe 'when pam and try_first_pass' do
let(:params) do
{
auth_types: %w[pam],
auth_config: { 'pam' => { 'try_first_pass' => 'toto' } }
}
end

it do
is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(
%r{tryFirstPass="toto"}
)
end
end

describe 'when pam and use_first_pass' do
let(:params) do
{
auth_types: %w[pam],
auth_config: { 'pam' => { 'use_first_pass' => 'toto' } }
}
end

it do
is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(
%r{useFirstPass="toto"}
)
end
end

describe 'when pam and use_unix_groups' do
let(:params) do
{
auth_types: %w[pam],
auth_config: { 'pam' => { 'use_unix_groups' => 'toto' } }
}
end

it do
is_expected.to contain_file('/etc/rundeck/jaas-auth.conf').with_content(
%r{useUnixGroups="toto"}
)
end
end

describe 'with multiauth active_directory and file auth users array' do
let(:params) do
{
Expand Down
6 changes: 2 additions & 4 deletions templates/_auth_ldap.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ provider_url =
providerUrl="<%= provider_url %>"
authenticationMethod="simple"
forceBindingLogin="<%= @auth_config['ldap']['force_binding'] %>"
<%- if @auth_config['ldap']['force_binding_use_root'] != :undef -%>
forceBindingLoginUseRootContextForRoles="<%= @auth_config['ldap']['force_binding_use_root'] %>"
<%- end -%>
<%- if @auth_config['ldap']['bind_dn'] != :undef -%>
<%- if !@auth_config['ldap']['bind_dn'].nil? && @auth_config['ldap']['bind_dn'] != :undef -%>
bindDn="<%= @auth_config['ldap']['bind_dn']%>"
<%- end -%>
<%- if @auth_config['ldap']['bind_password'] != :undef -%>
<%- if !@auth_config['ldap']['bind_password'].nil? && @auth_config['ldap']['bind_password'] != :undef -%>
bindPassword="<%= @auth_config['ldap']['bind_password']%>"
<%- end -%>
userBaseDn="<%= @auth_config['ldap']['user_base_dn'] %>"
Expand Down
8 changes: 4 additions & 4 deletions templates/_auth_pam.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ org.rundeck.jaas.jetty.JettyPamLoginModule requisite
debug="true"
service="<%= @auth_config['pam']['service'] %>"
supplementalRoles="<%= @auth_config['pam']['supplemental_roles'].join(',') %>"
<%- if @auth_config['pam']['clear_pass'] != :undef -%>
<%- if !@auth_config['pam']['clear_pass'].nil? && @auth_config['pam']['clear_pass'] != :undef -%>
clearPass="<%= @auth_config['pam']['clear_pass'] %>"
<%- end -%>
<%- if @auth_config['pam']['try_first_pass'] != :undef -%>
<%- if !@auth_config['pam']['try_first_pass'].nil? && @auth_config['pam']['try_first_pass'] != :undef -%>
tryFirstPass="<%= @auth_config['pam']['try_first_pass'] %>"
<%- end -%>
<%- if @auth_config['pam']['use_first_pass'] != :undef -%>
<%- if !@auth_config['pam']['use_first_pass'].nil? && @auth_config['pam']['use_first_pass'] != :undef -%>
useFirstPass="<%= @auth_config['pam']['use_first_pass'] %>"
<%- end -%>
<%- if @auth_config['pam']['use_unix_groups'] != :undef -%>
<%- if !@auth_config['pam']['use_unix_groups'].nil? && @auth_config['pam']['use_unix_groups'] != :undef -%>
useUnixGroups="<%= @auth_config['pam']['use_unix_groups'] %>"
<%- end -%>
storePass="<%= @auth_config['pam']['store_pass'] %>";