diff options
Diffstat (limited to 'auth')
4 files changed, 205 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 + + |