diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/fixtures/expected/csharp/nuget-dotnetcore/v2.0.json | 20 | ||||
| -rw-r--r-- | spec/integration/dotnet/nuget_spec.rb | 7 | ||||
| -rw-r--r-- | spec/support/shared.rb | 8 | ||||
| -rw-r--r-- | spec/unit/license/management/repository_spec.rb | 7 |
4 files changed, 20 insertions, 22 deletions
diff --git a/spec/fixtures/expected/csharp/nuget-dotnetcore/v2.0.json b/spec/fixtures/expected/csharp/nuget-dotnetcore/v2.0.json index 920f7de..070401e 100644 --- a/spec/fixtures/expected/csharp/nuget-dotnetcore/v2.0.json +++ b/spec/fixtures/expected/csharp/nuget-dotnetcore/v2.0.json @@ -14,6 +14,12 @@ "count": 2 }, { + "id": "MIT", + "name": "MIT License", + "url": "https://opensource.org/licenses/MIT", + "count": 2 + }, + { "id": "https://github.com/dotnet/corefx/blob/master/license.txt", "name": "https://github.com/dotnet/corefx/blob/master/LICENSE.TXT", "url": "", @@ -32,18 +38,6 @@ "count": 1 }, { - "id": "MIT", - "name": "MIT License", - "url": "https://opensource.org/licenses/MIT", - "count": 1 - }, - { - "id": "http://www.opensource.org/licenses/mit-license.php", - "name": "http://www.opensource.org/licenses/mit-license.php", - "url": "", - "count": 1 - }, - { "id": "https://raw.githubusercontent.com/antlr/antlrcs/master/license.txt", "name": "https://raw.githubusercontent.com/antlr/antlrcs/master/LICENSE.txt", "url": "", @@ -120,7 +114,7 @@ "./src/web.api" ], "licenses": [ - "http://www.opensource.org/licenses/mit-license.php" + "MIT" ] }, { diff --git a/spec/integration/dotnet/nuget_spec.rb b/spec/integration/dotnet/nuget_spec.rb index 3dce774..456bef7 100644 --- a/spec/integration/dotnet/nuget_spec.rb +++ b/spec/integration/dotnet/nuget_spec.rb @@ -70,11 +70,8 @@ RSpec.describe "nuget" do expect(report).not_to be_empty expect(report).to match_schema(version: '2.0') - # expect(report[:licenses].map { |x| x[:id] }.uniq).to match_array(['MIT']) - expect(report[:dependencies].map { |x| x[:name] }).to match_array([ - "jive", - "MvcMailer", - ]) + expect(find_in(report, 'jive')[:licenses]).to match_array(['MIT']) + expect(find_in(report, 'MvcMailer')[:licenses]).to match_array(['MIT']) end end diff --git a/spec/support/shared.rb b/spec/support/shared.rb index 8a7590b..a6aac67 100644 --- a/spec/support/shared.rb +++ b/spec/support/shared.rb @@ -2,14 +2,14 @@ RSpec.shared_examples "each report version" do |language, package_manager, branc [ '1.0', '1.1', '2.0' ].each do |version| context "when generating a `#{version}` report" do let(:url) { "https://gitlab.com/gitlab-org/security-products/tests/#{language}-#{package_manager}.git" } + let(:expected_content) { JSON.parse(fixture_file_content("expected/#{language}/#{package_manager}/v#{version}.json")) } it 'matches the expected report' do runner.clone(url, branch: branch) - report = runner.scan(env: { 'LM_REPORT_VERSION' => version }) + actual = runner.scan(env: { 'LM_REPORT_VERSION' => version }) - content = fixture_file_content("expected/#{language}/#{package_manager}/v#{version}.json") - expect(report).to eq(JSON.parse(content, symbolize_names: true)) - expect(report).to match_schema(version: version) + expect(JSON.pretty_generate(actual)).to eq(JSON.pretty_generate(expected_content)) + expect(actual).to match_schema(version: version) end end end diff --git a/spec/unit/license/management/repository_spec.rb b/spec/unit/license/management/repository_spec.rb index 6ebc09e..5531934 100644 --- a/spec/unit/license/management/repository_spec.rb +++ b/spec/unit/license/management/repository_spec.rb @@ -11,6 +11,13 @@ RSpec.describe License::Management::Repository do expect(subject.item_for(license)['id']).to eql(spdx_id) end end + + it 'recognizes `http://www.opensource.org/licenses/mit-license.php`' do + url = 'http://www.opensource.org/licenses/mit-license.php' + license = LicenseFinder::License.new(short_name: url, matcher: LicenseFinder::License::NoneMatcher.new, url: url) + + expect(subject.item_for(license)['id']).to eql('MIT') + end end context "when mapping a license that refers to nuget.org" do |
