Skip to content

DRAFT: Feature/assuming IAM role when using s3 #34185

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
FEATURE: using class method in test, fixing init parm
  • Loading branch information
ducks committed Aug 10, 2025
commit 044ebcc103ab3c574ae2ed52066b0c30e279d129
12 changes: 4 additions & 8 deletions spec/lib/s3_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,6 @@
end

it "assumes role when all credentials present" do
s3_helper = S3Helper.new("some-bucket", "", client: client)

mock_credentials =
instance_double(
Aws::STS::Types::Credentials,
Expand All @@ -420,11 +418,11 @@
session_token: "TEMP_TOKEN",
)

allow(s3_helper).to receive(:assume_s3_role).and_return(mock_credentials)
allow(S3Helper).to receive(:assume_s3_role).and_return(mock_credentials)

opts = s3_helper.s3_options(Upload.new)
opts = S3Helper.s3_options(SiteSetting)

expect(s3_helper).to have_received(:assume_s3_role)
expect(S3Helper).to have_received(:assume_s3_role)
expect(opts[:access_key_id]).to eq("TEMP_KEY")
end
end
Expand All @@ -433,9 +431,7 @@
before { SiteSetting.s3_role_arn = "" }

it "uses regular credentials" do
s3_helper = S3Helper.new("some-bucket", "", client: client)

opts = s3_helper.s3_options(Upload.new)
opts = S3Helper.s3_options(SiteSetting)

expect(opts[:access_key_id]).to eq(SiteSetting.s3_access_key_id)
end
Expand Down
Loading