Skip to content

Commit

Permalink
Simplify writing default credentials in the cassettes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Nov 12, 2024
1 parent 700f6d3 commit 5285fed
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,34 @@

require "manageiq/providers/autosde"

def credentials_autosde_host
@credentials_autosde_host ||= "autosde-appliance-host"
end

def credentials_autosde_user
@credentials_autosde_user ||= "autosde"
end

def credentials_autosde_password
@credentials_autosde_password ||= "change_me"
end

VCR.configure do |config|
config.ignore_hosts 'codeclimate.com' if ENV['CI']
config.cassette_library_dir = File.join(ManageIQ::Providers::Autosde::Engine.root, 'spec/vcr_cassettes')
config.default_cassette_options = {:record => :none, :allow_unused_http_interactions => true}
config.hook_into :webmock

defaults = {
"appliance_host" => "autosde-appliance-host",
"site_manager_user" => "autosde",
"site_manager_password" => "change_me"
"appliance_host" => credentials_autosde_host,
"site_manager_user" => credentials_autosde_user,
"site_manager_password" => credentials_autosde_password
}
(Rails.application.credentials.autosde_defaults || defaults).each do |key, value|

# Sanitize the credentials when writing to the cassette to avoid leaking this information.
defaults.each do |key, value|
config.define_cassette_placeholder(value) do
Rails.application.credentials.dig(:autosde, key)
end
end
end

def credentials_autosde_host
@credentials_autosde_host ||= "autosde-appliance-host"
end

def credentials_autosde_user
@credentials_autosde_user ||= "autosde"
end

def credentials_autosde_password
@credentials_autosde_password ||= "change_me"
end

0 comments on commit 5285fed

Please sign in to comment.