]> WPIA git - gigi.git/blob - tests/org/cacert/gigi/dbObjects/TestCertificate.java
8e7f8efee3bfe1aeb1f79f8397b3d3e7eb6f9630
[gigi.git] / tests / org / cacert / gigi / dbObjects / TestCertificate.java
1 package org.cacert.gigi.dbObjects;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.security.GeneralSecurityException;
7 import java.security.KeyPair;
8
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;
13
14 public class TestCertificate extends ClientBusinessTest {
15
16     @Test
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, CertificateProfile.getById(1));
21
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());
31     }
32 }