diff --git a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCMSBuilderPropertyTest.java b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCMSBuilderPropertyTest.java index a319006a..0bf43e38 100644 --- a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCMSBuilderPropertyTest.java +++ b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCMSBuilderPropertyTest.java @@ -2,6 +2,7 @@ import com.pholser.junit.quickcheck.Property; import com.pholser.junit.quickcheck.runner.JUnitQuickcheck; +import net.ripe.rpki.commons.crypto.ValidityPeriod; import org.joda.time.DateTime; import org.junit.runner.RunWith; @@ -14,27 +15,21 @@ @RunWith(JUnitQuickcheck.class) public class ManifestCMSBuilderPropertyTest { - - @Property public void buildEncodedParseCheck( - byte[] content, - BigInteger manifestNumber, - Integer validityHours - ){ - ManifestCmsBuilder builder = new ManifestCmsBuilder(); - builder.addFile("test.crl", content); - builder.withManifestNumber(manifestNumber); - builder.withSignatureProvider(DEFAULT_SIGNATURE_PROVIDER); - builder.withCertificate(createValidManifestEECertificate(TEST_KEY_PAIR)); - DateTime start = DateTime.now(); - builder.withThisUpdateTime(start); - builder.withNextUpdateTime(start.plusHours(validityHours)); - ManifestCms manifestCms = builder.build(TEST_KEY_PAIR.getPrivate()); - - ManifestCmsParser mftParser = new ManifestCmsParser(); - mftParser.parse("test.mft", manifestCms.getEncoded()); - assertTrue(mftParser.getManifestCms().containsFile("test.crl")); + @Property + public void buildEncodedParseCheck(byte[] content, BigInteger manifestNumber, Integer validityHours) { + ManifestCmsBuilder builder = new ManifestCmsBuilder(); + builder.addFile("test.crl", content); + builder.withManifestNumber(manifestNumber); + builder.withSignatureProvider(DEFAULT_SIGNATURE_PROVIDER); + builder.withCertificate(createValidManifestEECertificate(TEST_KEY_PAIR)); + DateTime start = DateTime.now(); + builder.withValidityPeriod(new ValidityPeriod(start, start.plusHours(Math.abs(validityHours)))); + ManifestCms manifestCms = builder.build(TEST_KEY_PAIR.getPrivate()); + + ManifestCmsParser mftParser = new ManifestCmsParser(); + mftParser.parse("test.mft", manifestCms.getEncoded()); + assertTrue(mftParser.getManifestCms().containsFile("test.crl")); } - } diff --git a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsBuilderTest.java b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsBuilderTest.java index b3a02914..2c9fa1d6 100644 --- a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsBuilderTest.java +++ b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsBuilderTest.java @@ -27,8 +27,7 @@ public class ManifestCmsBuilderTest { @Before public void setUp() { subject.withManifestNumber(BigInteger.valueOf(68)); - subject.withThisUpdateTime(THIS_UPDATE_TIME); - subject.withNextUpdateTime(NEXT_UPDATE_TIME); + subject.withValidityPeriod(new ValidityPeriod(THIS_UPDATE_TIME, NEXT_UPDATE_TIME)); subject.withCertificate(createValidManifestEECertificate()); subject.withSignatureProvider(DEFAULT_SIGNATURE_PROVIDER); } diff --git a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsParserTest.java b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsParserTest.java index 67f4ec57..5f63be9d 100644 --- a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsParserTest.java +++ b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsParserTest.java @@ -144,7 +144,7 @@ public void setUp() { DateTimeUtils.setCurrentMillisFixed(THIS_UPDATE_TIME.getMillis()); ManifestCmsBuilder builder = new ManifestCmsBuilder(); builder.withCertificate(createValidManifestEECertificate()).withManifestNumber(BigInteger.valueOf(68)); - builder.withThisUpdateTime(THIS_UPDATE_TIME).withNextUpdateTime(NEXT_UPDATE_TIME); + builder.withValidityPeriod(new ValidityPeriod(THIS_UPDATE_TIME, NEXT_UPDATE_TIME)); builder.addFile("foo1", FOO_CONTENT); builder.addFile("BaR", BAR_CONTENT); builder.withSignatureProvider(DEFAULT_SIGNATURE_PROVIDER); @@ -201,7 +201,7 @@ public void shouldRejectManifestWithNonInheritEECert() { // Use 10/8 EE cert builder.withCertificate(createTenSlashEightResourceCertificate()).withManifestNumber(BigInteger.valueOf(68)); - builder.withThisUpdateTime(THIS_UPDATE_TIME).withNextUpdateTime(NEXT_UPDATE_TIME); + builder.withValidityPeriod(new ValidityPeriod(THIS_UPDATE_TIME, NEXT_UPDATE_TIME)); builder.addFile("foo1", FOO_CONTENT); builder.addFile("BaR", BAR_CONTENT); diff --git a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsTest.java b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsTest.java index 4e890013..9ae0c2c1 100644 --- a/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsTest.java +++ b/src/test/java/net/ripe/rpki/commons/crypto/cms/manifest/ManifestCmsTest.java @@ -225,15 +225,19 @@ public void shouldRejectWhenThisUpdateTimeIsNotBeforeNextUpdateTime() { IpResourceSet resources = rootCertificate.getResources(); - CertificateRepositoryObjectValidationContext context = new CertificateRepositoryObjectValidationContext(ROOT_CERTIFICATE_LOCATION, rootCertificate, resources, Lists.newArrayList(rootCertificate.getSubject().getName())); + CertificateRepositoryObjectValidationContext context = new CertificateRepositoryObjectValidationContext( + ROOT_CERTIFICATE_LOCATION, rootCertificate, resources, Lists.newArrayList(rootCertificate.getSubject().getName())); ValidationResult result = ValidationResult.withLocation(ROOT_SIA_MANIFEST_RSYNC_LOCATION); subject.validateWithCrl(ROOT_SIA_MANIFEST_RSYNC_LOCATION.toASCIIString(), context, ValidationOptions.strictValidation(), result, crl); assertTrue(result.hasFailures()); assertEquals( - new ValidationCheck(ValidationStatus.ERROR, ValidationString.MANIFEST_THIS_UPDATE_TIME_BEFORE_NEXT_UPDATE_TIME, NEXT_UPDATE_TIME.plusSeconds(1).toString(), NEXT_UPDATE_TIME.toString()), - result.getResult(new ValidationLocation(ROOT_SIA_MANIFEST_RSYNC_LOCATION), ValidationString.MANIFEST_THIS_UPDATE_TIME_BEFORE_NEXT_UPDATE_TIME) + new ValidationCheck(ValidationStatus.ERROR, + ValidationString.MANIFEST_THIS_UPDATE_TIME_BEFORE_NEXT_UPDATE_TIME, + NEXT_UPDATE_TIME.plusSeconds(1).toString(), NEXT_UPDATE_TIME.toString()), + result.getResult(new ValidationLocation(ROOT_SIA_MANIFEST_RSYNC_LOCATION), + ValidationString.MANIFEST_THIS_UPDATE_TIME_BEFORE_NEXT_UPDATE_TIME) ); } @@ -455,7 +459,7 @@ public static ManifestCmsBuilder getRootManifestBuilder(ValidityPeriod validityP ManifestCmsBuilder builder = new ManifestCmsBuilder(); builder.withCertificate(getManifestEEResourceCertificateBuilder().build()); builder.withManifestNumber(BigInteger.valueOf(68)); - builder.withThisUpdateTime(validityPeriod.getNotValidBefore()).withNextUpdateTime(validityPeriod.getNotValidAfter()); + builder.withValidityPeriod(validityPeriod); builder.withSignatureProvider(DEFAULT_SIGNATURE_PROVIDER); return builder; }