Skip to content

Commit a31f0c8

Browse files
authored
Merge pull request #851 from agrare/move_fix_expires_at_to_shared_helper
Move fix_token_expries_at to spec/support
2 parents 0cec9e5 + 1f45d95 commit a31f0c8

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

spec/spec_helper.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,11 @@
1212
config.filter_run_excluding(:qpid_proton) unless ENV['CI'] || Gem.loaded_specs.key?(:qpid_proton)
1313
end
1414

15-
def fix_token_expires_at(interaction)
16-
data = JSON.parse(interaction.response.body)
17-
data["token"]["expires_at"] = "9999-12-31T23:59:59.999999Z"
18-
interaction.response.body = data.to_json.force_encoding('ASCII-8BIT')
19-
end
20-
2115
VCR.configure do |config|
2216
config.ignore_hosts 'codeclimate.com' if ENV['CI']
2317
config.cassette_library_dir = File.join(ManageIQ::Providers::Openstack::Engine.root, 'spec/vcr_cassettes')
2418

25-
config.before_record do |interaction|
26-
fix_token_expires_at(interaction) if interaction.request.uri.end_with?("v3/auth/tokens")
27-
end
19+
fix_token_expires_at(config)
2820

2921
secrets = Rails.application.secrets
3022
secrets.openstack.each_key do |secret|

spec/support/vcr_helper.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def fix_token_expires_at_interaction(interaction)
2+
return unless interaction.request.uri.end_with?("v3/auth/tokens")
3+
4+
data = JSON.parse(interaction.response.body)
5+
return if data.dig("token", "expires_at").nil?
6+
7+
data["token"]["expires_at"] = "9999-12-31T23:59:59.999999Z"
8+
interaction.response.body = data.to_json.force_encoding('ASCII-8BIT')
9+
end
10+
11+
def fix_token_expires_at(config)
12+
config.before_record { |interaction| fix_token_expires_at_interaction(interaction) }
13+
end

0 commit comments

Comments
 (0)