1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * Copyright © 2017 Amdocs
\r
7 * * ===========================================================================
\r
8 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
9 * * you may not use this file except in compliance with the License.
\r
10 * * You may obtain a copy of the License at
\r
12 * * http://www.apache.org/licenses/LICENSE-2.0
\r
14 * * Unless required by applicable law or agreed to in writing, software
\r
15 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
16 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
17 * * See the License for the specific language governing permissions and
\r
18 * * limitations under the License.
\r
19 * * ============LICENSE_END====================================================
\r
21 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
23 ******************************************************************************/
\r
24 package com.att.dao.aaf.test;
\r
26 import static org.junit.Assert.assertEquals;
\r
27 import static org.junit.Assert.assertTrue;
\r
29 import java.io.IOException;
\r
30 import java.math.BigInteger;
\r
31 import java.nio.ByteBuffer;
\r
32 import java.security.NoSuchAlgorithmException;
\r
33 import java.util.List;
\r
35 import org.junit.Test;
\r
37 import com.att.authz.layer.Result;
\r
38 import com.att.dao.aaf.cass.CertDAO;
\r
39 import com.att.dao.aaf.cass.CertDAO.Data;
\r
40 import com.att.inno.env.APIException;
\r
43 * UserDAO unit test.
\r
47 public class JU_CertDAO extends AbsJUCass {
\r
49 public void test() throws IOException, NoSuchAlgorithmException, APIException {
\r
50 CertDAO cdao = new CertDAO(trans,cluster,"authz");
\r
53 CertDAO.Data data = new CertDAO.Data();
\r
54 data.serial=new BigInteger("11839383");
\r
55 data.id = "m55555@tguard.att.com";
\r
56 data.x500="CN=ju_cert.dao.att.com, OU=AAF, O=\"ATT Services, Inc.\", L=Southfield, ST=Michigan, C=US";
\r
57 data.x509="I'm a cert";
\r
59 cdao.create(trans,data);
\r
62 ByteBuffer bb = data.bytify();
\r
63 Data bdata = new CertDAO.Data();
\r
64 bdata.reconstitute(bb);
\r
65 checkData1(data, bdata);
\r
67 // Validate Read with key fields in Data
\r
68 Result<List<CertDAO.Data>> rlcd = cdao.read(trans,data);
\r
69 assertTrue(rlcd.isOKhasData());
\r
70 for(CertDAO.Data d : rlcd.value) {
\r
74 // Validate Read with key fields in Data
\r
75 rlcd = cdao.read(trans,data.ca,data.serial);
\r
76 assertTrue(rlcd.isOKhasData());
\r
77 for(CertDAO.Data d : rlcd.value) {
\r
82 data.id = "m66666.tguard.att.com";
\r
83 cdao.update(trans,data);
\r
84 rlcd = cdao.read(trans,data);
\r
85 assertTrue(rlcd.isOKhasData());
\r
86 for(CertDAO.Data d : rlcd.value) {
\r
90 cdao.delete(trans,data, true);
\r
98 private void checkData1(Data data, Data d) {
\r
99 assertEquals(data.ca,d.ca);
\r
100 assertEquals(data.serial,d.serial);
\r
101 assertEquals(data.id,d.id);
\r
102 assertEquals(data.x500,d.x500);
\r
103 assertEquals(data.x509,d.x509);
\r