Skip to content

Commit

Permalink
Merge pull request #11805 from agrare/bz_1382684_auth_check_host_no_c…
Browse files Browse the repository at this point in the history
…reds

Handle authentication_check on hosts with no credentials
(cherry picked from commit ec7c7e5)

https://bugzilla.redhat.com/show_bug.cgi?id=1384216
  • Loading branch information
jrafanie authored and chessbyte committed Oct 13, 2016
1 parent 7cbbb97 commit 456fb61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions app/models/mixins/authentication_mixin.rb
Expand Up @@ -246,11 +246,11 @@ def authentication_check_types(*args)
def authentication_check(*args)
options = args.last.kind_of?(Hash) ? args.last : {}
save = options.fetch(:save, true)
type = args.first
auth = authentication_best_fit(type)
status, details = authentication_check_no_validation(type || auth.authtype, options)
auth = authentication_best_fit(args.first)
type = args.first || auth.try(:authtype)
status, details = authentication_check_no_validation(type, options)

if save
if auth && save
status == :valid ? auth.validation_successful : auth.validation_failed(status, details)
end

Expand Down
8 changes: 4 additions & 4 deletions spec/models/mixins/authentication_mixin_spec.rb
Expand Up @@ -158,8 +158,9 @@ def self.name; "TestClass"; end

context "with a host and ems" do
before(:each) do
@host = FactoryGirl.create(:host_vmware_esx_with_authentication)
@ems = FactoryGirl.create(:ems_vmware_with_authentication)
@host = FactoryGirl.create(:host_vmware_esx_with_authentication)
@host_no_auth = FactoryGirl.create(:host_vmware_esx)
@ems = FactoryGirl.create(:ems_vmware_with_authentication)
MiqQueue.destroy_all
@auth = @ems.authentication_type(:default)
@orig_ems_user, @orig_ems_pwd = @ems.auth_user_pwd(:default)
Expand Down Expand Up @@ -366,8 +367,7 @@ def self.name; "TestClass"; end
end

it "missing credentials" do
allow(@host).to receive(:missing_credentials?).and_return(true)
expect(@host.authentication_check).to eq([false, "Missing credentials"])
expect(@host_no_auth.authentication_check).to eq([false, "Missing credentials"])
end

it "verify_credentials fails" do
Expand Down

0 comments on commit 456fb61

Please sign in to comment.