2 * ============LICENSE_START==========================================
3 * ===================================================================
4 * Copyright © 2018 AT&T Intellectual Property. All rights reserved.
5 * ===================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ============LICENSE_END============================================
19 package org.onap.aaf.auth.cmd.test.ns;
21 import static org.junit.Assert.*;
23 import java.io.Writer;
25 import java.util.ArrayList;
27 import org.onap.aaf.auth.cmd.ns.List;
28 import org.onap.aaf.auth.cmd.ns.NS;
29 import org.onap.aaf.auth.env.AuthzEnv;
30 import org.onap.aaf.cadi.Locator;
31 import org.onap.aaf.cadi.LocatorException;
32 import org.onap.aaf.cadi.PropAccess;
33 import org.onap.aaf.cadi.SecuritySetter;
34 import org.onap.aaf.cadi.client.Future;
35 import org.onap.aaf.cadi.config.SecurityInfoC;
36 import org.onap.aaf.cadi.http.HMangr;
37 import org.onap.aaf.misc.env.APIException;
40 import aaf.v2_0.Roles;
41 import aaf.v2_0.Users.User;
42 import junit.framework.Assert;
44 import org.onap.aaf.auth.cmd.AAFcli;
45 import org.junit.After;
46 import org.junit.Before;
47 import org.junit.Test;
48 import org.mockito.Mock;
49 import org.mockito.Mockito;
50 import static org.mockito.Mockito.*;
52 import org.junit.Test;
54 public class JU_List {
60 private class NssStub extends Nss {
61 public void addNs(Nss.Ns ns) {
62 if (this.ns == null) {
63 this.ns = new ArrayList<Nss.Ns>();
68 private class NsStub extends Ns{
69 public void addAttrib(Nss.Ns.Attrib attrib) {
70 if ( this.attrib == null) {
71 this.attrib = new ArrayList<Nss.Ns.Attrib>();
73 this.attrib.add(attrib);
76 public void addResponsible(String str) {
77 if (this.responsible == null) {
78 this.responsible = new ArrayList<String>();
80 this.responsible.add(str);
83 public void addAdmin(String str) {
84 if (this.admin == null) {
85 this.admin = new ArrayList<String>();
98 public void setUp() throws APIException, LocatorException {
99 PropAccess prop = new PropAccess();
100 AuthzEnv aEnv = new AuthzEnv();
101 Writer wtr = mock(Writer.class);
102 Locator loc = mock(Locator.class);
103 HMangr hman = new HMangr(aEnv, loc);
104 aafcli = new AAFcli(prop, aEnv, wtr, hman, null, null);
106 NS ns = new NS(aafcli);
112 public void testReport() throws Exception {
113 Future<Nss> fu = mock(Future.class);
114 NssStub nssStub = new NssStub();
115 NssStub.NsStub nsStub = nssStub.new NsStub();
116 Nss.Ns.Attrib attrib = mock(Nss.Ns.Attrib.class);
117 when(attrib.getKey()).thenReturn("key");
118 when(attrib.getValue()).thenReturn("value");
119 nsStub.addAttrib(attrib);
120 nsStub.addResponsible("test");
121 nsStub.addAdmin("admin");
122 nssStub.addNs(nsStub);
124 aafcli.eval("DETAILS @[ 123");
126 list.report(fu, "test");
130 public void testGetType() {
131 Assert.assertEquals("n/a", list.getType(user));
133 Assert.assertEquals("U/P", list.getType(user));
135 Assert.assertEquals("U/P2", list.getType(user));
137 Assert.assertEquals("Cert", list.getType(user));
139 Assert.assertEquals("x509", list.getType(user));