Skip to content

Commit 73b6eab

Browse files
committed
Fix user delegation keys not refreshing
Fix #14
1 parent b3f6431 commit 73b6eab

File tree

6 files changed

+24
-3
lines changed

6 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## [Unreleased]
22

3+
## [0.5.6] 2025-01-17
4+
5+
- Fix user delegation key not refreshing (#14)
6+
37
## [0.5.5] 2025-01-10
48

59
- Allow lazy loading the signer

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ GIT
9797
PATH
9898
remote: .
9999
specs:
100-
azure-blob (0.5.5)
100+
azure-blob (0.5.6)
101101
rexml
102102

103103
GEM

lib/azure_blob/identity_token.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def initialize(principal_id: nil)
1919
end
2020

2121
def to_s
22-
refresh if expired?
22+
refresh
2323
token
2424
end
2525

@@ -30,6 +30,7 @@ def expired?
3030
end
3131

3232
def refresh
33+
return unless expired?
3334
headers = { "Metadata" => "true" }
3435
headers["X-IDENTITY-HEADER"] = ENV["IDENTITY_HEADER"] if ENV["IDENTITY_HEADER"]
3536

lib/azure_blob/user_delegation_key.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def initialize(account_name:, signer:)
1515
end
1616

1717
def to_s
18+
refresh
1819
user_delegation_key
1920
end
2021

lib/azure_blob/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module AzureBlob
4-
VERSION = "0.5.5"
4+
VERSION = "0.5.6"
55
end

test/client/test_user_delegation_key.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,19 @@ def test_refresh_when_over_expiration_buffer
4242

4343
refute_equal initial_expiry, delegation_key.signed_expiry
4444
end
45+
46+
def test_to_s_refresh_automatically
47+
now = Time.now
48+
after_expiration_buffer = now + 21601
49+
Time.stub :now, now do
50+
@delegation_key = AzureBlob::UserDelegationKey.new(account_name:, signer:)
51+
end
52+
53+
initial_expiry = delegation_key.signed_expiry
54+
Time.stub :now, after_expiration_buffer do
55+
delegation_key.to_s
56+
end
57+
58+
refute_equal initial_expiry, delegation_key.signed_expiry
59+
end
4560
end

0 commit comments

Comments
 (0)