1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package com.att.authz.cm.cert;
\r
25 import static org.junit.Assert.*;
\r
26 import static org.mockito.Mockito.mock;
\r
28 import java.io.IOException;
\r
29 import java.security.cert.CertificateException;
\r
30 import java.security.cert.X509Certificate;
\r
32 import org.bouncycastle.asn1.x500.X500Name;
\r
33 import org.bouncycastle.operator.OperatorCreationException;
\r
34 import org.bouncycastle.pkcs.PKCS10CertificationRequest;
\r
35 import org.junit.BeforeClass;
\r
36 import org.junit.Rule;
\r
37 import org.junit.Test;
\r
38 import org.junit.rules.ExpectedException;
\r
39 import org.junit.runner.RunWith;
\r
40 import org.mockito.runners.MockitoJUnitRunner;
\r
42 import com.att.cadi.cm.CertException;
\r
43 import com.att.inno.env.Trans;
\r
45 @RunWith(MockitoJUnitRunner.class)
\r
46 public class JU_CSRMeta {
\r
48 private static CSRMeta csrmeta;
\r
49 private static Trans trans;
\r
50 private static PKCS10CertificationRequest req;
\r
53 public static void setUp() {
\r
54 trans = mock(Trans.class);
\r
55 csrmeta = new CSRMeta();
\r
57 csrmeta.email("pupleti@ht.com");
\r
58 csrmeta.mechID("HAKJH787");
\r
63 csrmeta.challenge("Challenge");
\r
68 public void x500Name() throws IOException {
\r
70 X500Name x500 = csrmeta.x500Name();
\r
71 assertEquals(x500.toString(),"CN=CN,E=pupleti@ht.com,OU=HAKJH787,O=O,L=L,ST=ST,C=C");
\r
75 public void initialConversationCert() throws CertificateException, OperatorCreationException, IOException {
\r
76 X509Certificate cert = csrmeta.initialConversationCert(trans);
\r
77 assertEquals(cert.getBasicConstraints(),-1);
\r
81 public void generateCSR() throws IOException, CertException {
\r
82 req = csrmeta.generateCSR(trans);
\r
87 public ExpectedException thrown= ExpectedException.none();
\r
90 public void dump() throws IOException, CertException {
\r
91 req = csrmeta.generateCSR(trans);
\r