From a1161309d2cfe44ab1738723a6937ecd3680ea3a Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 9 Jan 2020 09:04:48 -0700 Subject: Add spec to handle pipfile.lock files --- spec/integration/python/pipenv_spec.rb | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 spec/integration/python/pipenv_spec.rb (limited to 'spec') diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb new file mode 100644 index 0000000..7d02bf9 --- /dev/null +++ b/spec/integration/python/pipenv_spec.rb @@ -0,0 +1,49 @@ +require 'spec_helper' + +RSpec.describe "pipenv" do + context "when a project depends on a Pipfile.lock" do + let(:requirements) { "sentry-sdk>=0.7.7" } + + it 'produces a valid report' do + runner.add_file('Pipfile.lock') do + <<~RAW +{ + "_meta": { + "hash": { + "sha256": "d9b5cc506fc4feb9bf1ae7cadfd3737d5a0bd2b2d6c3fbcf0de3458bab34ad89" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.8" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "six": { + "hashes": [ + "sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd", + "sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66" + ], + "index": "pypi", + "version": "==1.13.0" + } + }, + "develop": {} +} + RAW + end + + report = runner.scan + + expect(report).not_to be_empty + expect(report[:version]).to start_with('2') + expect(report[:dependencies].map { |x| x[:name] }).to include("six") + end + end +end -- cgit v1.2.3 From 1c73ad594a26597086b76b4b08ef045247791b5f Mon Sep 17 00:00:00 2001 From: mo khan Date: Mon, 13 Jan 2020 11:04:04 -0700 Subject: Create tmpdir in docker reachable location for MacOS --- spec/spec_helper.rb | 1 + spec/support/integration_test_helper.rb | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index be7673c..115822b 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require 'license/management' require 'json' +require 'securerandom' require 'support/integration_test_helper' RSpec.configure do |config| diff --git a/spec/support/integration_test_helper.rb b/spec/support/integration_test_helper.rb index 485af1b..5ef00a1 100644 --- a/spec/support/integration_test_helper.rb +++ b/spec/support/integration_test_helper.rb @@ -2,7 +2,8 @@ module IntegrationTestHelper class IntegrationTestRunner attr_reader :project_path - def initialize(project_path = Dir.mktmpdir('lm')) + def initialize(project_path = File.join(Dir.pwd, 'tmp', SecureRandom.uuid)) + FileUtils.mkdir_p(project_path) @project_path = project_path end -- cgit v1.2.3 From eb3a7788d67b05faaa73bb521635251ae14e7d2a Mon Sep 17 00:00:00 2001 From: mo khan Date: Tue, 14 Jan 2020 13:16:47 -0700 Subject: Simplify fixture generation in test --- spec/integration/python/pipenv_spec.rb | 49 +++++++++++----------------------- 1 file changed, 15 insertions(+), 34 deletions(-) (limited to 'spec') diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 7d02bf9..15e48dc 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -2,42 +2,23 @@ require 'spec_helper' RSpec.describe "pipenv" do context "when a project depends on a Pipfile.lock" do - let(:requirements) { "sentry-sdk>=0.7.7" } - - it 'produces a valid report' do - runner.add_file('Pipfile.lock') do - <<~RAW -{ - "_meta": { - "hash": { - "sha256": "d9b5cc506fc4feb9bf1ae7cadfd3737d5a0bd2b2d6c3fbcf0de3458bab34ad89" + let(:pipfile_lock_content) do + JSON.pretty_generate({ + "_meta": { + "hash": { "sha256": "" }, + "pipfile-spec": 6, + "requires": { "python_version": "3.8" }, + "sources": [ { "name": "pypi", "url": "https://pypi.org/simple", "verify_ssl": true } ] }, - "pipfile-spec": 6, - "requires": { - "python_version": "3.8" + "default": { + "six": { "hashes": [], "index": "pypi", "version": "==1.13.0" } }, - "sources": [ - { - "name": "pypi", - "url": "https://pypi.org/simple", - "verify_ssl": true - } - ] - }, - "default": { - "six": { - "hashes": [ - "sha256:1f1b7d42e254082a9db6279deae68afb421ceba6158efa6131de7b3003ee93fd", - "sha256:30f610279e8b2578cab6db20741130331735c781b56053c59c4076da27f06b66" - ], - "index": "pypi", - "version": "==1.13.0" - } - }, - "develop": {} -} - RAW - end + "develop": {} + }) + end + + it 'produces a valid report' do + runner.add_file('Pipfile.lock', pipfile_lock_content) report = runner.scan -- cgit v1.2.3 From 3aeed26912b238f6cb9c8b43587b0f3a7bf181f4 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 14:19:39 -0700 Subject: Add spec to ensure we can parse a v3 Pipfile.lock --- Gemfile.lock | 6 ++++ license-management.gemspec | 1 + spec/fixtures/v2.0_schema.json | 16 +++++++++++ spec/integration/python/pipenv_spec.rb | 51 ++++++++++++++++++++++++++++++++-- spec/spec_helper.rb | 2 ++ spec/support/matchers.rb | 13 +++++++++ 6 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/v2.0_schema.json create mode 100644 spec/support/matchers.rb (limited to 'spec') diff --git a/Gemfile.lock b/Gemfile.lock index abe9075..60f69d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,7 +8,11 @@ PATH GEM remote: https://rubygems.org/ specs: + addressable (2.7.0) + public_suffix (>= 2.0.2, < 5.0) diff-lcs (1.3) + json-schema (2.8.1) + addressable (>= 2.4) license_finder (5.11.1) bundler rubyzip (>= 1, < 3) @@ -18,6 +22,7 @@ GEM xml-simple net-hippie (0.3.0) parslet (1.8.2) + public_suffix (4.0.3) rspec (3.9.0) rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) @@ -42,6 +47,7 @@ PLATFORMS ruby DEPENDENCIES + json-schema (~> 2.8) license-management! rspec (~> 3.9) diff --git a/license-management.gemspec b/license-management.gemspec index 492fd2d..60ab5e1 100644 --- a/license-management.gemspec +++ b/license-management.gemspec @@ -29,5 +29,6 @@ Gem::Specification.new do |spec| spec.add_dependency 'license_finder', '~> 5.11' spec.add_dependency 'net-hippie', '~> 0.3' + spec.add_development_dependency 'json-schema', '~> 2.8' spec.add_development_dependency 'rspec', '~> 3.9' end diff --git a/spec/fixtures/v2.0_schema.json b/spec/fixtures/v2.0_schema.json new file mode 100644 index 0000000..bd304ce --- /dev/null +++ b/spec/fixtures/v2.0_schema.json @@ -0,0 +1,16 @@ +{ + "$id": "https://gitlab.com/gitlab-org/security-products/license-management/blob/master/spec/fixtures/v2.0_schema.json", + "type": "object", + "required": [ + "version", + "licenses", + "dependencies" + ], + "properties": { + "version": { "type": "string" }, + "licenses": { "type": "array" }, + "dependencies": { "type": "array" } + }, + "additionalProperties": false +} + diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 15e48dc..6039b25 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' RSpec.describe "pipenv" do - context "when a project depends on a Pipfile.lock" do + context "when a project depends on a version 6 Pipfile.lock" do let(:pipfile_lock_content) do JSON.pretty_generate({ "_meta": { @@ -23,8 +23,55 @@ RSpec.describe "pipenv" do report = runner.scan expect(report).not_to be_empty - expect(report[:version]).to start_with('2') + expect(report[:version]).not_to be_empty + expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("six") end end + + context "when a project depends on a version 3.2.1 Pipfile.lock" do + let(:pipfile_lock_content) do + JSON.pretty_generate({ + "default": { + "crayons": { "version": "==0.1.2", "hash": "" }, + "requirements-parser": { "version": "==0.1.0", "hash": "" }, + "pexpect": { "version": "==4.2.1", "hash": "" }, + "delegator.py": { "version": "==0.0.8", "hash": "" }, + "backports.shutil_get_terminal_size": { "version": "==1.0.0", "hash": "" }, + "ptyprocess": { "version": "==0.5.1", "hash": "" }, + "parse": { "version": "==1.6.6", "hash": "" }, + "toml": { "version": "==0.9.2", "hash": "" }, + "colorama": { "version": "==0.3.7", "hash": "" }, + "requests": { "version": "==2.13.0", "hash": "" }, + "click": { "version": "==6.7", "hash": "" } + }, + "develop": { + "packaging": { "version": "==16.8", "hash": "" }, + "pytest": { "version": "==3.0.6", "hash": "" }, + "setuptools": { "version": "==34.0.2", "hash": "" }, + "pyparsing": { "version": "==2.1.10", "hash": "" }, + "py": { "version": "==1.4.32", "hash": "" }, + "six": { "version": "==1.10.0", "hash": "" }, + "appdirs": { "version": "==1.4.0", "hash": "" } + }, + "_meta": { + "sources": [ { "url": "https://pypi.python.org/simple", "verify_ssl": true } ], + "requires": {}, + "Pipfile-sha256": "24f12b631b7c40b8c5eff934a1aef263ed04f5eaffb4acf4706442f3d23cba36" + } + }) + end + + it 'produces a valid report' do + runner.add_file('Pipfile.lock', pipfile_lock_content) + + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report).not_to be_empty + expect(report[:version]).not_to be_empty + expect(report[:licenses]).not_to be_empty + expect(report[:dependencies].count).to eql(18) + end + end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 115822b..1889335 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,7 +1,9 @@ require 'license/management' require 'json' require 'securerandom' +require 'json-schema' require 'support/integration_test_helper' +require 'support/matchers' RSpec.configure do |config| config.include IntegrationTestHelper, type: :integration diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb new file mode 100644 index 0000000..bb54d19 --- /dev/null +++ b/spec/support/matchers.rb @@ -0,0 +1,13 @@ +RSpec::Matchers.define :match_schema do |version: nil, **options| + match do |actual| + path = License::Management.root.join("spec/fixtures/v#{version}_schema.json") + schema = JSON.parse(IO.read(path)) + @errors = JSON::Validator.fully_validate(schema, actual, options) + @errors.empty? + end + + failure_message do |response| + "didn't match the schema for version #{version}" \ + " The validation errors were:\n#{@errors.join("\n")}" + end +end -- cgit v1.2.3 From ac9634d8f8c6bbaa8348929f42d53d2b375f6dfb Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 14:41:14 -0700 Subject: Add a json schema for dependency --- spec/fixtures/schema/v2.0.json | 16 ++++++++++++++++ spec/fixtures/schema/v2.0_dependency.json | 27 +++++++++++++++++++++++++++ spec/fixtures/v2.0_schema.json | 16 ---------------- spec/integration/python/pipenv_spec.rb | 1 + spec/integration/ruby/bundler_spec.rb | 2 ++ spec/support/matchers.rb | 9 +++++---- 6 files changed, 51 insertions(+), 20 deletions(-) create mode 100644 spec/fixtures/schema/v2.0.json create mode 100644 spec/fixtures/schema/v2.0_dependency.json delete mode 100644 spec/fixtures/v2.0_schema.json (limited to 'spec') diff --git a/spec/fixtures/schema/v2.0.json b/spec/fixtures/schema/v2.0.json new file mode 100644 index 0000000..3377a9d --- /dev/null +++ b/spec/fixtures/schema/v2.0.json @@ -0,0 +1,16 @@ +{ + "$id": "https://gitlab.com/gitlab-org/security-products/license-management/blob/master/spec/fixtures/schema/v2.0.json", + "type": "object", + "required": [ + "version", + "licenses", + "dependencies" + ], + "properties": { + "version": { "type": "string" }, + "licenses": { "type": "array" }, + "dependencies": { "$ref": "v2.0_dependency.json" } + }, + "additionalProperties": false +} + diff --git a/spec/fixtures/schema/v2.0_dependency.json b/spec/fixtures/schema/v2.0_dependency.json new file mode 100644 index 0000000..fcd96d7 --- /dev/null +++ b/spec/fixtures/schema/v2.0_dependency.json @@ -0,0 +1,27 @@ +{ + "type": "array", + "required": [ + "name", + "url", + "description", + "paths", + "licenses" + ], + "properties": { + "name": { "type": "string" }, + "url": { "type": "uri" }, + "description": { "type": "string" }, + "paths": { + "type": "array", + "items": { + "type": "string" + } + }, + "licenses": { + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/spec/fixtures/v2.0_schema.json b/spec/fixtures/v2.0_schema.json deleted file mode 100644 index bd304ce..0000000 --- a/spec/fixtures/v2.0_schema.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "$id": "https://gitlab.com/gitlab-org/security-products/license-management/blob/master/spec/fixtures/v2.0_schema.json", - "type": "object", - "required": [ - "version", - "licenses", - "dependencies" - ], - "properties": { - "version": { "type": "string" }, - "licenses": { "type": "array" }, - "dependencies": { "type": "array" } - }, - "additionalProperties": false -} - diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 6039b25..2756f6b 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -23,6 +23,7 @@ RSpec.describe "pipenv" do report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:version]).not_to be_empty expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("six") diff --git a/spec/integration/ruby/bundler_spec.rb b/spec/integration/ruby/bundler_spec.rb index 179da2a..2cb8f7d 100644 --- a/spec/integration/ruby/bundler_spec.rb +++ b/spec/integration/ruby/bundler_spec.rb @@ -14,6 +14,7 @@ gem 'saml-kit' report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("saml-kit") end @@ -81,6 +82,7 @@ BUNDLED WITH report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:licenses]).not_to be_empty expect(report[:dependencies].map { |x| x[:name] }).to include("saml-kit") end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index bb54d19..1d1c263 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -1,8 +1,9 @@ -RSpec::Matchers.define :match_schema do |version: nil, **options| +RSpec::Matchers.define :match_schema do |version: '2.0'| match do |actual| - path = License::Management.root.join("spec/fixtures/v#{version}_schema.json") - schema = JSON.parse(IO.read(path)) - @errors = JSON::Validator.fully_validate(schema, actual, options) + schema = License::Management.root + .join("spec/fixtures/schema/v#{version}.json") + .to_s + @errors = JSON::Validator.fully_validate(schema, actual) @errors.empty? end -- cgit v1.2.3 From 3d4fbad1e39f7cbb37643864b8229aa4116ce07c Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 14:51:53 -0700 Subject: Combine schema into a single file --- spec/fixtures/schema/v2.0.json | 48 +++++++++++++++++++++++++++++-- spec/fixtures/schema/v2.0_dependency.json | 27 ----------------- 2 files changed, 46 insertions(+), 29 deletions(-) delete mode 100644 spec/fixtures/schema/v2.0_dependency.json (limited to 'spec') diff --git a/spec/fixtures/schema/v2.0.json b/spec/fixtures/schema/v2.0.json index 3377a9d..712143b 100644 --- a/spec/fixtures/schema/v2.0.json +++ b/spec/fixtures/schema/v2.0.json @@ -8,8 +8,52 @@ ], "properties": { "version": { "type": "string" }, - "licenses": { "type": "array" }, - "dependencies": { "$ref": "v2.0_dependency.json" } + "licenses": { + "type": "array", + "items": { + "type": "object", + "required": [ + "id", + "name", + "url" + ], + "properties": { + "id": { "type": "string" }, + "name": { "type": "string" }, + "url": { "type": "uri" } + } + } + }, + "dependencies": { + "type": "array", + "items": { + "type": "object", + "required": [ + "name", + "url", + "description", + "paths", + "licenses" + ], + "properties": { + "name": { "type": "string" }, + "url": { "type": "uri" }, + "description": { "type": "string" }, + "paths": { + "type": "array", + "items": { + "type": "string" + } + }, + "licenses": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } }, "additionalProperties": false } diff --git a/spec/fixtures/schema/v2.0_dependency.json b/spec/fixtures/schema/v2.0_dependency.json deleted file mode 100644 index fcd96d7..0000000 --- a/spec/fixtures/schema/v2.0_dependency.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "type": "array", - "required": [ - "name", - "url", - "description", - "paths", - "licenses" - ], - "properties": { - "name": { "type": "string" }, - "url": { "type": "uri" }, - "description": { "type": "string" }, - "paths": { - "type": "array", - "items": { - "type": "string" - } - }, - "licenses": { - "type": "array", - "items": { - "type": "string" - } - } - } -} -- cgit v1.2.3 From 3e9bbcd897812e64d3a356dcd5806baeec198d65 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 15:11:58 -0700 Subject: Validate version # --- spec/fixtures/schema/v2.0.json | 30 ++++++++++++++++++++++-------- spec/integration/dotnet/examples_spec.rb | 1 + spec/integration/python/pip_spec.rb | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/fixtures/schema/v2.0.json b/spec/fixtures/schema/v2.0.json index 712143b..6ade7ad 100644 --- a/spec/fixtures/schema/v2.0.json +++ b/spec/fixtures/schema/v2.0.json @@ -7,7 +7,10 @@ "dependencies" ], "properties": { - "version": { "type": "string" }, + "version": { + "type": "string", + "pattern": "^[0-9]+\\.[0-9]+$" + }, "licenses": { "type": "array", "items": { @@ -18,9 +21,15 @@ "url" ], "properties": { - "id": { "type": "string" }, - "name": { "type": "string" }, - "url": { "type": "uri" } + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "url": { + "type": "uri" + } } } }, @@ -36,9 +45,15 @@ "licenses" ], "properties": { - "name": { "type": "string" }, - "url": { "type": "uri" }, - "description": { "type": "string" }, + "name": { + "type": "string" + }, + "url": { + "type": "uri" + }, + "description": { + "type": "string" + }, "paths": { "type": "array", "items": { @@ -57,4 +72,3 @@ }, "additionalProperties": false } - diff --git a/spec/integration/dotnet/examples_spec.rb b/spec/integration/dotnet/examples_spec.rb index 43caea0..5b2a913 100644 --- a/spec/integration/dotnet/examples_spec.rb +++ b/spec/integration/dotnet/examples_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ".NET Core" do report = runner.scan(env: { 'LICENSE_FINDER_CLI_OPTS' => '--recursive' }) expect(report).not_to be_empty + 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 diff --git a/spec/integration/python/pip_spec.rb b/spec/integration/python/pip_spec.rb index 5ff5f60..b092189 100644 --- a/spec/integration/python/pip_spec.rb +++ b/spec/integration/python/pip_spec.rb @@ -10,6 +10,7 @@ RSpec.describe "pip" do report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:version]).to start_with('2') expect(report[:dependencies].map { |x| x[:name] }).to include("sentry-sdk") expect(report[:dependencies].find { |x| x[:name] == 'sentry-sdk' }[:licenses]).to match_array(["BSD-4-Clause"]) @@ -39,6 +40,7 @@ RSpec.describe "pip" do report = runner.scan expect(report).not_to be_empty + expect(report).to match_schema(version: '2.0') expect(report[:version]).to start_with('2') expect(report[:licenses]).not_to be_empty expect(report[:dependencies]).not_to be_empty -- cgit v1.2.3 From 06d2844938465c84f908139db7e7a3abc4e3cd6d Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 15:30:44 -0700 Subject: Parse version 5 of the pipfile.lock --- spec/integration/python/pipenv_spec.rb | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'spec') diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 2756f6b..4d6559c 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -75,4 +75,53 @@ RSpec.describe "pipenv" do expect(report[:dependencies].count).to eql(18) end end + + context "when a project depends on a version 5 Pipfile.lock" do + let(:pipfile_lock_content) do + JSON.pretty_generate({ + "_meta": { + "hash": { "sha256": "" }, + "host-environment-markers": { + "implementation_name": "cpython", + "implementation_version": "3.6.1", + "os_name": "posix", + "platform_machine": "x86_64", + "platform_python_implementation": "CPython", + "platform_release": "16.7.0", + "platform_system": "Darwin", + "platform_version": "Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64", + "python_full_version": "3.6.1", + "python_version": "3.6", + "sys_platform": "darwin" + }, + "pipfile-spec": 5, + "requires": {}, + "sources": [{ "name": "pypi", "url": "https://pypi.python.org/simple", "verify_ssl": true }] + }, + "default": { + "certifi": { "hashes": ["", ""], "version": "==2017.7.27.1" }, + "chardet": { "hashes": ["", ""], "version": "==3.0.4" }, + "idna": { "hashes": ["", ""], "version": "==2.6" }, + "requests": { "hashes": ["", ""], "version": "==2.18.4" }, + "urllib3": { "hashes": ["", ""], "version": "==1.22" } + }, + "develop": { + "py": { "hashes": ["", ""], "version": "==1.4.34" }, + "pytest": { "hashes": ["", ""], "version": "==3.2.2" } + } + }) + end + + it 'produces a valid report' do + runner.add_file('Pipfile.lock', pipfile_lock_content) + + report = runner.scan + + expect(report).to match_schema(version: '2.0') + expect(report).not_to be_empty + expect(report[:version]).not_to be_empty + expect(report[:licenses]).not_to be_empty + expect(report[:dependencies].count).to eql(7) + end + end end -- cgit v1.2.3 From 34f162a4903d852d47bd5440839f7519eb6fa8f0 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 15 Jan 2020 16:25:16 -0700 Subject: Match dependency names --- spec/integration/python/pipenv_spec.rb | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/integration/python/pipenv_spec.rb b/spec/integration/python/pipenv_spec.rb index 4d6559c..1ea60fe 100644 --- a/spec/integration/python/pipenv_spec.rb +++ b/spec/integration/python/pipenv_spec.rb @@ -26,7 +26,7 @@ RSpec.describe "pipenv" do expect(report).to match_schema(version: '2.0') expect(report[:version]).not_to be_empty expect(report[:licenses]).not_to be_empty - expect(report[:dependencies].map { |x| x[:name] }).to include("six") + expect(report[:dependencies].map { |x| x[:name] }).to contain_exactly("six") end end @@ -72,7 +72,26 @@ RSpec.describe "pipenv" do expect(report).not_to be_empty expect(report[:version]).not_to be_empty expect(report[:licenses]).not_to be_empty - expect(report[:dependencies].count).to eql(18) + expect(report[:dependencies].map { |x| x[:name] }).to match_array([ + "appdirs", + "backports.shutil_get_terminal_size", + "click", + "colorama", + "crayons", + "delegator.py", + "packaging", + "parse", + "pexpect", + "ptyprocess", + "py", + "pyparsing", + "pytest", + "requests", + "requirements-parser", + "setuptools", + "six", + "toml", + ]) end end @@ -121,7 +140,9 @@ RSpec.describe "pipenv" do expect(report).not_to be_empty expect(report[:version]).not_to be_empty expect(report[:licenses]).not_to be_empty - expect(report[:dependencies].count).to eql(7) + expect(report[:dependencies].map { |x| x[:name] }).to match_array([ + 'certifi', 'chardet', 'idna', 'requests', 'urllib3', 'py', 'pytest' + ]) end end end -- cgit v1.2.3