Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- HTTP Basic credentials set in Rails credentials are now read correctly. Rails
returns them as an `ActiveSupport::OrderedOptions`, which Flightdeck mistook
for a callable and resolved to nothing, leaving the dashboard unconfigured.

## [1.1.0] - 2026-08-12

### Added
Expand Down
6 changes: 5 additions & 1 deletion lib/flightdeck/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ def from_credentials
def normalize(source)
return nil if source.nil?

source = source.call if source.respond_to?(:call)
# Only genuine callables are invoked. `respond_to?(:call)` is not a safe
# test here: Rails credentials hand back an ActiveSupport::OrderedOptions,
# whose method_missing answers true for every name and returns nil for
# `call` — which used to swallow credential-configured auth entirely.
source = source.call if source.is_a?(Proc) || source.is_a?(Method)
return nil if source.nil?

username = fetch(source, :username)
Expand Down
21 changes: 21 additions & 0 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ class Flightdeck::ConfigurationTest < ActiveSupport::TestCase
end
end

test "resolve_http_basic reads credentials returned as OrderedOptions" do
# This is what Rails actually hands back for a nested credentials key, and
# it claims to respond_to?(:call) for every name.
credentials = ActiveSupport::OrderedOptions.new
credentials.username = "cred"
credentials.password = "secret"

Rails.application.credentials.stub(:flightdeck, credentials) do
assert_equal({ username: "cred", password: "secret" }, @config.resolve_http_basic)
end
end

test "resolve_http_basic reads explicit http_basic given as OrderedOptions" do
@config.http_basic = ActiveSupport::OrderedOptions.new.tap do |options|
options.username = "a"
options.password = "b"
end

assert_equal({ username: "a", password: "b" }, @config.resolve_http_basic)
end

test "base_controller_class defaults to ActionController::Base and constantizes when set" do
# Load the controller while nothing is configured, so this test cannot
# leave a half-defined constant behind for the rest of the suite.
Expand Down