Skip to content
Closed
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
1 change: 1 addition & 0 deletions lib/azure_blob/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def sign_request(method)

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

Expand Down
1 change: 1 addition & 0 deletions test/client/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class TestClient < TestCase
EXPIRATION = 120

def setup
skip if offline?
@account_name = ENV["AZURE_ACCOUNT_NAME"]
@access_key = ENV["AZURE_ACCESS_KEY"]
@container = ENV["AZURE_PRIVATE_CONTAINER"]
Expand Down
4 changes: 4 additions & 0 deletions test/client/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ def assert_match_content(expected, received)
def using_shared_key
!(ENV["AZURE_ACCESS_KEY"].nil? || ENV["AZURE_ACCESS_KEY"].empty?)
end

def offline?
ENV.key?("OFFLINE_TESTS_ONLY")
end
end
2 changes: 1 addition & 1 deletion test/client/test_user_delegation_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class TestUserDelegationKey < TestCase
attr_reader :delegation_key, :account_name, :principal_id, :signer, :host
def setup
skip if using_shared_key
skip if using_shared_key || offline?
@account_name = ENV["AZURE_ACCOUNT_NAME"]
@principal_id = ENV["AZURE_PRINCIPAL_ID"]
@host = "https://#{account_name}.blob.core.windows.net"
Expand Down
1 change: 1 addition & 0 deletions test/rails/controllers/blobs/redirect_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "rails/database/setup"

class ActiveStorage::Blobs::RedirectControllerWithOpenRedirectTest < ActionDispatch::IntegrationTest
setup { skip if offline? }
test "showing existing blob stored in azure" do
with_raise_on_open_redirects(:azure) do
blob = create_file_blob filename: "racecar.jpg", service_name: :azure
Expand Down
1 change: 1 addition & 0 deletions test/rails/controllers/direct_uploads_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

class ActiveStorage::AzureBlobDirectUploadsControllerTest < ActionDispatch::IntegrationTest
setup do
skip if offline?
@config = SERVICE_CONFIGURATIONS[:azure]
ActiveStorage::Blob.service = ActiveStorage::Service.configure(:azure, SERVICE_CONFIGURATIONS)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require "rails/database/setup"

class ActiveStorage::Representations::RedirectControllerWithOpenRedirectTest < ActionDispatch::IntegrationTest
setup { skip if offline? }
test "showing existing variant stored in azure" do
with_raise_on_open_redirects(:azure) do
blob = create_file_blob filename: "racecar.jpg", service_name: :azure
Expand Down
1 change: 1 addition & 0 deletions test/rails/service/azure_blob_public_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class ActiveStorage::Service::AzureBlobPublicServiceTest < ActiveSupport::TestCa
include ActiveStorage::Service::SharedServiceTests

setup do
skip if offline?
@config = SERVICE_CONFIGURATIONS[:azure_public]
end

Expand Down
2 changes: 2 additions & 0 deletions test/rails/service/azure_blob_service_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
class ActiveStorage::Service::AzureBlobServiceTest < ActiveSupport::TestCase
SERVICE = ActiveStorage::Service.configure(:azure, SERVICE_CONFIGURATIONS)

setup { skip if offline? }

include ActiveStorage::Service::SharedServiceTests

test "direct upload with content type" do
Expand Down
1 change: 1 addition & 0 deletions test/rails/service/shared_service_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module ActiveStorage::Service::SharedServiceTests

included do
setup do
skip if offline?
@key = SecureRandom.base58(24)
@service = self.class.const_get(:SERVICE)
@service.upload @key, StringIO.new(FIXTURE_DATA)
Expand Down
4 changes: 4 additions & 0 deletions test/rails/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
require "debug"
require "action_view"
require "action_view/helpers"

def offline?
ENV.key?("OFFLINE_TESTS_ONLY")
end
ENV["RAILS_ENV"] ||= "test"
require_relative "dummy/config/environment.rb"

Expand Down
Loading