diff --git a/lib/embedded_ansible.rb b/lib/embedded_ansible.rb index e99d074013e..01b6acc2031 100644 --- a/lib/embedded_ansible.rb +++ b/lib/embedded_ansible.rb @@ -99,7 +99,7 @@ def find_or_create_database_authentication end def generate_password - SecureRandom.base64(18).tr("+/", "-_") + SecureRandom.hex(18) end def miq_database diff --git a/spec/lib/embedded_ansible_spec.rb b/spec/lib/embedded_ansible_spec.rb index ed28d25b3de..7ff3916dab3 100644 --- a/spec/lib/embedded_ansible_spec.rb +++ b/spec/lib/embedded_ansible_spec.rb @@ -231,5 +231,14 @@ expect(auth).to have_attributes(:userid => "awx", :password => "mypassword") end end + + describe "#generate_password (private)" do + it "doesn't include special characters" do + 100.times do + pass = subject.send(:generate_password) + expect(pass).to match(/^[a-zA-Z0-9]+$/) + end + end + end end end