Skip to content

Commit

Permalink
Move VCR credentials into secrets.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tumido committed May 10, 2018
1 parent 3d3e706 commit 80e06e4
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
21 changes: 21 additions & 0 deletions spec/factories/ext_management_system.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FactoryGirl.define do
factory :ems_google_with_vcr_authentication, :parent => :ems_google do
zone do
_guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone
zone
end

after(:create) do |ems|
project = Rails.application.secrets.google.try(:[], 'project') || 'GOOGLE_PROJECT'
service_account = Rails.application.secrets.google.try(:[], 'service_account') || 'GOOGLE_SERVICE_ACCOUNT'

ems.authentications << FactoryGirl.create(
:authentication,
:type => "AuthToken",
:auth_key => service_account,
:userid => "_"
)
ems.update_attributes(:project => project)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
describe ManageIQ::Providers::Google::CloudManager::Refresher do
before(:each) do
_guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone
@google_json_key = "{\n \"type\": \"service_account\",\n \"project_id\": \"civil-tube-113314\",\n \"private_key_id\": \"bd99fda9d4a1e62f8371b7cd92ffcc6bb21ee453\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCR2KaVdHB3sMkm\\n8v8KZCPuKMvbUZ4oswT2ORRgm8hwJkMgvGpGAVnCRTwujXwm7ar7Acbopxzg4Qcm\\nb+DL6liyojrV3flbNiFcQniyMdjJxERyGKCEeLa+fGW9dNG2/v+2WAiQamywKgMA\\nlgR9bgaKZBPoDYIGpcwMqbXfCz/edUrWgf/sPw/EVePn56ARwEGE8azPyflP+tsM\\n2SskpW0SNJnHgwj3dKlH8iRXFTqGBaodM/864yb5IPTFkmR/3TPs9z+vbiyD/5zw\\nRbsSY9CRkP1ZU6qYn4KEbyv2eZ3J76oYJ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Wwop0bBvshCqPG43RL9pdr1\\nVpjHBc57W3oYLsWQ0NP/GhTIMRoCPdw+4B7VWWOhAoGAYEdx3cnDpPOTH1179GTv\\ny/q1LXvp8nP50HZ1Yc+wAOnifXBKhSTpjDqgru5OiGT7rggzyK0ui3nyfbwM5AH7\\nyQXmt8q0Nnzo8GdL+YKTfGbnmSwDH0SotEeofwruPuxOr7ows6joo283NOugudsx\\nUAa/tB/piHG/VYQ6dxb8zsg=\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"[email protected]\",\n \"client_id\": \"102455136987689387132\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/199203428544-compute%40developer.gserviceaccount.com\"\n}\n"
@ems = FactoryGirl.create(:ems_google, :zone => zone)
@ems.authentications << FactoryGirl.create(:authentication, :userid => "_", :auth_key => @google_json_key)
@ems.update_attributes(:project => "civil-tube-113314")

# A true thread may fail the test with VCR
allow(Thread).to receive(:new) do |*args, &block|
block.call(*args)
Class.new do
def join; end
end.new
end
@ems = FactoryGirl.create(:ems_google_with_vcr_authentication)
end

it "will perform a full refresh" do
Expand Down
17 changes: 17 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,26 @@
SimpleCov.start
end

require 'vcr'
require 'cgi'

VCR.configure do |config|
config.ignore_hosts 'codeclimate.com' if ENV['CI']
config.cassette_library_dir = File.join(ManageIQ::Providers::Google::Engine.root, 'spec/vcr_cassettes')

# Set your config/secrets.yml file
secrets = Rails.application.secrets

# Looks for provider subkeys you set in secrets.yml. Replace the values of
# those keys (both escaped or unescaped) with some placeholder text.
secrets.keys.each do |provider|
next if [:secret_key_base, :secret_token].include?(provider) # Defaults
cred_hash = secrets.public_send(provider)
cred_hash.each do |key, value|
config.filter_sensitive_data("#{provider.upcase}_#{key.upcase}") { CGI.escape(value) }
config.filter_sensitive_data("#{provider.upcase}_#{key.upcase}") { value }
end
end
end

Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f }
Expand Down

0 comments on commit 80e06e4

Please sign in to comment.