@Test public void shouldBuildParseEncodedRpkiCaCertRequest() throws Exception { PKCS10CertificationRequest pkcs10Request = createRpkiCaCertificateRequest(); assertNotNull(pkcs10Request); PKCS10CertificationRequest decodedPkcs10Request = new PKCS10CertificationRequest(pkcs10Request.getEncoded()); RpkiCaCertificateRequestParser requestParser = new RpkiCaCertificateRequestParser(decodedPkcs10Request); Assert.assertEquals( ProvisioningObjectMother.RPKI_CA_CERT_REQUEST_CA_REPO_URI, requestParser.getCaRepositoryUri()); Assert.assertEquals( ProvisioningObjectMother.RPKI_CA_CERT_REQUEST_CA_MFT_URI, requestParser.getManifestUri()); Assert.assertEquals( ProvisioningObjectMother.RPKI_CA_CERT_REQUEST_CA_NOTIFICATION_URI, requestParser.getNotificationUri()); Assert.assertEquals( ProvisioningObjectMother.RPKI_CA_CERT_REQUEST_KEYPAIR.getPublic(), requestParser.getPublicKey()); }
@Test public void shouldRoundTripBuildParseRpkiCaCertRequest() throws RpkiCaCertificateRequestParserException { RpkiCaCertificateRequestBuilder requestBuilder = new RpkiCaCertificateRequestBuilder(); URI caRepositoryUri = URI.create("rsync://host/module/subdir/"); URI manifestUri = URI.create("rsync://host/module/subdir/subject.mft"); X500Principal subject = new X500Principal("CN=subject"); KeyPair keyPair = PregeneratedKeyPairFactory.getInstance().generate(); requestBuilder.withCaRepositoryUri(caRepositoryUri); requestBuilder.withManifestUri(manifestUri); requestBuilder.withSubject(subject); PKCS10CertificationRequest pkcs10Request = requestBuilder.build(keyPair); assertNotNull(pkcs10Request); RpkiCaCertificateRequestParser requestParser = new RpkiCaCertificateRequestParser(pkcs10Request); assertEquals(caRepositoryUri, requestParser.getCaRepositoryUri()); assertEquals(manifestUri, requestParser.getManifestUri()); assertEquals(keyPair.getPublic(), requestParser.getPublicKey()); }