diff options
-rw-r--r-- | auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/JU_BasicAuthCodeTest.java | 115 | ||||
-rw-r--r-- | auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java | 65 | ||||
-rw-r--r-- | auth/sample/data/identities.dat | 47 | ||||
-rw-r--r-- | auth/sample/data/sample.identities.dat | 9 | ||||
-rw-r--r-- | cadi/core/src/test/resources/output_key | 1 | ||||
-rw-r--r-- | cadi/core/test/output_key | 27 |
6 files changed, 233 insertions, 31 deletions
diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/JU_BasicAuthCodeTest.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/JU_BasicAuthCodeTest.java new file mode 100644 index 00000000..eea60eb0 --- /dev/null +++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/JU_BasicAuthCodeTest.java @@ -0,0 +1,115 @@ +/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.locate;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Answers;
+import org.mockito.Mock;
+import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.auth.locate.facade.LocateFacade;
+import org.onap.aaf.cadi.aaf.v2_0.AAFAuthn;
+import org.onap.aaf.cadi.principal.BasicPrincipal;
+import org.onap.aaf.cadi.principal.X509Principal;
+import org.onap.aaf.misc.env.LogTarget;
+
+public class JU_BasicAuthCodeTest {
+
+ @Mock
+ AAFAuthn authn;
+
+ @Mock(answer = Answers.RETURNS_DEEP_STUBS)
+ AuthzTrans trans;
+
+ @Mock
+ HttpServletRequest req;
+
+ @Mock
+ HttpServletResponse resp;
+
+ @Mock
+ LogTarget error;
+
+ @Mock
+ LocateFacade facade;
+
+ @Mock
+ BasicPrincipal basicPrincipal;
+ @Mock
+ X509Principal x509Principal;
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void testWithNullUserPrincipal() throws Exception {
+ BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);
+ LocateCode locateCode = basicAuthCode.clone(facade, false);
+
+ assertEquals(locateCode.desc(), basicAuthCode.desc());
+
+ when(trans.getUserPrincipal()).thenReturn(null);
+ when(trans.error()).thenReturn(error);
+
+ basicAuthCode.handle(trans, req, resp);
+ }
+
+ @Test
+ public void testWithBasicUserPrincipal() throws Exception {
+ BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);
+ LocateCode locateCode = basicAuthCode.clone(facade, false);
+
+ assertEquals(locateCode.desc(), basicAuthCode.desc());
+
+ when(trans.getUserPrincipal()).thenReturn(basicPrincipal);
+
+ basicAuthCode.handle(trans, req, resp);
+
+ verify(resp).setStatus(HttpStatus.OK_200);
+ }
+
+ @Test
+ public void testWithX509UserPrincipal() throws Exception {
+ BasicAuthCode basicAuthCode = new BasicAuthCode(authn, facade);
+ LocateCode locateCode = basicAuthCode.clone(facade, false);
+
+ assertEquals(locateCode.desc(), basicAuthCode.desc());
+
+ when(trans.getUserPrincipal()).thenReturn(x509Principal);
+ when(req.getHeader("Authorization")).thenReturn("Basic 76//76");
+
+ basicAuthCode.handle(trans, req, resp);
+
+ verify(resp).setStatus(HttpStatus.FORBIDDEN_403);
+ }
+
+}
diff --git a/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java new file mode 100644 index 00000000..93b39b2d --- /dev/null +++ b/auth/auth-locate/src/test/java/org/onap/aaf/auth/locate/mapper/JU_Mapper_1_0Test.java @@ -0,0 +1,65 @@ +/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.auth.locate.mapper;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aaf.auth.locate.mapper.Mapper.API;
+
+import locate.v1_0.Endpoints;
+import locate.v1_0.MgmtEndpoints;
+import locate_local.v1_0.Error;
+import locate_local.v1_0.InRequest;
+import locate_local.v1_0.Out;
+
+public class JU_Mapper_1_0Test {
+
+ @Before
+ public void setUp() throws Exception {
+
+ }
+
+ @Test
+ public void testGetClasses() {
+ Mapper_1_0 mapper = new Mapper_1_0();
+ assertEquals(InRequest.class, mapper.getClass(API.IN_REQ));
+ assertEquals(Out.class, mapper.getClass(API.OUT));
+ assertEquals(Error.class, mapper.getClass(API.ERROR));
+ assertEquals(Void.class, mapper.getClass(API.VOID));
+ assertEquals(Endpoints.class, mapper.getClass(API.ENDPOINTS));
+ assertEquals(MgmtEndpoints.class, mapper.getClass(API.MGMT_ENDPOINTS));
+ }
+
+ @Test
+ public void testNewInstance() {
+ Mapper_1_0 mapper = new Mapper_1_0();
+ assertTrue(mapper.newInstance(API.IN_REQ) instanceof InRequest);
+ assertTrue(mapper.newInstance(API.OUT) instanceof Out);
+ assertTrue(mapper.newInstance(API.ERROR) instanceof Error);
+ assertTrue(mapper.newInstance(API.ENDPOINTS) instanceof Endpoints);
+ assertTrue(mapper.newInstance(API.MGMT_ENDPOINTS) instanceof MgmtEndpoints);
+ assertEquals(null, mapper.newInstance(API.VOID));
+ }
+
+}
diff --git a/auth/sample/data/identities.dat b/auth/sample/data/identities.dat index 3c40e500..358829ef 100644 --- a/auth/sample/data/identities.dat +++ b/auth/sample/data/identities.dat @@ -1,5 +1,5 @@ # -# Identities.dat +# Sample Identities.dat # This file is for use with the "Default Organization". It is a simple mechanism to have a basic ILM structure to use with # out-of-the-box tire-kicking, or even for Small companies # @@ -16,36 +16,21 @@ # 5 - official email # 6 - employment status e=employee, c=contractor, a=application, n=no longer with company # 7 - responsible to (i.e Supervisor for People, or AppOwner, if it's an App ID) -jonathan|Jonathan C Gathman|Jonathan|Gathman|314-550-3312|jonathan.gathman@att.com|e| -clefevre|Catherine LeFevre|Catherine|LeFevre||catherine.lefevre@att.com|e| -ramkoya|Ram Koya|Ram|Koya||ram.koya@att.com|e|clefevre -chris|Chris Varner|Chris|Varner|469-375-0774|chris.varner@att.com|c|anne -ian|Ian Howell|Ian|Howell|314-450-2782|ian.howell@att.com|e|jonathan -gabe|Gabe B Maurer|Gabe|Maurer|314-962-9579|gabe.maurer@att.com|e|jonathan -sai|Sai Gandham|Sai|Gandham|424-265-9959|sai.gandham@att.com|c|anne -anne|Anne E Kopp|Anne|Kopp|512-244-4280|anne.e.kopp@att.com|e|jonathan -aaf|AAF App|AAF|Application||DL-aaf-support@att.com|a|jonathan -a2345z|AAF App|AAF|Application||DL-aaf-support@att.com|a|jonathan -aaf_authz|AAF App|AAF|Application||jonathan.gathman@att.com|a|jonathan -kirank|Kiran K Kamineni|Kiran|Kamineni|999-999=9999|kiran.k.kamineni@intel.com|e|ramkoya -aaf_sms|Secret Management Service|SMS|Secret Management Service provides secure storage for sensitive information such as passwords and userIDs||kiran.k.kamineni@intel.com|a|kirank -djtimoney|Dan Timoney|Dan|Timoney|+1 (732) 420-3226|dt5972@att.com|e|ramkoya -xuegao|Xue Gao|Xue|Gao|0032479670327|xg353y@att.com|e|clefevre -clamp|Clamp Application|clamp|Application||xg353y@att.com|a|xuegao -dmaapbc|DMaap Bus Controller|DMaap|Bus Controller||dgl@research.att.com|a|dgfromatt -dglfromatt|Dominic Lunanuova|Dominic|Lunanuova|732-420-9618|dgl@research.att.com|e|ramokoya -puthenpura|Sarat Puthenpura|Sarat|Puthenpura|||e|clefevre -ruoyu|Ruoyu Ying|Ruoyu|Ying|13661960772|ruoyu.ying@intel.com|e|puthenpura -sunilu|Sunil Unnava|Sunil|Unnava|6094541858|sunil.unnava@att.com|e|ramkoya -dmaapmr|DMaap Message Router|DMaap MR|Message Router||su622b@att.com|a|sunilu -oof|OOF|OOF|OOF||sarat@research.att.com|a|saratp -saratp|Sarat Puthenpura|Sarat|Puthenpura|9089012067|sarat@research.att.com|e|clefevre +# + +iowna|Ima D. Owner|Ima|Owner|314-123-2000|ima.d.owner@osaaf.com|e| +mmanager|Mark D. Manager|Mark|Manager|314-123-1234|mark.d.manager@osaaf.com|e|iowna +bdevl|Robert D. Developer|Bob|Developer|314-123-1235|bob.d.develper@osaaf.com|e|mmanager +mmarket|Mary D. Marketer|Mary|Marketer|314-123-1236|mary.d.marketer@osaaf.com|e|mmanager +ccontra|Clarice D. Contractor|Clarice|Contractor|314-123-1237|clarice.d.contractor@osaaf.com|c|mmanager +iretired|Ira Lee M. Retired|Ira|Retired|314-123-1238|clarice.d.contractor@osaaf.com|n|mmanager +osaaf|ID of AAF|||||a|bdevl # ONAP default Users -demo|PORTAL DEMO|PORTAL|DEMO|||e|jonathan -jh0003|PORTAL ADMIN|PORTAL|ADMIN|||e|jonathan -cs0008|PORTAL DESIGNER|PORTAL|DESIGNER|||e|jonathan -jm0007|PORTAL TESTER|PORTAL|TESTER|||e|jonathan -op0001|PORTAL OPS|PORTAL|OPS|||e|jonathan -gv0001|PORTAL GOVERNOR|PORTAL|GOVERNOR|||e|jonathan +demo|PORTAL DEMO|PORTAL|DEMO|||e|mmanager +jh0003|PORTAL ADMIN|PORTAL|ADMIN|||e|mmanager +cs0008|PORTAL DESIGNER|PORTAL|DESIGNER|||e|mmanager +jm0007|PORTAL TESTER|PORTAL|TESTER|||e|mmanager +op0001|PORTAL OPS|PORTAL|OPS|||e|mmanager +gv0001|PORTAL GOVERNOR|PORTAL|GOVERNOR|||e|mmanager diff --git a/auth/sample/data/sample.identities.dat b/auth/sample/data/sample.identities.dat index 39d18a12..358829ef 100644 --- a/auth/sample/data/sample.identities.dat +++ b/auth/sample/data/sample.identities.dat @@ -25,3 +25,12 @@ mmarket|Mary D. Marketer|Mary|Marketer|314-123-1236|mary.d.marketer@osaaf.com|e| ccontra|Clarice D. Contractor|Clarice|Contractor|314-123-1237|clarice.d.contractor@osaaf.com|c|mmanager iretired|Ira Lee M. Retired|Ira|Retired|314-123-1238|clarice.d.contractor@osaaf.com|n|mmanager osaaf|ID of AAF|||||a|bdevl +# ONAP default Users +demo|PORTAL DEMO|PORTAL|DEMO|||e|mmanager +jh0003|PORTAL ADMIN|PORTAL|ADMIN|||e|mmanager +cs0008|PORTAL DESIGNER|PORTAL|DESIGNER|||e|mmanager +jm0007|PORTAL TESTER|PORTAL|TESTER|||e|mmanager +op0001|PORTAL OPS|PORTAL|OPS|||e|mmanager +gv0001|PORTAL GOVERNOR|PORTAL|GOVERNOR|||e|mmanager + + diff --git a/cadi/core/src/test/resources/output_key b/cadi/core/src/test/resources/output_key new file mode 100644 index 00000000..9d94dcbd --- /dev/null +++ b/cadi/core/src/test/resources/output_key @@ -0,0 +1 @@ +QRSTUVWXYZabcdef
\ No newline at end of file diff --git a/cadi/core/test/output_key b/cadi/core/test/output_key new file mode 100644 index 00000000..353fabd2 --- /dev/null +++ b/cadi/core/test/output_key @@ -0,0 +1,27 @@ +g6wDq10CsnMUE0HB18N2UsrFri27TBG05Z1JzrvNSPUhIphFcv7gst-eHKvfbgffKF-rs9Zkjd5F +3FZDci9MlG4vhwrXHXLgo6DXEVH4FsfT5MP__E3yrnuGOcDI4kWUFdni3xG48PXNcT_xQoPb6JRO +dI3PiRRhgpvxuIL8O6iptFRoEilywvb8ySRFJA1XkRxCq-btzSpAHdMkBF-YnwMQYASveKXUddgo +Ab6Rvn6u8cDVWTIvmlEQe2el6dcKOOeMc5Ipc0AXsTLpGmhMVySEeyzKysHk0c1BiGxTulqZQcHP +L9uDFMxqL_GBwQOM4Xfu5wD_Dh1zNoKIpPta1AORjqlaUFOEsVWIn5oOKnimz4aNOjUku7tj3OKi +c-AsphXLIpmodQD4uZBynwhIjuNcJ3-SRZ3_SHnXqvf8gE-4jab2baMEX_QJ2GXumcOdZujDp8yz +3hCBlsToWXD-IatJ9dv_1gSn2_VOcXIhaNwe4YomaBVsQ4QqOkFWP9ZH3IfHrcCWZGt_HKg87NrJ +PASZ9yzlBLBTI7XFOg4rqU7l-b6-LpTLm36c0f5ImPzr-kHpE--y0cuTfdI4CEv3dJMGysKOfXax +N4tgR5t7ArQdFhLyo5mH-L5l973yuqJGVeRlTsYBYsHEb5vtIZxrYlebU9SSMmL9J-xI-hQV5tV7 +VR2C_zIKGL2nAq-tfVaiD1-M-SZW0S5VNmM-zXVxPT7jalCdHl6Dca47MhwQBVv_fxB5Nsahf10X +MT58fLLi7C2aCIAPqFyu0e3B_yuAnhDzdkS_TmtX9ke25BSZe8Ql0lni9USKxwykfoRpt7UtdAId +l8XxAgksLoDwxpL_EGz4I0jQN-4ziCVHpZNQmX08XUQ7Gx_xMtrIi21QRUhF04ZxLxlwTXj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