Skip to content

Commit

Permalink
Remove Rails application secret and change to env secret to remove de…
Browse files Browse the repository at this point in the history
…praction warnings
  • Loading branch information
syed-ali-tw committed Nov 19, 2024
1 parent eb43db7 commit fac8567
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 33 deletions.
2 changes: 1 addition & 1 deletion app/controllers/link_checker_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def verify_signature
end

def webhook_secret_token
Rails.application.secrets.link_checker_api_secret_token
ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN")
end
end
2 changes: 1 addition & 1 deletion app/services/link_check_report_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def call_link_checker_api
GdsApi.link_checker_api.create_batch(
uris,
webhook_uri: callback_url,
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN"),
)
end

Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Application < Rails::Application
config.asset_host = ENV.fetch("ASSET_HOST", nil)

config.action_mailer.notify_settings = {
api_key: Rails.application.secrets.notify_api_key || "fake-test-api-key",
api_key: ENV.fetch("GOVUK_NOTIFY_API_KEY", "fake-test-api-key"),
}

config.generators do |g|
Expand Down
26 changes: 0 additions & 26 deletions config/secrets.yml

This file was deleted.

2 changes: 1 addition & 1 deletion test/functional/link_check_reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LinkCheckReportsControllerTest < ActionController::TestCase
uris: ["https://www.gov.uk"],
id: 1234,
webhook_uri: link_checker_api_callback_url(host: Plek.find("publisher")),
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV["LINK_CHECKER_API_SECRET_TOKEN"],
)
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/link_checker_api_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def campaign_edition_link_check_report
def set_headers(post_body)
headers = {
"Content-Type": "application/json",
"X-LinkCheckerApi-Signature": generate_signature(post_body.to_json, Rails.application.secrets.link_checker_api_secret_token),
"X-LinkCheckerApi-Signature": generate_signature(post_body.to_json, ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN")),
}

request.headers.merge! headers
Expand Down
2 changes: 1 addition & 1 deletion test/integration/edition_link_check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EditionLinkCheckTest < LegacyJavascriptIntegrationTest
uris: ["https://www.gov.uk"],
id: 1234,
webhook_uri: link_checker_api_callback_url(host: Plek.find("publisher")),
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN"),
)

@place = FactoryBot.create(:place_edition, introduction: "This is [link](https://www.gov.uk) text.")
Expand Down
2 changes: 1 addition & 1 deletion test/unit/services/link_check_report_creator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create_edition(govspeak)
uris: ["https://www.gov.uk"],
id: 1234,
webhook_uri: link_checker_api_callback_url(host: Plek.find("publisher")),
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN"),
)
end

Expand Down

0 comments on commit fac8567

Please sign in to comment.