X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;ds=sidebyside;f=tests%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FTestCertificateAdd.java;h=2a1555f7adc0b34bb2b7278e709d3ee349f5cae8;hb=ee6876a6b2a79171aa9a83ec9ee56f17b8ad0c0b;hp=97bc69c3c1d9e91f339c78d378cf1949178bf8b4;hpb=b58a76fd82cff44fb6e1cdf09c8b04d890ac2e1e;p=gigi.git diff --git a/tests/org/cacert/gigi/pages/account/TestCertificateAdd.java b/tests/org/cacert/gigi/pages/account/TestCertificateAdd.java index 97bc69c3..2a1555f7 100644 --- a/tests/org/cacert/gigi/pages/account/TestCertificateAdd.java +++ b/tests/org/cacert/gigi/pages/account/TestCertificateAdd.java @@ -56,6 +56,13 @@ import sun.security.x509.X509Key; public class TestCertificateAdd extends ClientTest { + private static class OnPageError extends Error { + + public OnPageError(String page) { + super(page); + } + } + KeyPair kp = generateKeypair(); String csrf; @@ -68,7 +75,7 @@ public class TestCertificateAdd extends ClientTest { @Test public void testSimpleServer() throws IOException, GeneralSecurityException { PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] { - CertificateRequest.OID_KEY_USAGE_SSL_SERVER + CertificateRequest.OID_KEY_USAGE_SSL_SERVER }, new DNSName(uniq + ".tld")); String pem = generatePEMCSR(kp, "CN=a." + uniq + ".tld", atts); @@ -82,7 +89,7 @@ public class TestCertificateAdd extends ClientTest { @Test public void testSimpleMail() throws IOException, GeneralSecurityException { PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] { - CertificateRequest.OID_KEY_USAGE_EMAIL_PROTECTION + CertificateRequest.OID_KEY_USAGE_EMAIL_PROTECTION }, new DNSName("a." + uniq + ".tld"), new DNSName("b." + uniq + ".tld"), new RFC822Name(email)); String pem = generatePEMCSR(kp, "CN=a b", atts, "SHA384WithRSA"); @@ -96,7 +103,7 @@ public class TestCertificateAdd extends ClientTest { @Test public void testSimpleClient() throws IOException, GeneralSecurityException { PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] { - CertificateRequest.OID_KEY_USAGE_SSL_CLIENT + CertificateRequest.OID_KEY_USAGE_SSL_CLIENT }, new RFC822Name(email)); String pem = generatePEMCSR(kp, "CN=a b,email=" + email, atts, "SHA512WithRSA"); @@ -116,7 +123,7 @@ public class TestCertificateAdd extends ClientTest { @Test public void testIssue() throws IOException, GeneralSecurityException { PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] { - CertificateRequest.OID_KEY_USAGE_SSL_CLIENT + CertificateRequest.OID_KEY_USAGE_SSL_CLIENT }, new RFC822Name(email)); String pem = generatePEMCSR(kp, "CN=a b,email=" + email, atts, "SHA512WithRSA"); @@ -132,7 +139,7 @@ public class TestCertificateAdd extends ClientTest { OutputStream out = huc.getOutputStream(); out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8")); out.write(("&CN=CAcert+WoT+User&profile=client&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8")); - out.write(("&hash_alg=SHA512&CCA=y").getBytes("UTF-8")); + out.write(("&hash_alg=SHA512&tos_agree=y").getBytes("UTF-8")); URLConnection uc = authenticate(new URL(huc.getHeaderField("Location") + ".crt")); String crt = IOUtils.readURL(new InputStreamReader(uc.getInputStream(), "UTF-8")); @@ -243,7 +250,7 @@ public class TestCertificateAdd extends ClientTest { private X509Certificate createCertWithValidity(String validity) throws IOException, GeneralSecurityException, UnsupportedEncodingException, MalformedURLException, CertificateException { PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] { - CertificateRequest.OID_KEY_USAGE_SSL_CLIENT + CertificateRequest.OID_KEY_USAGE_SSL_CLIENT }, new RFC822Name(email)); String pem = generatePEMCSR(kp, "CN=a b", atts, "SHA512WithRSA"); @@ -255,7 +262,7 @@ public class TestCertificateAdd extends ClientTest { OutputStream out = huc.getOutputStream(); out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8")); out.write(("&profile=client&CN=" + CertificateRequest.DEFAULT_CN + "&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8")); - out.write(("&hash_alg=SHA512&CCA=y&").getBytes("UTF-8")); + out.write(("&hash_alg=SHA512&tos_agree=y&").getBytes("UTF-8")); out.write(validity.getBytes("UTF-8")); String certurl = huc.getHeaderField("Location"); @@ -295,8 +302,9 @@ public class TestCertificateAdd extends ClientTest { assertArrayEquals(new String[] { "client", CertificateRequest.DEFAULT_CN, "", Digest.SHA512.toString() }, res); - } catch (Error e) { - assertTrue(e.getMessage().startsWith("
Challenge mismatch"));
}
return csrf;
}
@@ -310,7 +318,7 @@ public class TestCertificateAdd extends ClientTest {
}
attributeValue.set("SANs", new SubjectAlternativeNameExtension(names));
PKCS10Attributes atts = new PKCS10Attributes(new PKCS10Attribute[] {
- new PKCS10Attribute(PKCS9Attribute.EXTENSION_REQUEST_OID, attributeValue)
+ new PKCS10Attribute(PKCS9Attribute.EXTENSION_REQUEST_OID, attributeValue)
});
ExtendedKeyUsageExtension eku = new ExtendedKeyUsageExtension(//
new Vector<>(Arrays.