github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/cataloger/python/parse_pipfile_lock_test.go (about)

     1  package python
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/anchore/syft/syft/artifact"
     7  	"github.com/anchore/syft/syft/file"
     8  	"github.com/anchore/syft/syft/pkg"
     9  	"github.com/anchore/syft/syft/pkg/cataloger/internal/pkgtest"
    10  )
    11  
    12  func TestParsePipFileLock(t *testing.T) {
    13  
    14  	fixture := "test-fixtures/pipfile-lock/Pipfile.lock"
    15  	locations := file.NewLocationSet(file.NewLocation(fixture))
    16  	expectedPkgs := []pkg.Package{
    17  		{
    18  			Name:         "aio-pika",
    19  			Version:      "6.8.0",
    20  			PURL:         "pkg:pypi/aio-pika@6.8.0",
    21  			Locations:    locations,
    22  			Language:     pkg.Python,
    23  			Type:         pkg.PythonPkg,
    24  			MetadataType: pkg.PythonPipfileLockMetadataType,
    25  			Metadata: pkg.PythonPipfileLockMetadata{
    26  				Index: "https://pypi.org/simple",
    27  				Hashes: []string{
    28  					"sha256:1d4305a5f78af3857310b4fe48348cdcf6c097e0e275ea88c2cd08570531a369",
    29  					"sha256:e69afef8695f47c5d107bbdba21bdb845d5c249acb3be53ef5c2d497b02657c0",
    30  				}},
    31  		},
    32  		{
    33  			Name:         "aiodns",
    34  			Version:      "2.0.0",
    35  			PURL:         "pkg:pypi/aiodns@2.0.0",
    36  			Locations:    locations,
    37  			Language:     pkg.Python,
    38  			Type:         pkg.PythonPkg,
    39  			MetadataType: pkg.PythonPipfileLockMetadataType,
    40  			Metadata: pkg.PythonPipfileLockMetadata{
    41  				Index: "https://test.pypi.org/simple",
    42  				Hashes: []string{
    43  					"sha256:815fdef4607474295d68da46978a54481dd1e7be153c7d60f9e72773cd38d77d",
    44  					"sha256:aaa5ac584f40fe778013df0aa6544bf157799bd3f608364b451840ed2c8688de",
    45  				},
    46  			},
    47  		},
    48  		{
    49  			Name:         "aiohttp",
    50  			Version:      "3.7.4.post0",
    51  			PURL:         "pkg:pypi/aiohttp@3.7.4.post0",
    52  			Locations:    locations,
    53  			Language:     pkg.Python,
    54  			Type:         pkg.PythonPkg,
    55  			MetadataType: pkg.PythonPipfileLockMetadataType,
    56  			Metadata: pkg.PythonPipfileLockMetadata{
    57  				Index: "https://pypi.org/simple",
    58  				Hashes: []string{
    59  					"sha256:02f46fc0e3c5ac58b80d4d56eb0a7c7d97fcef69ace9326289fb9f1955e65cfe",
    60  					"sha256:0563c1b3826945eecd62186f3f5c7d31abb7391fedc893b7e2b26303b5a9f3fe",
    61  				},
    62  			},
    63  		},
    64  		{
    65  			Name:         "aiohttp-jinja2",
    66  			Version:      "1.4.2",
    67  			PURL:         "pkg:pypi/aiohttp-jinja2@1.4.2",
    68  			Locations:    locations,
    69  			Language:     pkg.Python,
    70  			Type:         pkg.PythonPkg,
    71  			MetadataType: pkg.PythonPipfileLockMetadataType,
    72  			Metadata: pkg.PythonPipfileLockMetadata{
    73  				Index: "https://pypi.org/simple",
    74  				Hashes: []string{
    75  					"sha256:860da7582efa866744bad5883947557d0f82e457d69903ea65d666b66f8a69ca",
    76  					"sha256:9c22a0e48e3b277fc145c67dd8c3b8f609dab36bce9eb337f70dfe716663c9a0",
    77  				},
    78  			},
    79  		},
    80  	}
    81  
    82  	// TODO: relationships are not under test
    83  	var expectedRelationships []artifact.Relationship
    84  
    85  	pkgtest.TestFileParser(t, fixture, parsePipfileLock, expectedPkgs, expectedRelationships)
    86  }