Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
whitelist with any known variant of a license name
- Loading branch information
Matthew Kane Parker
committed
Sep 27, 2012
1 parent
64df005
commit 522327d
Showing
11 changed files
with
134 additions
and
25 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,24 @@ | ||
Feature: Whitelist licenses | ||
As a developer | ||
I want to whitelist certain OSS licenses that my business has pre-approved | ||
So that any dependencies with those licenses do not show up as action items | ||
|
||
Scenario: Auditing an application with whitelisted licenses | ||
Given I have an app with license finder | ||
And my app depends on a gem "mit_licensed_gem" licensed with "MIT" | ||
When I run "license_finder" | ||
Then I should see "mit_licensed_gem" in its output | ||
When I whitelist the following licenses: "MIT, other" | ||
And I run "license_finder" | ||
Then I should see "All gems are approved for use" in its output | ||
And it should exit with status code 0 | ||
|
||
Scenario: Whitelist with MIT License alternative name "Expat" should whitelist "MIT" licenses | ||
Given I have an app with license finder | ||
And "Expat" is an alternative name for the "MIT" license | ||
And my app depends on a gem "mit_licensed_gem" licensed with "MIT" | ||
When I run "license_finder" | ||
Then I should see "mit_licensed_gem" in its output | ||
When I whitelist the "Expat" license | ||
And I run "license_finder" | ||
Then I should not see "mit_licensed_gem" in its output |
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 |
---|---|---|
@@ -1,4 +1,15 @@ | ||
module LicenseFinder | ||
class Configuration < LicenseFinder::Persistence::Configuration | ||
def whitelisted?(license_name) | ||
license = License.find_by_name(license_name) || license_name | ||
whitelisted_licenses.include? license | ||
end | ||
|
||
private | ||
def whitelisted_licenses | ||
whitelist.map do |license_name| | ||
LicenseFinder::License.find_by_name(license_name) || license_name | ||
end.compact | ||
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
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
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,27 @@ | ||
require "spec_helper" | ||
|
||
describe LicenseFinder::Configuration do | ||
it_behaves_like "a persistable configuration" | ||
|
||
describe "whitelisted?" do | ||
let(:config) { LicenseFinder::Configuration.new } | ||
|
||
context "canonical name whitelisted" do | ||
before { config.whitelist = [LicenseFinder::License::Apache2.names[rand(0...LicenseFinder::License::Apache2.names.count)]]} | ||
|
||
let(:possible_license_names) { LicenseFinder::License::Apache2.names } | ||
|
||
it "should return true if if the license is the canonical name, pretty name, or alternative name of the license" do | ||
possible_license_names.each do |name| | ||
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't." | ||
end | ||
end | ||
|
||
it "should be case-insensitive" do | ||
possible_license_names.map(&:downcase).each do |name| | ||
config.whitelisted?(name).should be_true, "expected #{name} to be whitelisted, but wasn't" | ||
end | ||
end | ||
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
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
5 changes: 0 additions & 5 deletions
5
spec/lib/license_finder/persistence/yaml/configuration_spec.rb
This file was deleted.
Oops, something went wrong.