+ @Test
+ public void testLoginMethodDisplay() throws IOException {
+ String email = createUniqueName() + "@testmail.org";
+ createVerifiedUser("an", "bn", email, TEST_PASSWORD);
+ String l = login(email, TEST_PASSWORD);
+ URLConnection c = get(l, "");
+ String readURL = IOUtils.readURL(c);
+ assertThat(readURL, containsString("Password"));
+ }
+
+ @Test
+ public void testLoginCertificate() throws IOException, GeneralSecurityException, GigiApiException, InterruptedException {
+ String email = createUniqueName() + "@testmail.org";
+ int user = createVerifiedUser("an", "bn", email, TEST_PASSWORD);
+ KeyPair kp = generateKeypair();
+ String csr = generatePEMCSR(kp, "CN=hans");
+ User u = User.getById(user);
+ Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "hans"), Digest.SHA256, csr, CSRType.CSR, getClientProfile());
+ final PrivateKey pk = kp.getPrivate();
+ await(c.issue(null, "2y", u));
+ final X509Certificate ce = c.cert();
+ c.setLoginEnabled(true);
+ String cookie = login(pk, ce);
+ URL u2 = new URL("https://" + getSecureServerName() + SECURE_REFERENCE);
+ HttpURLConnection huc = (HttpURLConnection) u2.openConnection();
+ huc.addRequestProperty("Cookie", cookie);
+ authenticateClientCert(pk, ce, huc);
+ assertEquals(200, huc.getResponseCode());
+ }