@@ -451,3 +451,62 @@ func TestDecodePomLicenses(t *testing.T) {
451451 })
452452 }
453453}
454+
455+ func TestIsJarLicenseFile (t * testing.T ) {
456+ tests := []struct {
457+ name string
458+ path string
459+ want bool
460+ }{
461+ {
462+ name : "LICENSE at root" ,
463+ path : "LICENSE" ,
464+ want : true ,
465+ },
466+ {
467+ name : "LICENSE.txt at root" ,
468+ path : "LICENSE.txt" ,
469+ want : true ,
470+ },
471+ {
472+ name : "license under META-INF" ,
473+ path : "META-INF/LICENSE" ,
474+ want : true ,
475+ },
476+ {
477+ name : "copyright at root" ,
478+ path : "COPYRIGHT" ,
479+ want : true ,
480+ },
481+ {
482+ name : "nested archive named license.jar" ,
483+ path : "license.jar" ,
484+ want : false ,
485+ },
486+ {
487+ name : "nested archive named copyright.war under META-INF" ,
488+ path : "META-INF/copyright.war" ,
489+ want : false ,
490+ },
491+ {
492+ name : "vendored license with prefix" ,
493+ path : "META-INF/FastDoubleParser-LICENSE" ,
494+ want : false ,
495+ },
496+ {
497+ name : "license in subdirectory" ,
498+ path : "META-INF/licenses/LICENSE" ,
499+ want : false ,
500+ },
501+ {
502+ name : "unrelated file" ,
503+ path : "com/example/Main.class" ,
504+ want : false ,
505+ },
506+ }
507+ for _ , tt := range tests {
508+ t .Run (tt .name , func (t * testing.T ) {
509+ assert .Equal (t , tt .want , jar .IsJarLicenseFile (tt .path ))
510+ })
511+ }
512+ }
0 commit comments