+ }
+
+ @Test
+ public void testIssueWithDescription() throws IOException, GeneralSecurityException {
+ String description = "Just a new comment." + RandomToken.generateToken(32);
+ HttpURLConnection huc = sendCertificateForm(description);
+ assertEquals(302, huc.getResponseCode());
+
+ URLConnection uc = get(Certificates.PATH);
+ assertThat(IOUtils.readURL(uc), containsString(description));
+
+ description = "Just a new comment." + RandomToken.generateToken(100);
+ huc = sendCertificateForm(description);
+ assertThat(fetchStartErrorMessage(IOUtils.readURL(huc)), containsString("Submitted description is longer than 100 characters."));
+ }
+
+ private HttpURLConnection sendCertificateForm(String description) throws IOException, GeneralSecurityException {
+ HttpURLConnection huc = openCertificateForm();
+ OutputStream out = huc.getOutputStream();
+ out.write(("csrf=" + URLEncoder.encode(csrf, "UTF-8")).getBytes("UTF-8"));
+ out.write(("&CN=" + URLEncoder.encode(CertificateRequest.DEFAULT_CN, "UTF-8") + "&profile=client&SANs=" + URLEncoder.encode("email:" + email + "\n", "UTF-8")).getBytes("UTF-8"));
+ out.write(("&hash_alg=SHA512").getBytes("UTF-8"));
+ out.write(("&description=" + URLEncoder.encode(description, "UTF-8")).getBytes("UTF-8"));
+ return huc;
+ }
+
+ private HttpURLConnection openCertificateForm() throws IOException, GeneralSecurityException, UnsupportedEncodingException {
+ PKCS10Attributes atts = buildAtts(new ObjectIdentifier[] {
+ CertificateRequest.OID_KEY_USAGE_SSL_CLIENT
+ }, new RFC822Name(email));
+
+ String pem = generatePEMCSR(kp, "CN=a b,email=" + email, atts, "SHA512WithRSA");
+
+ String[] res = fillOutForm("CSR=" + URLEncoder.encode(pem, "UTF-8"));
+ assertArrayEquals(new String[] {
+ "client", "a b", "email:" + email + "\n", Digest.SHA512.toString()
+ }, res);