Improve code coverage for aaf cadi modules
[aaf/cadi.git] / aaf / src / test / java / org / onap / aaf / cadi / aaf / v2_0 / JU_AAFAuthnTest.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aaf\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
10  * * \r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * * \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
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 package org.onap.aaf.cadi.aaf.v2_0;\r
24 import static org.junit.Assert.*;\r
25 \r
26 import org.junit.Test;\r
27 \r
28 \r
29 \r
30 import static org.junit.Assert.*;\r
31 import static org.mockito.Matchers.anyInt;\r
32 import static org.mockito.Mockito.when;\r
33 \r
34 \r
35 import org.junit.Before;\r
36 import org.junit.Test;\r
37 import org.mockito.Answers;\r
38 import org.mockito.Mock;\r
39 import org.mockito.MockitoAnnotations;\r
40 import org.onap.aaf.cadi.AbsUserCache;\r
41 import org.onap.aaf.cadi.CadiException;\r
42 import org.onap.aaf.cadi.aaf.AAFPermission;\r
43 import org.onap.aaf.cadi.client.Future;\r
44 import org.onap.aaf.inno.env.APIException;\r
45 \r
46 import com.att.aft.dme2.internal.jersey.api.client.Client;\r
47 \r
48 public class JU_AAFAuthnTest {\r
49         \r
50         @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
51         private AAFCon<Client> con;\r
52 \r
53         @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
54         private Future<String> fp;\r
55 \r
56         @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
57         private AbsUserCache<AAFPermission> cache;\r
58 \r
59         \r
60         @Before\r
61         public void setup() throws APIException, CadiException {\r
62                 MockitoAnnotations.initMocks(this);\r
63                 when(con.client(AAFCon.AAF_LATEST_VERSION).read("/authn/basicAuth", "text/plain")).thenReturn(fp);\r
64         }\r
65         \r
66         @Test\r
67         public void testAAFAuthnAAFConOfCLIENT() throws Exception {\r
68                 when(fp.get(anyInt())).thenReturn(false);\r
69                 when(fp.code()).thenReturn(401);\r
70                 when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
71                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
72                 \r
73                 assertNotNull(auth.validate("NewUser", "New Password"));;\r
74         }\r
75 \r
76         @Test\r
77         public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission() throws Exception {\r
78                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
79         }\r
80         \r
81         @Test\r
82         public void testAAFAuthnAAFConOfCLIENT1() throws Exception {\r
83                 when(fp.get(anyInt())).thenReturn(false);\r
84                 when(fp.code()).thenReturn(401);\r
85                 when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
86                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
87                 \r
88                 assertNotNull(auth.validate("NewUser1", "New Password1"));;\r
89         }\r
90 \r
91         @Test\r
92         public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission1() throws Exception {\r
93                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
94         }\r
95         \r
96         @Test\r
97         public void testAAFAuthnAAFConOfCLIENT2() throws Exception {\r
98                 when(fp.get(anyInt())).thenReturn(false);\r
99                 when(fp.code()).thenReturn(401);\r
100                 when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
101                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
102                 \r
103                 assertNotNull(auth.validate("NewUser2", "New Password2"));;\r
104         }\r
105 \r
106         @Test\r
107         public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission2() throws Exception {\r
108                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
109         }\r
110         \r
111         @Test\r
112         public void testAAFAuthnAAFConOfCLIENT3() throws Exception {\r
113                 when(fp.get(anyInt())).thenReturn(false);\r
114                 when(fp.code()).thenReturn(401);\r
115                 when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
116                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
117                 \r
118                 assertNotNull(auth.validate("NewUser3", "New Password3"));;\r
119         }\r
120 \r
121         @Test\r
122         public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission3() throws Exception {\r
123                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
124         }\r
125         \r
126         @Test\r
127         public void testAAFAuthnAAFConOfCLIENT4() throws Exception {\r
128                 when(fp.get(anyInt())).thenReturn(false);\r
129                 when(fp.code()).thenReturn(401);\r
130                 when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
131                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
132                 \r
133                 assertNotNull(auth.validate("NewUser4", "New Password4"));;\r
134         }\r
135 \r
136         @Test\r
137         public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission4() throws Exception {\r
138                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
139         }\r
140         \r
141         @Test\r
142         public void testAAFAuthnAAFConOfCLIENT5() throws Exception {\r
143                 when(fp.get(anyInt())).thenReturn(false);\r
144                 when(fp.code()).thenReturn(401);\r
145                 when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
146                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
147                 \r
148                 assertNotNull(auth.validate("NewUser5", "New Password5"));;\r
149         }\r
150 \r
151         @Test\r
152         public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission5() throws Exception {\r
153                 AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
154         }\r
155 }\r