diff options
| author | mo khan <mo.khan@gmail.com> | 2020-05-19 10:00:54 -0600 |
|---|---|---|
| committer | mo khan <mo.khan@gmail.com> | 2020-05-19 10:00:54 -0600 |
| commit | d413ca59eb620487764753290c78e561d60555fe (patch) | |
| tree | d33b8e3054c509030800d2e4020797d6e024e3fb /spec | |
| parent | 154f15f737db7e4ef67bd231d5e9bec964cca16b (diff) | |
Capture invalid urls
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/fixtures/maven/invalid-spec-url-pom.xml | 16 | ||||
| -rw-r--r-- | spec/unit/java/metadata_spec.rb | 13 | ||||
| -rw-r--r-- | spec/unit/java/parsers/maven_spec.rb | 8 |
3 files changed, 37 insertions, 0 deletions
diff --git a/spec/fixtures/maven/invalid-spec-url-pom.xml b/spec/fixtures/maven/invalid-spec-url-pom.xml new file mode 100644 index 0000000..5a9de9b --- /dev/null +++ b/spec/fixtures/maven/invalid-spec-url-pom.xml @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>com.example</groupId> + <artifactId>invalid</artifactId> + <version>1.0-SNAPSHOT</version> + <name>invalid</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>model</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project> diff --git a/spec/unit/java/metadata_spec.rb b/spec/unit/java/metadata_spec.rb new file mode 100644 index 0000000..9f2f108 --- /dev/null +++ b/spec/unit/java/metadata_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +RSpec.describe Spandx::Java::Metadata do + describe '#licenses' do + context 'when the metadata is invalid' do + subject { described_class.new(artifact_id: '${project.artifactId}', group_id: '${project.groupId}', version: '${project.version}') } + + let(:result) { subject.licenses } + + specify { expect(result).to be_empty } + end + end +end diff --git a/spec/unit/java/parsers/maven_spec.rb b/spec/unit/java/parsers/maven_spec.rb index 218c4c7..7dda40c 100644 --- a/spec/unit/java/parsers/maven_spec.rb +++ b/spec/unit/java/parsers/maven_spec.rb @@ -12,6 +12,14 @@ RSpec.describe Spandx::Java::Parsers::Maven do specify { expect(because[0].name).to eql('junit:junit') } specify { expect(because[0].version).to eql('3.8.1') } end + + context 'when parsing an invlid pom.xml' do + let(:lockfile) { fixture_file('maven/invalid-spec-url-pom.xml') } + + let(:because) { subject.parse(lockfile) } + + specify { expect(because[0].name).to eql('${project.groupId}:model') } + end end describe '.matches?' do |
