1 package org.cacert.gigi.dbObjects;
3 import static org.junit.Assert.*;
5 import java.io.IOException;
6 import java.security.GeneralSecurityException;
7 import java.security.KeyPair;
9 import org.cacert.gigi.GigiApiException;
10 import org.cacert.gigi.dbObjects.Certificate.CSRType;
11 import org.cacert.gigi.testUtils.ClientBusinessTest;
12 import org.junit.Test;
14 public class TestCertificate extends ClientBusinessTest {
17 public void testSetLoginEnabled() throws GeneralSecurityException, IOException, GigiApiException {
18 KeyPair kp = generateKeypair();
19 String key = generatePEMCSR(kp, "CN=testmail@example.com");
20 Certificate c = new Certificate(u, u, Certificate.buildDN("CN", "testmail@example.com"), Digest.SHA256, key, CSRType.CSR, getClientProfile());
22 assertFalse(c.isLoginEnabled());
23 c.setLoginEnabled(true);
24 assertTrue(c.isLoginEnabled());
25 c.setLoginEnabled(true);
26 assertTrue(c.isLoginEnabled());
27 c.setLoginEnabled(false);
28 assertFalse(c.isLoginEnabled());
29 c.setLoginEnabled(false);
30 assertFalse(c.isLoginEnabled());