Skip to content

Commit 6e1d4aa

Browse files
committed
Add debug logging and offline test mode
1 parent e276162 commit 6e1d4aa

11 files changed

+18
-1
lines changed

lib/azure_blob/http.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ def sign_request(method)
116116

117117
def raise_error
118118
return unless raise_on_error
119+
warn "[AzureBlob] HTTP #{response.code} body: #{response.body}" if ENV["CI"]
119120
raise error_from_response.new(body: @response.body, status: @response.code&.to_i)
120121
end
121122

test/client/test_client.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class TestClient < TestCase
99
EXPIRATION = 120
1010

1111
def setup
12+
skip if offline?
1213
@account_name = ENV["AZURE_ACCOUNT_NAME"]
1314
@access_key = ENV["AZURE_ACCESS_KEY"]
1415
@container = ENV["AZURE_PRIVATE_CONTAINER"]

test/client/test_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,8 @@ def assert_match_content(expected, received)
1717
def using_shared_key
1818
!(ENV["AZURE_ACCESS_KEY"].nil? || ENV["AZURE_ACCESS_KEY"].empty?)
1919
end
20+
21+
def offline?
22+
ENV.key?("OFFLINE_TESTS_ONLY")
23+
end
2024
end

test/client/test_user_delegation_key.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class TestUserDelegationKey < TestCase
66
attr_reader :delegation_key, :account_name, :principal_id, :signer, :host
77
def setup
8-
skip if using_shared_key
8+
skip if using_shared_key || offline?
99
@account_name = ENV["AZURE_ACCOUNT_NAME"]
1010
@principal_id = ENV["AZURE_PRINCIPAL_ID"]
1111
@host = "https://#{account_name}.blob.core.windows.net"

test/rails/controllers/blobs/redirect_controller_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require "rails/database/setup"
55

66
class ActiveStorage::Blobs::RedirectControllerWithOpenRedirectTest < ActionDispatch::IntegrationTest
7+
setup { skip if offline? }
78
test "showing existing blob stored in azure" do
89
with_raise_on_open_redirects(:azure) do
910
blob = create_file_blob filename: "racecar.jpg", service_name: :azure

test/rails/controllers/direct_uploads_controller_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
class ActiveStorage::AzureBlobDirectUploadsControllerTest < ActionDispatch::IntegrationTest
88
setup do
9+
skip if offline?
910
@config = SERVICE_CONFIGURATIONS[:azure]
1011
ActiveStorage::Blob.service = ActiveStorage::Service.configure(:azure, SERVICE_CONFIGURATIONS)
1112
end

test/rails/controllers/representations/redirect_controller_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require "rails/database/setup"
55

66
class ActiveStorage::Representations::RedirectControllerWithOpenRedirectTest < ActionDispatch::IntegrationTest
7+
setup { skip if offline? }
78
test "showing existing variant stored in azure" do
89
with_raise_on_open_redirects(:azure) do
910
blob = create_file_blob filename: "racecar.jpg", service_name: :azure

test/rails/service/azure_blob_public_service_test.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class ActiveStorage::Service::AzureBlobPublicServiceTest < ActiveSupport::TestCa
99
include ActiveStorage::Service::SharedServiceTests
1010

1111
setup do
12+
skip if offline?
1213
@config = SERVICE_CONFIGURATIONS[:azure_public]
1314
end
1415

test/rails/service/azure_blob_service_test.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
class ActiveStorage::Service::AzureBlobServiceTest < ActiveSupport::TestCase
77
SERVICE = ActiveStorage::Service.configure(:azure, SERVICE_CONFIGURATIONS)
88

9+
setup { skip if offline? }
10+
911
include ActiveStorage::Service::SharedServiceTests
1012

1113
test "direct upload with content type" do

test/rails/service/shared_service_tests.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ module ActiveStorage::Service::SharedServiceTests
1010

1111
included do
1212
setup do
13+
skip if offline?
1314
@key = SecureRandom.base58(24)
1415
@service = self.class.const_get(:SERVICE)
1516
@service.upload @key, StringIO.new(FIXTURE_DATA)

0 commit comments

Comments
 (0)