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

[wip] remove deprecation warning #19512

Closed
wants to merge 1 commit into from
Closed
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
28 changes: 10 additions & 18 deletions spec/models/mixins/authentication_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,40 +266,32 @@ def self.name; "TestClass"; end
end
end

context ".validate_credentials_task" do
let(:args) { %w(userid password foo) }
context ".verify_credentials_task" do
let(:klass) { ManageIQ::Providers::Redhat::InfraManager }
let(:args) { {"userid" => "user", "password" => "pass", "other" => "value"} }
let(:queue_opts) do
{
:args => [*args],
:class_name => "ExtManagementSystem",
:method_name => "raw_connect?",
:args => [args],
:class_name => klass.name,
:method_name => "verify_credentials?",
:queue_name => "generic",
:role => "ems_operations",
:zone => 'zone'
}
end
let(:task_opts) do
{
:action => "Validate EMS Provider Credentials",
:action => "Verify EMS Provider Credentials",
:userid => 'userid'
}
end

it "returns success with no error message" do
it "queues background task" do
ok_task = FactoryBot.create(:miq_task, :status => 'Ok')
allow(MiqTask).to receive(:generic_action_with_callback).with(task_opts, queue_opts).and_return(1)
allow(MiqTask).to receive(:wait_for_taskid).with(1, :timeout => 30).and_return(ok_task)

expect(ExtManagementSystem.validate_credentials_task(args, 'userid', 'zone')).to eq([true, nil])
end

it "returns failure with an error message" do
message = 'Login failed due to a bad username or password.'
error_task = FactoryBot.create(:miq_task, :status => 'Error', :message => message)
allow(MiqTask).to receive(:generic_action_with_callback).with(task_opts, queue_opts).and_return(1)
allow(MiqTask).to receive(:wait_for_taskid).with(1, :timeout => 30).and_return(error_task)

expect(ExtManagementSystem.validate_credentials_task(args, 'userid', 'zone')).to eq([false, message])
task_id = klass.verify_credentials_task('userid', 'zone', args)
expect(task_id).to eq(1)
end
end

Expand Down