--- /dev/null
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ * * http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ * * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+package org.onap.aaf.cadi.aaf.v2_0;\r
+import static org.junit.Assert.*;\r
+\r
+import org.junit.Test;\r
+\r
+\r
+\r
+import static org.junit.Assert.*;\r
+import static org.mockito.Matchers.anyInt;\r
+import static org.mockito.Mockito.when;\r
+\r
+\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Answers;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aaf.cadi.AbsUserCache;\r
+import org.onap.aaf.cadi.CadiException;\r
+import org.onap.aaf.cadi.aaf.AAFPermission;\r
+import org.onap.aaf.cadi.client.Future;\r
+import org.onap.aaf.inno.env.APIException;\r
+\r
+import com.att.aft.dme2.internal.jersey.api.client.Client;\r
+\r
+public class AAFAuthnTest {\r
+ \r
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
+ private AAFCon<Client> con;\r
+\r
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
+ private Future<String> fp;\r
+\r
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)\r
+ private AbsUserCache<AAFPermission> cache;\r
+\r
+ \r
+ @Before\r
+ public void setup() throws APIException, CadiException {\r
+ MockitoAnnotations.initMocks(this);\r
+ when(con.client(AAFCon.AAF_LATEST_VERSION).read("/authn/basicAuth", "text/plain")).thenReturn(fp);\r
+ }\r
+ \r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENT() throws Exception {\r
+ when(fp.get(anyInt())).thenReturn(false);\r
+ when(fp.code()).thenReturn(401);\r
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
+ \r
+ assertNotNull(auth.validate("NewUser", "New Password"));;\r
+ }\r
+\r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission() throws Exception {\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
+ }\r
+ \r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENT1() throws Exception {\r
+ when(fp.get(anyInt())).thenReturn(false);\r
+ when(fp.code()).thenReturn(401);\r
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
+ \r
+ assertNotNull(auth.validate("NewUser1", "New Password1"));;\r
+ }\r
+\r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission1() throws Exception {\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
+ }\r
+ \r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENT2() throws Exception {\r
+ when(fp.get(anyInt())).thenReturn(false);\r
+ when(fp.code()).thenReturn(401);\r
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
+ \r
+ assertNotNull(auth.validate("NewUser2", "New Password2"));;\r
+ }\r
+\r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission2() throws Exception {\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
+ }\r
+ \r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENT3() throws Exception {\r
+ when(fp.get(anyInt())).thenReturn(false);\r
+ when(fp.code()).thenReturn(401);\r
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
+ \r
+ assertNotNull(auth.validate("NewUser3", "New Password3"));;\r
+ }\r
+\r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission3() throws Exception {\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
+ }\r
+ \r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENT4() throws Exception {\r
+ when(fp.get(anyInt())).thenReturn(false);\r
+ when(fp.code()).thenReturn(401);\r
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
+ \r
+ assertNotNull(auth.validate("NewUser4", "New Password4"));;\r
+ }\r
+\r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission4() throws Exception {\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
+ }\r
+ \r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENT5() throws Exception {\r
+ when(fp.get(anyInt())).thenReturn(false);\r
+ when(fp.code()).thenReturn(401);\r
+ when(fp.header("WWW-Authenticate")).thenReturn("Basic realm=\"Value\"");\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con);\r
+ \r
+ assertNotNull(auth.validate("NewUser5", "New Password5"));;\r
+ }\r
+\r
+ @Test\r
+ public void testAAFAuthnAAFConOfCLIENTAbsUserCacheOfAAFPermission5() throws Exception {\r
+ AAFAuthn<Client> auth = new AAFAuthn<Client>(con,cache);\r
+ }\r
+}\r