From 6d469611d86642bc0b74ce51af72cc36d2af962d Mon Sep 17 00:00:00 2001 From: Instrumental Date: Mon, 26 Mar 2018 12:04:27 -0700 Subject: Remove Code from cadi, it is now in authz Issue-ID: AAF-193 Change-Id: Ib7abdb15ba8a7445a3875cf8c6bb48b7d563f424 Signed-off-by: Instrumental --- .../java/org/onap/aaf/cadi/JU_CadiWrapTest.java | 197 --------------------- 1 file changed, 197 deletions(-) delete mode 100644 core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java (limited to 'core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java') diff --git a/core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java b/core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java deleted file mode 100644 index da81e0c..0000000 --- a/core/src/test/java/org/onap/aaf/cadi/JU_CadiWrapTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************* - * ============LICENSE_START==================================================== - * * org.onap.aaf - * * =========================================================================== - * * Copyright © 2017 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==================================================== - * * - * * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * * - ******************************************************************************/ -package org.onap.aaf.cadi; - -import static org.junit.Assert.*; - -import org.junit.Test; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.isA; -import static org.mockito.Mockito.when; - -import java.security.Principal; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.MockitoAnnotations; -import org.onap.aaf.cadi.CachedPrincipal.Resp; -import org.onap.aaf.cadi.filter.MapPermConverter; -import org.onap.aaf.cadi.lur.EpiLur; -import org.onap.aaf.cadi.taf.TafResp; - -public class JU_CadiWrapTest { - - @Mock - private HttpServletRequest request; - - @Mock - private TafResp tafResp; - - @Mock - private Principal principle; - - @Mock - private Lur lur; - - @Before - public void setUp() throws Exception { - MockitoAnnotations.initMocks(this); - } - - @Test - public void testInstantiate() throws CadiException { - Access a = new PropAccess(); - when(tafResp.getAccess()).thenReturn(a); - - lur.fishAll(isA(Principal.class), isA(List.class)); - - EpiLur lur1 = new EpiLur(lur); - - CadiWrap wrap = new CadiWrap(request, tafResp, lur1); - - assertNull(wrap.getUserPrincipal()); - assertNull(wrap.getRemoteUser()); - assertNull(wrap.getUser()); - assertEquals(wrap.getPermissions(principle).size(), 0); - - byte[] arr = {'1','2'}; - wrap.setCred(arr); - - assertEquals(arr, wrap.getCred()); - - wrap.setUser("User1"); - assertEquals("User1", wrap.getUser()); - - wrap.invalidate("1"); - - assertFalse(wrap.isUserInRole(null)); - - wrap.set(tafResp, lur); - - wrap.invalidate("2"); - - wrap.isUserInRole("User1"); - } - - @Test - public void testInstantiateWithPermConverter() throws CadiException { - Access a = new PropAccess(); - when(tafResp.getAccess()).thenReturn(a); - when(tafResp.getPrincipal()).thenReturn(principle); - - - CachingLur lur1 = new CachingLur() { - - @Override - public Permission createPerm(String p) { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean fish(Principal bait, Permission pond) { - // TODO Auto-generated method stub - return true; - } - - @Override - public void fishAll(Principal bait, List permissions) { - // TODO Auto-generated method stub - - } - - @Override - public void destroy() { - // TODO Auto-generated method stub - - } - - @Override - public boolean handlesExclusively(Permission pond) { - // TODO Auto-generated method stub - return false; - } - - @Override - public boolean supports(String userName) { - // TODO Auto-generated method stub - return false; - } - - @Override - public void remove(String user) { - // TODO Auto-generated method stub - - } - - @Override - public Resp reload(User user) { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setDebug(String commaDelimIDsOrNull) { - // TODO Auto-generated method stub - - } - - @Override - public void clear(Principal p, StringBuilder sb) { - // TODO Auto-generated method stub - - } - }; - - MapPermConverter pc = new MapPermConverter(); - - CadiWrap wrap = new CadiWrap(request, tafResp, lur1, pc); - - assertNotNull(wrap.getUserPrincipal()); - assertNull(wrap.getRemoteUser()); - assertNull(wrap.getUser()); - - byte[] arr = {'1','2'}; - wrap.setCred(arr); - - assertEquals(arr, wrap.getCred()); - - wrap.setUser("User1"); - assertEquals("User1", wrap.getUser()); - - wrap.invalidate("1"); - wrap.setPermConverter(new MapPermConverter()); - - assertTrue(wrap.getLur() instanceof CachingLur); - assertTrue(wrap.isUserInRole("User1")); - - wrap.set(tafResp, lur); - assertFalse(wrap.isUserInRole("Perm1")); - } -} -- cgit 1.2.3-korg