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

Create/update Tower project with scm_credential #14618

Merged
merged 1 commit into from
Apr 17, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ module ManageIQ::Providers::AnsibleTower::Shared::AutomationManager::Configurati
include ProviderObjectMixin

module ClassMethods
def provider_params(params)
authentication_id = params.delete(:authentication_id)
params[:credential] = Authentication.find(authentication_id).manager_ref if authentication_id
params
end

def provider_collection(manager)
manager.with_provider_connection do |connection|
connection.api.projects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
let(:manager) { FactoryGirl.create(:provider_ansible_tower, :with_authentication).managers.first }
let(:atc) { double("AnsibleTowerClient::Connection", :api => api) }
let(:api) { double("AnsibleTowerClient::Api", :projects => projects) }
let(:credential) { FactoryGirl.create(:ansible_scm_credential, :manager_ref => '1') }

context "create through API" do
let(:projects) { double("AnsibleTowerClient::Collection", :create! => project) }
Expand Down Expand Up @@ -56,6 +57,20 @@
expect { described_class.create_in_provider(manager.id, params) }.to raise_error(ActiveRecord::RecordNotFound)
end

it ".create_in_provider with credential" do
params[:authentication_id] = credential.id
expect(AnsibleTowerClient::Connection).to receive(:new).and_return(atc)
store_new_project(project, manager)
expect(EmsRefresh).to receive(:queue_refresh_task).and_return([finished_task])
expect(ExtManagementSystem).to receive(:find).with(manager.id).and_return(manager)
expected_params = params.clone.merge(:credential => '1')
expected_params.delete(:authentication_id)
expect(projects).to receive(:create!).with(expected_params)
expected_notify[:options][:op_arg] = expected_params.to_s
expect(Notification).to receive(:create).with(expected_notify)
expect(described_class.create_in_provider(manager.id, params)).to be_a(described_class)
end

it ".create_in_provider_queue" do
EvmSpecHelper.local_miq_server
task_id = described_class.create_in_provider_queue(manager.id, params)
Expand Down