+ }
+
+ @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;
+ }