summaryrefslogtreecommitdiff
path: root/spec/integration/go/modules_spec.rb
diff options
context:
space:
mode:
authormo khan <mo.khan@gmail.com>2020-04-02 15:11:12 +0000
committermo khan <mo.khan@gmail.com>2020-04-02 15:11:12 +0000
commit2d200e2bcecb91eadc5ee211f5bb65aafa645054 (patch)
tree9749333a7c8878b833b4642afe3071cf1c14012c /spec/integration/go/modules_spec.rb
parent43bcbbd04342faa497725c5b0be3c6d944d850da (diff)
parentbfd7459419921ff37ee500f0698862eea6788675 (diff)
Merge branch '10128-go-modules' into 'master'v3.5.0
Improve license detection in go modules projects See merge request gitlab-org/security-products/license-management!129
Diffstat (limited to 'spec/integration/go/modules_spec.rb')
-rw-r--r--spec/integration/go/modules_spec.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/spec/integration/go/modules_spec.rb b/spec/integration/go/modules_spec.rb
index ebe0359..143d8ea 100644
--- a/spec/integration/go/modules_spec.rb
+++ b/spec/integration/go/modules_spec.rb
@@ -2,4 +2,52 @@ require 'spec_helper'
RSpec.describe "modules" do
include_examples "each report version", "go", "modules"
+
+ context "when scanning a customers go.mod and go.sum files" do
+ let(:report) { runner.scan }
+
+ before do
+ runner.add_file('main.go', fixture_file_content('go/main.go'))
+ runner.add_file('go.mod', fixture_file_content('go/go.mod'))
+ runner.add_file('go.sum', fixture_file_content('go/go.sum'))
+ end
+
+ specify { expect(report).to match_schema(version: '2.0') }
+ specify { expect(report[:licenses]).not_to be_empty }
+
+ specify do
+ expect(report.dependency_names).to match_array([
+ "github.com/davecgh/go-spew",
+ "github.com/dimfeld/httptreemux/v5",
+ "github.com/go-logfmt/logfmt",
+ "github.com/golang/protobuf",
+ "github.com/google/uuid",
+ "github.com/pmezard/go-difflib",
+ "github.com/stretchr/objx",
+ "golang.org/x/net",
+ "golang.org/x/oauth2",
+ "google.golang.org/appengine",
+ "gopkg.in/yaml.v2",
+ 'github.com/stretchr/testify'
+ ])
+ end
+
+ specify { expect(report.licenses_for('github.com/dimfeld/httptreemux/v5')).to match_array(['MIT']) }
+ specify { expect(report.licenses_for('github.com/go-logfmt/logfmt')).to match_array(['MIT']) }
+ specify { expect(report.licenses_for('github.com/google/uuid')).to match_array(['BSD-3-Clause']) }
+ specify { expect(report.licenses_for('github.com/stretchr/testify')).to match_array(['MIT']) }
+ specify { expect(report.licenses_for('golang.org/x/oauth2')).to match_array(['BSD-3-Clause']) }
+ end
+
+ context "when scanning the `gitaly` project" do
+ let(:report) { runner.scan }
+
+ before do
+ runner.clone('https://gitlab.com/gitlab-org/gitaly.git')
+ end
+
+ specify { expect(report).to match_schema(version: '2.0') }
+ specify { expect(report[:licenses]).not_to be_empty }
+ specify { expect(report[:dependencies]).not_to be_empty }
+ end
end