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.
Auto merge of #3898 - frsyuki:git-http-configured-auth, r=indirect
Private access credentials for private git repositories Pull-request #2825 added support for authorization credentials provided by bundle-config for rubygems source. This change adds the same support for HTTP(S) URL of git source. Users can provide username and password as following: bundle config https://github.com/bundler/bundler.git username:password or export BUNDLE_GITHUB__COM=username:password Especially for private repositories on Github, users can use personal OAuth tokens: export BUNDLE_GITHUB__COM=abcd0123generatedtoken:x-oauth-basic This enables us to easily deploy ruby code hosted on github private repositories to production servers where storing shared password in plain text at `~/.git-credentials` is security risk.
- Loading branch information
Showing
2 changed files
with
52 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require "spec_helper" | ||
|
||
describe Bundler::Source::Git::GitProxy do | ||
let(:uri) { "https://github.com/bundler/bundler.git" } | ||
subject { described_class.new(Pathname("path"), uri, "HEAD") } | ||
|
||
context "with configured credentials" do | ||
it "adds username and password to URI" do | ||
Bundler.settings[uri] = "u:p" | ||
expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git")) | ||
subject.checkout | ||
end | ||
|
||
it "adds username and password to URI for host" do | ||
Bundler.settings["github.com"] = "u:p" | ||
expect(subject).to receive(:git_retry).with(match("https://u:p@github.com/bundler/bundler.git")) | ||
subject.checkout | ||
end | ||
|
||
it "does not add username and password to mismatched URI" do | ||
Bundler.settings["https://u:p@github.com/bundler/bundler-mismatch.git"] = "u:p" | ||
expect(subject).to receive(:git_retry).with(match(uri)) | ||
subject.checkout | ||
end | ||
|
||
it "keeps original userinfo" do | ||
Bundler.settings["github.com"] = "u:p" | ||
original = "https://orig:info@github.com/bundler/bundler.git" | ||
subject = described_class.new(Pathname("path"), original, "HEAD") | ||
expect(subject).to receive(:git_retry).with(match(original)) | ||
subject.checkout | ||
end | ||
end | ||
end |