From bae02b6ae73dda47dc86590b73c21a85bb7273a5 Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 14 Apr 2020 12:50:13 -0600 Subject: Migrate specs from gitlab-org/security-products/license-management --- spec/integration/dotnet/examples_spec.rb | 12 ++++ spec/integration/dotnet/nuget_spec.rb | 102 +++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 spec/integration/dotnet/examples_spec.rb create mode 100644 spec/integration/dotnet/nuget_spec.rb (limited to 'spec/integration/dotnet') diff --git a/spec/integration/dotnet/examples_spec.rb b/spec/integration/dotnet/examples_spec.rb new file mode 100644 index 0000000..13f4712 --- /dev/null +++ b/spec/integration/dotnet/examples_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +RSpec.describe ".NET Core" do + it 'scans https://github.com/microsoft/RockPaperScissorsLizardSpock.git' do + runner.clone('https://github.com/microsoft/RockPaperScissorsLizardSpock.git') + report = runner.scan(env: { 'LICENSE_FINDER_CLI_OPTS' => '--recursive' }) + + expect(report).to match_schema(version: '2.0') + expect(report[:licenses].count).not_to be_zero + expect(report[:dependencies].count).not_to be_zero + end +end diff --git a/spec/integration/dotnet/nuget_spec.rb b/spec/integration/dotnet/nuget_spec.rb new file mode 100644 index 0000000..6eeb261 --- /dev/null +++ b/spec/integration/dotnet/nuget_spec.rb @@ -0,0 +1,102 @@ +require 'spec_helper' + +RSpec.describe "nuget" do + include_examples "each report version", "csharp", "nuget-dotnetcore" + + context "when a project has a nuget packages.config file in the root" do + let(:packages_config) do + <<-XML + + + + + + + + + + + + + + XML + end + + it 'produces a valid report' do + runner.add_file('packages.config', packages_config) + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report[:licenses].count).not_to be_zero + expect(report.dependency_names).to match_array([ + "Microsoft.CodeDom.Providers.DotNetCompilerPlatform", + "Microsoft.Net.Compilers", + "Microsoft.Web.Infrastructure", + "Microsoft.Web.Xdt", + "Newtonsoft.Json", + "NuGet.Core", + "NuGet.Server", + "RouteMagic", + "WebActivatorEx", + "jive" + ]) + end + end + + context "when a project has multiple nuget packages.config in different sub directories" do + let(:console_packages) do + <<-XML + + + + + XML + end + + let(:winforms_packages) do + <<-XML + + + + + XML + end + + it 'produces a report including dependencies from each sub directory' do + runner.add_file('console/packages.config', console_packages) + runner.add_file('winforms/packages.config', winforms_packages) + report = runner.scan(env: { 'LICENSE_FINDER_CLI_OPTS' => '--recursive' }) + + expect(report).to match_schema(version: '2.0') + expect(report.licenses_for('jive')).to match_array(['MIT']) + expect(report.licenses_for('MvcMailer')).to match_array(['MIT']) + end + end + + context "when a project has a dependency that has it's own dependencies" do + let(:packages) do + <<-XML + + + + + XML + end + + pending 'produces a report that includes the dependencies of each dependency' do + runner.add_file('packages.config', packages) + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report[:licenses].count).not_to be_zero + expect(report[:licenses].map { |x| x[:id] }.uniq).to match_array(['LGPL-2.1', 'Apache-2.0', 'BSD-3-Clause']) + expect(report.dependency_names).to match_array([ + 'Iesi.Collections', + 'Remotion.Linq', + 'Remotion.Linq.EagerFetching', + "Antlr3.Runtime", + "NHibernate" + ]) + end + end +end -- cgit v1.2.3