@@ -21,6 +21,7 @@ const npmChange: Change = {
2121 }
2222 ]
2323}
24+
2425const rubyChange : Change = {
2526 change_type : 'added' ,
2627 manifest : 'Gemfile.lock' ,
@@ -100,105 +101,6 @@ beforeEach(async () => {
100101 jest . resetModules ( )
101102} )
102103
103- test ( 'it should handle SPDX expressions in allow-list that matches a single license project' , async ( ) => {
104- const change : Change = getChangeWithLicense ( 'MIT' )
105- const changes : Changes = [ change ]
106-
107- const { forbidden} = await getInvalidLicenseChanges ( changes , {
108- allow : [ 'EPL-1.0 OR MIT' ]
109- } )
110-
111- expect ( forbidden ) . toStrictEqual ( [ ] )
112- } )
113-
114- test ( 'it should handle SPDX expressions in allow-list with operators and a valid triple licensed project' , async ( ) => {
115- const change : Change = getChangeWithLicense (
116- 'EPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only'
117- )
118- const changes : Changes = [ change ]
119-
120- const { forbidden} = await getInvalidLicenseChanges ( changes , {
121- allow : [ 'EPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only' ]
122- } )
123-
124- expect ( forbidden ) . toStrictEqual ( [ ] )
125- } )
126-
127- test ( 'it should handle a valid triple licensed project that does not have a match in the allow-list' , async ( ) => {
128- const change = getChangeWithLicense ( 'EPL-1.0 AND LGPL-2.1 AND LGPL-2.1-only' )
129- const changes : Changes = [ change ]
130-
131- const { forbidden} = await getInvalidLicenseChanges ( changes , {
132- allow : [ 'EPL-1.0' , 'LGPL-2.1' , 'LGPL-2.1-only' ]
133- } )
134-
135- expect ( forbidden [ 0 ] ) . toBe ( change )
136- expect ( forbidden . length ) . toEqual ( 1 )
137- } )
138-
139- test ( 'it should handle license with OR SPDX expression and only match on one license in the allow-list' , async ( ) => {
140- const change = getChangeWithLicense ( 'EPL-1.0 OR LGPL-2.1' )
141- const changes : Changes = [ change ]
142-
143- for ( const allowedLicense of [ 'EPL-1.0' , 'LGPL-2.1' ] ) {
144- const { forbidden} = await getInvalidLicenseChanges ( changes , {
145- allow : [ allowedLicense ]
146- } )
147-
148- expect ( forbidden ) . toStrictEqual ( [ ] )
149- }
150- } )
151-
152- test ( 'it should handle SPDX expressions in allow-list with operators when license matches' , async ( ) => {
153- const changes : Changes = [
154- npmChange // MIT license
155- ]
156-
157- const { forbidden} = await getInvalidLicenseChanges ( changes , {
158- allow : [ 'MIT OR Apache-2.0' , 'MIT' , 'BSD-3-Clause' ]
159- } )
160-
161- expect ( forbidden ) . toStrictEqual ( [ ] )
162- } )
163-
164- test ( 'it should handle SPDX expressions in allow-list with operators when license does not match' , async ( ) => {
165- const changes : Changes = [
166- npmChange // MIT license
167- ]
168-
169- const { forbidden} = await getInvalidLicenseChanges ( changes , {
170- allow : [ 'MIT AND Apache-2.0' , 'BSD-3-Clause' ]
171- } )
172-
173- expect ( forbidden [ 0 ] ) . toBe ( npmChange )
174- expect ( forbidden . length ) . toEqual ( 1 )
175- } )
176-
177- test ( 'it should handle SPDX expressions in deny-list with operators when license matches deny list entry' , async ( ) => {
178- const changes : Changes = [
179- npmChange // MIT license
180- ]
181-
182- const { forbidden} = await getInvalidLicenseChanges ( changes , {
183- deny : [ 'MIT OR Apache-2.0' , 'BSD-3-Clause' ]
184- } )
185-
186- expect ( forbidden [ 0 ] ) . toBe ( npmChange )
187- expect ( forbidden . length ) . toEqual ( 1 )
188- } )
189-
190- test ( 'it should handle SPDX expressions in deny-list with operators when license does not match any deny list entry' , async ( ) => {
191- const changes : Changes = [
192- npmChange // MIT license
193- ]
194-
195- const { forbidden} = await getInvalidLicenseChanges ( changes , {
196- deny : [ 'MIT AND Apache-2.0' , 'BSD-3-Clause' ]
197- } )
198-
199- expect ( forbidden ) . toStrictEqual ( [ ] )
200- } )
201-
202104test ( 'it adds license outside the allow list to forbidden changes' , async ( ) => {
203105 const changes : Changes = [
204106 npmChange , // MIT license
@@ -362,25 +264,3 @@ describe('GH License API fallback', () => {
362264 expect ( unlicensed . length ) . toEqual ( 0 )
363265 } )
364266} )
365-
366- function getChangeWithLicense ( license : string ) : Change {
367- return {
368- manifest : 'pom.xml' ,
369- change_type : 'added' ,
370- ecosystem : 'maven' ,
371- name : 'dummy-library' ,
372- version : '1.0.0' ,
373- package_url : 'pkg:org.something:sdummy-library@1.0.0' ,
374- license,
375- source_repository_url : 'github.com/some-repo' ,
376- scope : 'runtime' ,
377- vulnerabilities : [
378- {
379- severity : 'critical' ,
380- advisory_ghsa_id : 'first-random_string' ,
381- advisory_summary : 'very dangerous' ,
382- advisory_url : 'github.com/future-funk'
383- }
384- ]
385- }
386- }
0 commit comments