Make package ID handling case-insensitive
This commit is contained in:
parent
c8c596aff4
commit
cbfca6a560
|
@ -195,7 +195,7 @@ public class JpaPackageCache extends BasePackageCacheManager implements IHapiPac
|
||||||
ourLog.info("Parsing package .tar.gz ({} bytes) from {}", bytes.length, theSourceDesc);
|
ourLog.info("Parsing package .tar.gz ({} bytes) from {}", bytes.length, theSourceDesc);
|
||||||
|
|
||||||
NpmPackage npmPackage = NpmPackage.fromPackage(new ByteArrayInputStream(bytes));
|
NpmPackage npmPackage = NpmPackage.fromPackage(new ByteArrayInputStream(bytes));
|
||||||
if (!npmPackage.id().equals(thePackageId)) {
|
if (!npmPackage.id().equalsIgnoreCase(thePackageId)) {
|
||||||
throw new InvalidRequestException("Package ID " + npmPackage.id() + " doesn't match expected: " + thePackageId);
|
throw new InvalidRequestException("Package ID " + npmPackage.id() + " doesn't match expected: " + thePackageId);
|
||||||
}
|
}
|
||||||
if (!PackageVersionComparator.isEquivalent(thePackageVersionId, npmPackage.version())) {
|
if (!PackageVersionComparator.isEquivalent(thePackageVersionId, npmPackage.version())) {
|
||||||
|
|
|
@ -14,7 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
@ -114,4 +116,14 @@ public class JpaPackageCacheTest extends BaseJpaR4Test {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPackageIdHandlingIsNotCaseSensitive() throws IOException {
|
||||||
|
String packageNameAllLowercase = "hl7.fhir.us.davinci-cdex";
|
||||||
|
String packageNameUppercase = packageNameAllLowercase.toUpperCase(Locale.ROOT);
|
||||||
|
InputStream stream = IgInstallerDstu3Test.class.getResourceAsStream("/packages/package-davinci-cdex-0.2.0.tgz");
|
||||||
|
|
||||||
|
// The package has the ID in lower-case, so for the test we input the first parameter in upper-case & check that no error is thrown
|
||||||
|
assertDoesNotThrow(() -> myPackageCacheManager.addPackageToCache(packageNameUppercase, "0.2.0", stream, packageNameAllLowercase));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue