github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/syft/pkg/java_metadata_test.go (about) 1 package pkg 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestPomProperties_PkgTypeIndicated(t *testing.T) { 10 cases := []struct { 11 name string 12 pomProperties PomProperties 13 expectedType Type 14 }{ 15 { 16 name: "regular Java package", 17 pomProperties: PomProperties{ 18 Path: "some path", 19 Name: "some name", 20 GroupID: "some group ID", 21 ArtifactID: "some artifact ID", 22 Version: "1", 23 }, 24 expectedType: JavaPkg, 25 }, 26 { 27 name: "cloudbees jenkins plugin", 28 pomProperties: PomProperties{ 29 Path: "some path", 30 Name: "some name", 31 GroupID: "com.cloudbees.jenkins.plugins", 32 ArtifactID: "some artifact ID", 33 Version: "1", 34 }, 35 expectedType: JenkinsPluginPkg, 36 }, 37 { 38 name: "jenkins.io plugin", 39 pomProperties: PomProperties{ 40 Path: "some path", 41 Name: "some name", 42 GroupID: "io.jenkins.plugins", 43 ArtifactID: "some artifact ID", 44 Version: "1", 45 }, 46 expectedType: JenkinsPluginPkg, 47 }, 48 { 49 name: "jenkins-ci.io plugin", 50 pomProperties: PomProperties{ 51 Path: "some path", 52 Name: "some name", 53 GroupID: "io.jenkins-ci.plugins", 54 ArtifactID: "some artifact ID", 55 Version: "1", 56 }, 57 expectedType: JenkinsPluginPkg, 58 }, 59 { 60 name: "jenkins-ci.org plugin", 61 pomProperties: PomProperties{ 62 Path: "some path", 63 Name: "some name", 64 GroupID: "org.jenkins-ci.plugins", 65 ArtifactID: "some artifact ID", 66 Version: "1", 67 }, 68 expectedType: JenkinsPluginPkg, 69 }, 70 { 71 name: "jenkins.org plugin", 72 pomProperties: PomProperties{ 73 Path: "some path", 74 Name: "some name", 75 GroupID: "org.jenkins.plugins", 76 ArtifactID: "some artifact ID", 77 Version: "1", 78 }, 79 expectedType: JenkinsPluginPkg, 80 }, 81 { 82 name: "jenkins plugin prefix", 83 pomProperties: PomProperties{ 84 Path: "some path", 85 Name: "some name", 86 GroupID: "com.cloudbees.jenkins.plugins.bluesteel", 87 ArtifactID: "some artifact ID", 88 Version: "1", 89 }, 90 expectedType: JenkinsPluginPkg, 91 }, 92 { 93 name: "jenkins.plugin somewhere in group id", 94 pomProperties: PomProperties{ 95 Path: "some path", 96 Name: "some name", 97 GroupID: "org.wagoodman.jenkins.plugins.something", 98 ArtifactID: "some artifact ID", 99 Version: "1", 100 }, 101 expectedType: JenkinsPluginPkg, 102 }, 103 } 104 105 for _, tc := range cases { 106 t.Run(tc.name, func(t *testing.T) { 107 actual := tc.pomProperties.PkgTypeIndicated() 108 assert.Equal(t, tc.expectedType, actual) 109 }) 110 } 111 }