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 errors in help message #17009

Merged
merged 1 commit into from
Feb 15, 2018
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
12 changes: 6 additions & 6 deletions spec/tools/miqldap_to_sssd/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

describe MiqLdapToSssd::Cli do
before do
@all_options = :tls_cacert, :tls_cacertdir, :basedn_domain, :only_change_userids, :skip_post_coversion_userid_change
@all_options = :tls_cacert, :tls_cacertdir, :domain, :only_change_userids, :skip_post_conversion_userid_change
stub_const("LOGGER", double)
allow(LOGGER).to receive(:debug)
end

describe "#parse" do
it "should assign defaults" do
opts = described_class.new.parse([]).options.slice(*@all_options)
expect(opts).to eq(:only_change_userids => false, :skip_post_coversion_userid_change => false)
expect(opts).to eq(:only_change_userids => false, :skip_post_conversion_userid_change => false)
end

it "should parse base DN domain names" do
opts = described_class.new.parse(%w(-d example.com)).options.slice(:basedn_domain)
expect(opts).to eq(:basedn_domain => "example.com")
opts = described_class.new.parse(%w(-d example.com)).options.slice(:domain)
expect(opts).to eq(:domain => "example.com")
end

it "should parse bind DN" do
Expand All @@ -37,12 +37,12 @@

it "can only updating the userids" do
opts = described_class.new.parse(%w(-n)).options.slice(*@all_options)
expect(opts).to eq(:only_change_userids => true, :skip_post_coversion_userid_change => false)
expect(opts).to eq(:only_change_userids => true, :skip_post_conversion_userid_change => false)
end

it "can skip updating the userids after the conversion" do
opts = described_class.new.parse(%w(-s)).options.slice(*@all_options)
expect(opts).to eq(:only_change_userids => false, :skip_post_coversion_userid_change => true)
expect(opts).to eq(:only_change_userids => false, :skip_post_conversion_userid_change => true)
end
end
end
2 changes: 1 addition & 1 deletion spec/tools/miqldap_to_sssd/configure_apache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
end

before do
@initial_settings = {:basedn_domain => "bob.your.uncle.com"}
@initial_settings = {:domain => "bob.your.uncle.com"}

@test_dir = "#{Dir.tmpdir}/#{@spec_name}"
@template_dir = "#{@test_dir}/TEMPLATE"
Expand Down
14 changes: 7 additions & 7 deletions spec/tools/miqldap_to_sssd/miqldap_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

describe MiqLdapToSssd::MiqLdapConfiguration do
describe '#retrieve_initial_settings' do
let(:settings) { {:tls_cacert => 'cert', :basedn_domain => "example.com"} }
let(:settings) { {:tls_cacert => 'cert', :domain => "example.com"} }

it 'raises an error when the basedn domain can not be determined' do
expect(MiqLdapToSssd::LOGGER).to receive(:fatal)
subject = described_class.new(settings.merge(:basedn => nil, :basedn_domain => nil))
subject = described_class.new(settings.merge(:basedn => nil, :domain => nil))
expect { subject.retrieve_initial_settings }.to raise_error(MiqLdapToSssd::MiqLdapConfigurationArgumentError)
end

Expand Down Expand Up @@ -36,14 +36,14 @@
expect { subject.retrieve_initial_settings }.to_not raise_error
end

it 'does not modify basedn_domain if provided' do
subject = described_class.new(settings.merge(:basedn_domain => "example.com"))
expect(subject.retrieve_initial_settings[:basedn_domain]).to eq("example.com")
it 'does not modify domain if provided' do
subject = described_class.new(settings.merge(:domain => "example.com"))
expect(subject.retrieve_initial_settings[:domain]).to eq("example.com")
end

it 'sets basedn_domain from mixed case basedn' do
it 'sets domain from mixed case basedn' do
subject = described_class.new(settings.merge(:basedn => "CN=Users,DC=Example,DC=COM"))
expect(subject.retrieve_initial_settings[:basedn_domain]).to eq("example.com")
expect(subject.retrieve_initial_settings[:domain]).to eq("example.com")
end
end
end
8 changes: 4 additions & 4 deletions tools/miqldap_to_sssd/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ def parse(args)
self.options = Trollop.options(args) do
banner "Usage: ruby #{$PROGRAM_NAME} [options]\n"

opt :basedn_domain,
"The Base DN domain name, e.g. example.com",
opt :domain,
"The domain name for the Base DN, e.g. example.com",
:short => "d",
:default => nil,
:type => :string
Expand All @@ -25,7 +25,7 @@ def parse(args)
:type => :string

opt :bind_pwd,
"The Base DN domain name, e.g. example.com",
"The password for the Bind DN.",
:short => "p",
:default => nil,
:type => :string
Expand All @@ -42,7 +42,7 @@ def parse(args)
:default => false,
:type => :flag

opt :skip_post_coversion_userid_change,
opt :skip_post_conversion_userid_change,
"Do the MiqLdap to SSSD conversion but skip the normalizing of the userids",
:short => "s",
:default => false,
Expand Down
2 changes: 1 addition & 1 deletion tools/miqldap_to_sssd/configure_apache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def update_realm

begin
miq_ext_auth = File.read("#{HTTPD_CONF_DIR}/manageiq-external-auth.conf")
miq_ext_auth[/(\s*)KrbAuthRealms(\s*)(.*)/, 3] = initial_settings[:basedn_domain]
miq_ext_auth[/(\s*)KrbAuthRealms(\s*)(.*)/, 3] = initial_settings[:domain]
File.write("#{HTTPD_CONF_DIR}/manageiq-external-auth.conf", miq_ext_auth)
rescue Errno::ENOENT, IndexError => err
LOGGER.fatal(err.message)
Expand Down
2 changes: 1 addition & 1 deletion tools/miqldap_to_sssd/converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def run
LOGGER.debug("Running #{$PROGRAM_NAME}")

do_conversion unless initial_settings[:only_change_userids]
ConfigureDatabase.new.change_userids_to_upn unless initial_settings[:skip_post_coversion_userid_change]
ConfigureDatabase.new.change_userids_to_upn unless initial_settings[:skip_post_conversion_userid_change]

Services.restart

Expand Down
10 changes: 5 additions & 5 deletions tools/miqldap_to_sssd/miqldap_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def retrieve_initial_settings

private

def check_for_basedn_domain
if initial_settings[:basedn_domain].nil? && initial_settings[:basedn].nil?
def check_for_domain
if initial_settings[:domain].nil? && initial_settings[:basedn].nil?
LOGGER.fatal(NO_BASE_DN_DOMAIN)
raise MiqLdapConfigurationArgumentError, NO_BASE_DN_DOMAIN
end
Expand Down Expand Up @@ -65,11 +65,11 @@ def current_authentication_settings
end

def derive_domain
check_for_basedn_domain
check_for_domain

# If the caller did not provide a base DN domain name derive it from the configured Base DN.
if initial_settings[:basedn_domain].nil?
initial_settings[:basedn_domain] = initial_settings[:basedn].downcase.split(",").collect do |p|
if initial_settings[:domain].nil?
initial_settings[:domain] = initial_settings[:basedn].downcase.split(",").collect do |p|
p.split('dc=')[1]
end.compact.join('.')
end
Expand Down
4 changes: 2 additions & 2 deletions tools/miqldap_to_sssd/sssd_conf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def write_updates(sssd_conf_contents)
File.open(SSSD_CONF_FILE, "w") do |f|
sssd_conf_contents.each do |section, values|
if section == :domain
f.write("\n[domain/#{initial_settings[:basedn_domain]}]\n")
f.write("\n[application/#{initial_settings[:basedn_domain]}]\n")
f.write("\n[domain/#{initial_settings[:domain]}]\n")
f.write("\n[application/#{initial_settings[:domain]}]\n")
else
f.write("\n[#{section}]\n")
end
Expand Down
4 changes: 2 additions & 2 deletions tools/miqldap_to_sssd/sssd_conf/sssd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def config_file_version
end

def default_domain_suffix
initial_settings[:basedn_domain]
initial_settings[:domain]
end

def domains
initial_settings[:basedn_domain]
initial_settings[:domain]
end

def sbus_timeout
Expand Down