Skip to content

Commit 4283318

Browse files
committed
fix(smoke): make docker probes runnable in real container environments
Stabilize docker smoke validation by allowing localhost traffic outside VCR cassettes and by adapting feed-creation assertions to the auto-source feature toggle. Decision: treat AUTO_SOURCE as environment-driven in smoke expectations so deployments with feature disabled still verify health/auth behavior without false negatives. This preserves strict VCR behavior for non-local traffic while restoring actionable smoke feedback for production-like checks.
1 parent 523fc72 commit 4283318

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

spec/smoke/docker_spec.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
let(:base_url) { ENV.fetch('SMOKE_BASE_URL', 'http://127.0.0.1:4000') }
99
let(:health_token) { ENV.fetch('SMOKE_HEALTH_TOKEN', 'health-check-token-xyz789') }
1010
let(:feed_token) { ENV.fetch('SMOKE_API_TOKEN', 'allow-any-urls-abcd-4321') }
11+
let(:auto_source_enabled) do
12+
ENV.fetch('SMOKE_AUTO_SOURCE_ENABLED', ENV.fetch('AUTO_SOURCE_ENABLED', 'false')) == 'true'
13+
end
1114

1215
def get_json(path, headers: {})
1316
uri = URI.join(base_url, path)
@@ -54,8 +57,15 @@ def perform_request(uri, request)
5457
}
5558

5659
response, body = post_json('/api/v1/feeds', body: payload)
57-
expect(response).to be_a(Net::HTTPUnauthorized)
58-
expect(body.dig('error', 'code')).to eq('UNAUTHORIZED')
60+
if auto_source_enabled
61+
expect(response).to be_a(Net::HTTPUnauthorized)
62+
expect(body.dig('error', 'code')).to eq('UNAUTHORIZED')
63+
else
64+
expect(response).to be_a(Net::HTTPForbidden)
65+
expect(body.dig('error', 'code')).to eq('FORBIDDEN')
66+
expect(body.dig('error', 'message')).to eq('Auto source feature is disabled')
67+
next
68+
end
5969

6070
response, body = post_json('/api/v1/feeds',
6171
body: payload,

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
VCR.configure do |config|
2525
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
2626
config.hook_into :faraday, :webmock
27+
config.ignore_localhost = true
2728
end
2829

2930
Dir[File.join(__dir__, 'support/**/*.rb')].each { |support_file| require support_file }

0 commit comments

Comments
 (0)