Skip to content

Commit

Permalink
Treat public source URLs with auth info in them as private.
Browse files Browse the repository at this point in the history
  • Loading branch information
benhoskings committed Nov 15, 2011
1 parent 5b95a7a commit 03fd4dd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/babushka/source.rb
Expand Up @@ -42,10 +42,10 @@ def self.default_remote_for name
def self.discover_uri_and_type path
if path.nil?
[nil, :implicit]
elsif path.to_s.sub(/^\w+:\/\//, '')[/^[^\/]+[@:]/]
[path.to_s, :private]
elsif path.to_s[/^(git|https?|file):\/\//]
[path.to_s, :public]
elsif path.to_s[/^(\w+@)?[a-zA-Z0-9.\-]+:/]
[path.to_s, :private]
else
[path.p, :local]
end
Expand Down
12 changes: 10 additions & 2 deletions spec/babushka/source_spec.rb
Expand Up @@ -19,7 +19,15 @@
it "should label nil paths as implicit" do
Source.discover_uri_and_type(nil).should == [nil, :implicit]
end
it "should work for public uris" do
it "should treat URLs containing auth info as private" do
[
'http://ben@server.org/benhoskings/babushka.git',
'https://ben:secret@server.org/benhoskings/babushka.git'
].each {|uri|
Source.discover_uri_and_type(uri).should == [uri, :private]
}
end
it "should treat git:// and friends as public" do
[
'git://github.com/benhoskings/babushka-deps.git',
'http://github.com/benhoskings/babushka-deps.git',
Expand All @@ -29,7 +37,7 @@
Source.discover_uri_and_type(uri).should == [uri, :public]
}
end
it "should work for private uris" do
it "should treat ssh-style URLs as private" do
[
'git@github.com:benhoskings/babushka-deps.git',
'benhoskin.gs:~ben/babushka-deps.git'
Expand Down

0 comments on commit 03fd4dd

Please sign in to comment.