Skip to content

Fix parallel test file collisions #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 20, 2025
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [Unreleased]

- Fix typo in class name `AzureBlob::ForbidenError` to `AzureBlob::ForbiddenError`
- Fix proper URI encoding for keys with special characters like question marks

## [0.5.8] 2025-05-14

- Add support for copying blobs across containers (#24)
Expand Down
6 changes: 4 additions & 2 deletions lib/azure_blob/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def blob_exist?(key, options = {})
#
# Returns a hash of the blob's tags.
def get_blob_tags(key)
uri = generate_uri("#{container}/#{key}?comp=tags")
uri = generate_uri("#{container}/#{key}")
uri.query = URI.encode_www_form(comp: "tags")
response = Http.new(uri, signer:).get

Tags.from_response(response).to_h
Expand Down Expand Up @@ -246,7 +247,8 @@ def delete_container(options = {})
#
# Example: +generate_uri("#{container}/#{key}")+
def generate_uri(path)
URI.parse(URI::RFC2396_PARSER.escape(File.join(host, path)))
encoded = path.split("/").map { |segment| CGI.escape(segment) }.join("/")
URI.parse([ host.chomp("/"), encoded ].join("/"))
end

# Returns an SAS signed URI
Expand Down
13 changes: 7 additions & 6 deletions test/client/test_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def setup
principal_id: @principal_id,
host: @host,
)
@key = "test client##{name}"
@uid = SecureRandom.uuid
@key = "test-client-?-#{name}-#{@uid}" # ? in key to test proper escaping
@content = "Some random content #{Random.rand(200)}"
end

Expand Down Expand Up @@ -197,9 +198,9 @@ def test_delete
end

def test_delete_prefix
prefix = "#{name}_prefix"
prefix = "#{name}_prefix_#{@uid}"
keys = 4.times.map do |i|
key = "#{prefix}/#{name}_#{i}"
key = "#{prefix}/#{i}"
client.create_block_blob(key, content)
key
end
Expand All @@ -212,7 +213,7 @@ def test_delete_prefix
end

def test_list_prefix
prefix = "#{name}_prefix"
prefix = "#{name}_prefix_#{@uid}"
@key = "#{prefix}/#{key}"
client.create_block_blob(key, content)

Expand All @@ -222,9 +223,9 @@ def test_list_prefix
end

def test_list_blobs_with_pages
prefix = "#{name}_prefix"
prefix = "#{name}_prefix_#{@uid}"
keys = 4.times.map do |i|
key = "#{prefix}/#{name}_#{i}"
key = "#{prefix}/#{i}"
client.create_block_blob(key, content)
key
end
Expand Down