Skip to content

Commit

Permalink
Merge pull request #851 from agrare/move_fix_expires_at_to_shared_helper
Browse files Browse the repository at this point in the history
Move fix_token_expries_at to spec/support
  • Loading branch information
Fryguy committed Jun 6, 2023
2 parents 0cec9e5 + 1f45d95 commit a31f0c8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
10 changes: 1 addition & 9 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,11 @@
config.filter_run_excluding(:qpid_proton) unless ENV['CI'] || Gem.loaded_specs.key?(:qpid_proton)
end

def fix_token_expires_at(interaction)
data = JSON.parse(interaction.response.body)
data["token"]["expires_at"] = "9999-12-31T23:59:59.999999Z"
interaction.response.body = data.to_json.force_encoding('ASCII-8BIT')
end

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

config.before_record do |interaction|
fix_token_expires_at(interaction) if interaction.request.uri.end_with?("v3/auth/tokens")
end
fix_token_expires_at(config)

secrets = Rails.application.secrets
secrets.openstack.each_key do |secret|
Expand Down
13 changes: 13 additions & 0 deletions spec/support/vcr_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def fix_token_expires_at_interaction(interaction)
return unless interaction.request.uri.end_with?("v3/auth/tokens")

data = JSON.parse(interaction.response.body)
return if data.dig("token", "expires_at").nil?

data["token"]["expires_at"] = "9999-12-31T23:59:59.999999Z"
interaction.response.body = data.to_json.force_encoding('ASCII-8BIT')
end

def fix_token_expires_at(config)
config.before_record { |interaction| fix_token_expires_at_interaction(interaction) }
end

0 comments on commit a31f0c8

Please sign in to comment.