Skip to content

Commit

Permalink
better approach to avoid 'invalid configuration option' error
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zagaynov committed Oct 10, 2018
1 parent e5e5eb2 commit 0ad8451
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/models/authenticator/amazon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ def verify_credentials(access_key_id, secret_access_key)
def aws_connect(access_key_id, secret_access_key, service = :IAM, proxy_uri = nil)
service ||= :EC2
proxy_uri ||= VMDB::Util.http_proxy_uri
require "aws-sdk-#{service.to_s.downcase}"

require 'aws-sdk'
Aws.const_get(service)::Resource.new(
:access_key_id => access_key_id,
:secret_access_key => secret_access_key,
Expand Down
11 changes: 7 additions & 4 deletions spec/models/manageiq/providers/amazon/aws_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
require 'aws-sdk'
# frozen_string_literal: true

def with_aws_stubbed(stub_responses_per_service)
stub_responses_per_service.each do |service, stub_responses|
raise "Aws.config[#{service}][:stub_responses] already set" if Aws.config.fetch(service, {})[:stub_responses]
Aws.config[service] ||= {}
Aws.config[service][:stub_responses] = stub_responses
if Aws.config.dig(service, :stub_responses).present?
raise "Aws.config[#{service}][:stub_responses] already set"
else
require "aws-sdk-#{service.to_s.downcase}"
(Aws.config[service] ||= {})[:stub_responses] = stub_responses
end
end
yield
ensure
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
require_relative "../../aws_helper"

require 'aws-sdk-sqs'
require 'aws-sdk-sns'

describe ManageIQ::Providers::Amazon::CloudManager::EventCatcher::Stream do
subject do
ems = FactoryGirl.create(:ems_amazon_with_authentication)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
require_relative '../aws_stubs'
require_relative '../aws_refresher_spec_common'

require 'aws-sdk-cloudformation'

describe ManageIQ::Providers::Amazon::NetworkManager::Refresher do
include AwsRefresherSpecCommon
include AwsStubs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
require_relative '../aws_stubs'
require_relative '../aws_refresher_spec_common'

require 'aws-sdk-elasticloadbalancing'

describe ManageIQ::Providers::Amazon::NetworkManager::Refresher do
include AwsRefresherSpecCommon
include AwsStubs
Expand Down

0 comments on commit 0ad8451

Please sign in to comment.