public class ZipFileSizeValidator {
private static final int THRESHOLD_ENTRIES = 10000;
- private static int THRESHOLD_SIZE = 100000000;
+ private static int thresholdSize = 100000000;
private static final double THRESHOLD_RATIO = 40;
private static final String INVALID_ZIP = "Invalid ZIP archive content.";
* Validate the total Size and number of entries in the zip.
*/
public void validateSizeAndEntries() {
- if (totalUncompressedSizeOfYangFilesInArchive > THRESHOLD_SIZE) {
+ if (totalUncompressedSizeOfYangFilesInArchive > thresholdSize) {
throw new ModelValidationException(INVALID_ZIP,
String.format("The total size of uncompressed yang files exceeds the CPS limit of %s bytes.",
- THRESHOLD_SIZE));
+ thresholdSize));
}
if (totalYangFileEntriesInArchive > THRESHOLD_ENTRIES) {
throw new ModelValidationException(INVALID_ZIP,
def 'Yang file limits in zip archive: #scenario for the bug reported in CPS-1477'() {
given: 'a yang file size (uncompressed) limit of #threshold bytes'
- ZipFileSizeValidator.THRESHOLD_SIZE = threshold
+ ZipFileSizeValidator.thresholdSize = threshold
and: 'an archive with a yang file of 1083 bytes'
def multipartFile = multipartZipFileFromResource('/yang-files-set-total-1083-bytes.zip')
when: 'attempt to extract yang files'
class ZipFileSizeValidatorSpec extends Specification {
- def static thresholdSize = ZipFileSizeValidator.THRESHOLD_SIZE
+ def static thresholdSize = ZipFileSizeValidator.thresholdSize
def static thresholdEntries = ZipFileSizeValidator.THRESHOLD_ENTRIES
def static thresholdRatio = ZipFileSizeValidator.THRESHOLD_RATIO