@@ -13,7 +13,7 @@ async function sharedComponentAnalysisTestFlow(testCase, usePipDepTreeUtility) {
1313 let expectedSbom = fs . readFileSync ( `test/providers/tst_manifests/pip/${ testCase } /expected_component_sbom.json` ) . toString ( ) . trim ( )
1414 expectedSbom = JSON . stringify ( JSON . parse ( expectedSbom ) )
1515 // invoke sut stack analysis for scenario manifest
16- let opts = { " TRUSTIFY_DA_PIP_USE_DEP_TREE" : usePipDepTreeUtility }
16+ let opts = { TRUSTIFY_DA_PIP_USE_DEP_TREE : usePipDepTreeUtility . toString ( ) }
1717 let providedDatForComponent = await pythonPip . provideComponent ( `test/providers/tst_manifests/pip/${ testCase } /requirements.txt` , opts )
1818 // verify returned data matches expectation
1919 expect ( providedDatForComponent ) . to . deep . equal ( {
@@ -34,7 +34,7 @@ async function sharedStackAnalysisTestFlow(testCase, usePipDepTreeUtility) {
3434 } catch ( error ) {
3535 throw new Error ( 'fail installing requirements.txt manifest in created virtual python environment' , { cause : error } )
3636 }
37- let opts = { " TRUSTIFY_DA_PIP_USE_DEP_TREE" : usePipDepTreeUtility }
37+ let opts = { TRUSTIFY_DA_PIP_USE_DEP_TREE : usePipDepTreeUtility . toString ( ) }
3838 let providedDataForStack = await pythonPip . provideStack ( `test/providers/tst_manifests/pip/${ testCase } /requirements.txt` , opts )
3939 // new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date
4040
@@ -48,14 +48,14 @@ async function sharedStackAnalysisTestFlow(testCase, usePipDepTreeUtility) {
4848}
4949
5050suite ( 'testing the python-pip data provider' , ( ) => {
51- // [
52- // {name: 'requirements.txt', expected: true},
53- // {name: 'some_other.file', expected: false}
54- // ].forEach(testCase => {
55- // test(`verify isSupported returns ${testCase.expected} for ${testCase.name}`, () =>
56- // expect(pythonPip.isSupported(testCase.name)).to.equal(testCase.expected)
57- // )
58- // });
51+ [
52+ { name : 'requirements.txt' , expected : true } ,
53+ { name : 'some_other.file' , expected : false }
54+ ] . forEach ( testCase => {
55+ test ( `verify isSupported returns ${ testCase . expected } for ${ testCase . name } ` , ( ) =>
56+ expect ( pythonPip . isSupported ( testCase . name ) ) . to . equal ( testCase . expected )
57+ )
58+ } ) ;
5959
6060 [
6161 // "pip_requirements_txt_no_ignore",
@@ -72,46 +72,46 @@ suite('testing the python-pip data provider', () => {
7272 // these test cases takes ~1400-2000 ms each pr >10000 in CI (for the first test-case)
7373 } ) . timeout ( process . env . GITHUB_ACTIONS ? 15000 : 10000 )
7474
75- // test(`verify requirements.txt sbom provided for stack analysis using pipdeptree utility with scenario ${scenario}`, () => {
76- // sharedStackAnalysisTestFlow(testCase, true);
77- // // these test cases takes ~2500-2700 ms each pr >10000 in CI (for the first test-case)
78- // }).timeout(process.env.GITHUB_ACTIONS ? 30000 : 10000)
75+ test ( `verify requirements.txt sbom provided for stack analysis using pipdeptree utility with scenario ${ scenario } ` , async ( ) => {
76+ await sharedStackAnalysisTestFlow ( testCase , true ) ;
77+ // these test cases takes ~2500-2700 ms each pr >10000 in CI (for the first test-case)
78+ } ) . timeout ( process . env . GITHUB_ACTIONS ? 30000 : 10000 )
7979
80- // test(`verify requirements.txt sbom provided for component analysis using pipdeptree utility with scenario ${scenario}`, () => {
81- // sharedComponentAnalysisTestFlow(testCase, true);
82- // // these test cases takes ~1400-2000 ms each pr >10000 in CI (for the first test-case)
83- // }).timeout(process.env.GITHUB_ACTIONS ? 15000 : 10000)
80+ test ( `verify requirements.txt sbom provided for component analysis using pipdeptree utility with scenario ${ scenario } ` , async ( ) => {
81+ await sharedComponentAnalysisTestFlow ( testCase , true ) ;
82+ // these test cases takes ~1400-2000 ms each pr >10000 in CI (for the first test-case)
83+ } ) . timeout ( process . env . GITHUB_ACTIONS ? 15000 : 10000 )
8484 } ) ;
8585
8686} ) . beforeAll ( ( ) => clock = useFakeTimers ( new Date ( '2023-10-01T00:00:00.000Z' ) ) ) . afterAll ( ( ) => clock . restore ( ) ) ;
8787
88- // suite('testing the python-pip data provider with virtual environment', () => {
89- // [
90- // "pip_requirements_virtual_env_txt_no_ignore",
91- // "pip_requirements_virtual_env_with_ignore"
92- // ].forEach(testCase => {
93- // let scenario = testCase.replace('pip_requirements_', '').replaceAll('_', ' ')
94- // test(`verify requirements.txt sbom provided for stack analysis using virutal python environment, with scenario ${scenario}`, async () => {
95- // // load the expected sbom stack analysis
96- // let expectedSbom = fs.readFileSync(`test/providers/tst_manifests/pip/${testCase}/expected_stack_sbom.json`,).toString()
97- // process.env["TRUSTIFY_DA_PYTHON_VIRTUAL_ENV"] = "true"
98- // // process.env["TRUSTIFY_DA_DEBUG"] = "true"
99- // expectedSbom = JSON.stringify(JSON.parse(expectedSbom), null, 4)
100- // // invoke sut stack analysis for scenario manifest
101- // let providedDataForStack = await pythonPip.provideStack(`test/providers/tst_manifests/pip/${testCase}/requirements.txt` )
102- // // new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date
88+ suite ( 'testing the python-pip data provider with virtual environment' , ( ) => {
89+ [
90+ "pip_requirements_virtual_env_txt_no_ignore" ,
91+ "pip_requirements_virtual_env_with_ignore"
92+ ] . forEach ( testCase => {
93+ let scenario = testCase . replace ( 'pip_requirements_' , '' ) . replaceAll ( '_' , ' ' )
94+ test ( `verify requirements.txt sbom provided for stack analysis using virutal python environment, with scenario ${ scenario } ` , async ( ) => {
95+ // load the expected sbom stack analysis
96+ let expectedSbom = fs . readFileSync ( `test/providers/tst_manifests/pip/${ testCase } /expected_stack_sbom.json` , ) . toString ( )
97+ expectedSbom = JSON . stringify ( JSON . parse ( expectedSbom ) , null , 4 )
98+ // invoke sut stack analysis for scenario manifest
99+ let providedDataForStack = await pythonPip . provideStack ( `test/providers/tst_manifests/pip/ ${ testCase } /requirements.txt` , {
100+ TRUSTIFY_DA_PYTHON_VIRTUAL_ENV : "true"
101+ } )
102+ // new(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date
103103
104- // // providedDataForStack.content = providedDataForStack.content.replaceAll("\"timestamp\":\"[a-zA-Z0-9\\-\\:]+\"","")
105- // // verify returned data matches expectation
106- // providedDataForStack.content = JSON.stringify(JSON.parse(providedDataForStack.content), null, 4)
107- // expect(providedDataForStack.content).to.deep.equal(expectedSbom)
108- // // expect(providedDataForStack).to.deep.equal({
109- // // ecosystem: 'pip',
110- // // contentType: 'application/vnd.cyclonedx+json',
111- // // content: expectedSbom
112- // // })
113- // // these test cases takes ~2500-2700 ms each pr >10000 in CI (for the first test-case)
114- // }).timeout(process.env.GITHUB_ACTIONS ? 60000 : 30000)
115- // })
104+ // providedDataForStack.content = providedDataForStack.content.replaceAll("\"timestamp\":\"[a-zA-Z0-9\\-\\:]+\"","")
105+ // verify returned data matches expectation
106+ providedDataForStack . content = JSON . stringify ( JSON . parse ( providedDataForStack . content ) , null , 4 )
107+ expect ( providedDataForStack . content ) . to . deep . equal ( expectedSbom )
108+ // expect(providedDataForStack).to.deep.equal({
109+ // ecosystem: 'pip',
110+ // contentType: 'application/vnd.cyclonedx+json',
111+ // content: expectedSbom
112+ // })
113+ // these test cases takes ~2500-2700 ms each pr >10000 in CI (for the first test-case)
114+ } ) . timeout ( process . env . GITHUB_ACTIONS ? 60000 : 30000 )
115+ } )
116116
117- // }).beforeAll(() => {clock = useFakeTimers(new Date('2023-10-01T00:00:00.000Z'))}).afterAll(()=> clock.restore());
117+ } ) . beforeAll ( ( ) => { clock = useFakeTimers ( new Date ( '2023-10-01T00:00:00.000Z' ) ) } ) . afterAll ( ( ) => clock . restore ( ) ) ;
0 commit comments