Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Rails.application.credentials instead of deprecated secrets #23254

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/models/mixins/miq_web_server_worker_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ def configure_secret_token(token = MiqDatabase.first.session_secret_token)
return if Rails.application.config.secret_key_base

Rails.application.config.secret_key_base = token

# To set a secret token after the Rails.application is initialized,
# we need to reset the secrets since they are cached:
# https://github.com/rails/rails/blob/4-2-stable/railties/lib/rails/application.rb#L386-L401
Rails.application.secrets = nil
end

def rails_server
Expand Down
6 changes: 3 additions & 3 deletions spec/models/firmware_registry/rest_api_depot_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
VCR.turn_on!
end

let(:host) { Rails.application.secrets.fwreg_rest_api_depot.try(:[], 'host') || 'host' }
let(:user) { Rails.application.secrets.fwreg_rest_api_depot.try(:[], 'userid') || 'username' }
let(:pass) { Rails.application.secrets.fwreg_rest_api_depot.try(:[], 'password') || 'password' }
let(:host) { Rails.application.credentials.fwreg_rest_api_depot.try(:[], 'host') || 'host' }
let(:user) { Rails.application.credentials.fwreg_rest_api_depot.try(:[], 'userid') || 'username' }
let(:pass) { Rails.application.credentials.fwreg_rest_api_depot.try(:[], 'password') || 'password' }
let(:url) { "http://#{host}/images/" }

describe '.fetch_from_remote' do
Expand Down
10 changes: 5 additions & 5 deletions spec/models/mixins/miq_web_server_worker_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
end

before do
@token = Rails.application.config.secret_key_base
@secrets = Rails.application.secrets
@token = Rails.application.config.secret_key_base
@credentials = Rails.application.credentials
MiqDatabase.seed
end

after do
Rails.application.config.secret_key_base = @token
Rails.application.secrets = @secrets
Rails.application.credentials = @credentials
end

it ".configure_secret_token defaults to MiqDatabase session_secret_token" do
Expand All @@ -43,8 +43,8 @@
it ".configure_secret_token does not reset secrets when token already configured" do
existing_value = SecureRandom.hex(64)
Rails.application.config.secret_key_base = existing_value
Rails.application.secrets = nil
Rails.application.secrets
Rails.application.credentials = nil
Rails.application.credentials

test_class.configure_secret_token
expect(Rails.application.config.secret_key_base).to eq(existing_value)
Expand Down