This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jeremy Tryba
committed
Jul 8, 2014
1 parent
ec0ef95
commit 26214a3
Showing
4 changed files
with
45 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
describe Bundler::S3Fetcher do | ||
before do | ||
allow(Bundler).to receive(:root){ Pathname.new("root") } | ||
end | ||
|
||
describe "sign" do | ||
it "requires authentication" do | ||
url = "s3://foo" | ||
expect { Bundler::S3Fetcher.new(url).sign(URI(url))}.to raise_error(Bundler::Fetcher::AuthenticationRequiredError) | ||
end | ||
|
||
it "signs S3 requests" do | ||
accessId = "a" | ||
secretKey = "b" | ||
url = "s3://#{accessId}:#{secretKey}@foo" | ||
time = Time.utc(2014,6,1).to_i | ||
|
||
actual = Bundler::S3Fetcher.new(url).sign(URI(url),time) | ||
expect(actual.host).to eq "foo.s3.amazonaws.com" | ||
expect(actual.scheme).to eq "https" | ||
query = CGI.parse(actual.query) | ||
expect(query['AWSAccessKeyId']).to eq [accessId] | ||
expect(query['Expires']).to eq [time.to_s] | ||
expect(query['Signature']).to eq ["2ZFX8vg7E04u/UqUH9F/cKiQjJA="] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters