Skip to content

Commit 14170c4

Browse files
committed
Add test for declared license mapping edge case.
Signed-off-by: Daniel Kreck <[email protected]>
1 parent 99c997c commit 14170c4

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

model/src/test/kotlin/PackageCurationTest.kt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,34 @@ class PackageCurationTest : WordSpec({
387387
result.metadata.declaredLicensesProcessed.spdxExpression shouldBe expression
388388
}
389389
}
390+
391+
"preserve OR operator when mapping makes previously invalid licenses valid" {
392+
// This test case demonstrates a bug where two declared licenses - one valid SPDX and one
393+
// invalid that needs mapping - are incorrectly combined with AND instead of OR.
394+
val pkg = Package.EMPTY.copy(
395+
declaredLicenses = setOf("Apache-2.0", "GNU Lesser General Public License v2.1 only"),
396+
// In reality, the initial processing only mapped the valid license
397+
declaredLicensesProcessed = ProcessedDeclaredLicense(
398+
spdxExpression = "Apache-2.0".toSpdx(),
399+
unmapped = setOf("GNU Lesser General Public License v2.1 only")
400+
)
401+
)
402+
403+
val curation = PackageCuration(
404+
id = pkg.id,
405+
data = PackageCurationData(
406+
declaredLicenseMapping = mapOf(
407+
"GNU Lesser General Public License v2.1 only" to "LGPL-2.1-only".toSpdx()
408+
)
409+
)
410+
)
411+
412+
val result = curation.apply(pkg.toCuratedPackage())
413+
414+
// Expected: Since the package originally declared two separate licenses, they should be
415+
// combined with OR (dual-licensing), not AND (both licenses apply).
416+
result.metadata.declaredLicensesProcessed.spdxExpression shouldBe "Apache-2.0 OR LGPL-2.1-only".toSpdx()
417+
}
390418
}
391419

392420
"isApplicable()" should {

0 commit comments

Comments
 (0)