From 71b068c825fc421f57c72e2c7415d4c3284a64d6 Mon Sep 17 00:00:00 2001 From: Yuri Rudman Date: Tue, 8 Aug 2017 17:07:29 -0400 Subject: [PATCH 1/2] having '$' sign inside double quotation for echo argument is interpreted as variable which need to be resolved. Single quotation need to be used to keep '$'. https://bugzilla.redhat.com/show_bug.cgi?id=1438974 --- .../pending/appliance_console/external_httpd_authentication.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/gems/pending/appliance_console/external_httpd_authentication.rb b/lib/gems/pending/appliance_console/external_httpd_authentication.rb index d8fce5802..5c5b3fcb2 100644 --- a/lib/gems/pending/appliance_console/external_httpd_authentication.rb +++ b/lib/gems/pending/appliance_console/external_httpd_authentication.rb @@ -128,7 +128,7 @@ def configure_sssd def configure_ipa_http_service say("Configuring IPA HTTP Service and Keytab ...") - AwesomeSpawn.run!("/bin/echo \"#{@password}\" | /usr/bin/kinit #{@principal}") + AwesomeSpawn.run!("/usr/bin/kinit", :params => [@principal], :stdin_data => @password) service = Principal.new(:hostname => @host, :realm => realm, :service => "HTTP", :ca_name => "ipa") service.register AwesomeSpawn.run!(IPA_GETKEYTAB, :params => {"-s" => @ipaserver, "-k" => HTTP_KEYTAB, "-p" => service.name}) From 782e12a35ec01bfbc69726f3a13d90456c959a3b Mon Sep 17 00:00:00 2001 From: Yuri Rudman Date: Wed, 9 Aug 2017 14:55:50 -0400 Subject: [PATCH 2/2] added rspec for ExternalHttpdAuthentication#configure_ipa_http_service https://bugzilla.redhat.com/show_bug.cgi?id=1438974 --- .../external_httpd_authentication_spec.rb | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/appliance_console/external_httpd_authentication_spec.rb b/spec/appliance_console/external_httpd_authentication_spec.rb index a3fa80ce8..c74d5ffca 100644 --- a/spec/appliance_console/external_httpd_authentication_spec.rb +++ b/spec/appliance_console/external_httpd_authentication_spec.rb @@ -1,6 +1,7 @@ require "active_support/all" require "appliance_console/external_httpd_authentication" require "appliance_console/prompts" +require "appliance_console/principal" require "linux_admin" describe ApplianceConsole::ExternalHttpdAuthentication do @@ -162,4 +163,25 @@ subject.post_activation end end + + context "#configure_ipa_http_service" do + before do + allow(subject).to receive(:say) + service = double("Principal") + allow(ApplianceConsole::Principal).to receive(:new).and_return(service) + allow(service).to receive(:register) + allow(service).to receive(:name) + allow(FileUtils).to receive(:chown) + allow(FileUtils).to receive(:chmod) + allow(AwesomeSpawn).to receive(:run!).with("/usr/sbin/ipa-getkeytab", anything) + end + + it "accept symbol '$' as part of password string" do + subject.instance_variable_set("@password", "$my_password") + expect(AwesomeSpawn).to receive(:run!).exactly(1).with("/usr/bin/kinit", + :params => ["admin"], + :stdin_data => "$my_password") + subject.send(:configure_ipa_http_service) + end + end end