diff options
| author | William Woodruff | 2018-02-07 11:20:19 -0500 |
|---|---|---|
| committer | William Woodruff | 2018-02-07 11:20:19 -0500 |
| commit | b4443e1cc0b41d2b25ca15b87c3d4cb2ab65837f (patch) | |
| tree | 083a7075c8889d40694c9b3f71bd3bfa15f6f5fe /Library/Homebrew/test | |
| parent | af8f8f11e32fe78677fc1d4cd62c07a29dc6d326 (diff) | |
| parent | 3f43f60a2a52617bfc906f6f08863fce774a8583 (diff) | |
| download | brew-b4443e1cc0b41d2b25ca15b87c3d4cb2ab65837f.tar.bz2 | |
Merge branch 'audit-deny-binary-looking-urls'
Diffstat (limited to 'Library/Homebrew/test')
| -rw-r--r-- | Library/Homebrew/test/dev-cmd/audit_spec.rb | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/Library/Homebrew/test/dev-cmd/audit_spec.rb b/Library/Homebrew/test/dev-cmd/audit_spec.rb index 2381ff1f5..38884222d 100644 --- a/Library/Homebrew/test/dev-cmd/audit_spec.rb +++ b/Library/Homebrew/test/dev-cmd/audit_spec.rb @@ -522,4 +522,82 @@ describe FormulaAuditor do end end end + + describe "#audit_url_is_not_binary" do + specify "it detects a url containing darwin and x86_64" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/example-darwin.x86_64.tar.gz" + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it detects a url containing darwin and amd64" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/example-darwin.amd64.tar.gz" + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it works on the devel spec" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/valid-1.0.tar.gz" + + devel do + url "https://example.com/example-darwin.x86_64.tar.gz" + end + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it works on the head spec" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/valid-1.0.tar.gz" + + head do + url "https://example.com/example-darwin.x86_64.tar.gz" + end + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems.first) + .to match("looks like a binary package, not a source archive. Official taps are source-only.") + end + + specify "it ignores resource urls" do + fa = formula_auditor "foo", <<~EOS, official_tap: true + class Foo < Formula + url "https://example.com/valid-1.0.tar.gz" + + resource "binary_res" do + url "https://example.com/example-darwin.x86_64.tar.gz" + end + end + EOS + + fa.audit_url_is_not_binary + + expect(fa.problems).to eq([]) + end + end end |
