diff options
author | Eylon Malin <eylon.malin@intl.att.com> | 2019-08-04 18:03:29 +0300 |
---|---|---|
committer | Ittay Stern <ittay.stern@att.com> | 2019-08-04 15:11:25 +0000 |
commit | c459c7efeafd556333c46c65fc4fe2616d3ef532 (patch) | |
tree | 74da52be5a3825bbea5c9c667ad3c5821af99bdd /vid-app-common/src/test/java | |
parent | e8e72260254d2399279a1497c14abafc06018037 (diff) |
Remove web-filter for incoming scheduler requests
authentication can be handled in a different way like using AAF
(see 48b0c6ee)
Issue-ID: VID-378
Signed-off-by: Eylon Malin <eylon.malin@intl.att.com>
Change-Id: I68c664bc6a20ce4d8722558e00985b7638fed04b
Diffstat (limited to 'vid-app-common/src/test/java')
-rw-r--r-- | vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java b/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java deleted file mode 100644 index 37c02b2e0..000000000 --- a/vid-app-common/src/test/java/org/onap/vid/controller/ClientCredentialsFilterTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 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.vid.controller; - - -import org.junit.Assert; -import org.mockito.Mockito; -import org.onap.vid.controller.filter.ClientCredentialsFilter; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; - -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - -import static org.mockito.ArgumentMatchers.any; - - -/** - * Created by amichai on 16/05/2018. - */ -public class ClientCredentialsFilterTest { - - @DataProvider - public static Object[][] authorizedData() { - return new Object[][] { - {"Basic 123==", null}, - {null, null}, - {null, ""}, - {"Basic 123==", ""}, - {"Basic 123==", "Basic 123=="} - }; - } - - @DataProvider - public static Object[][] notAuthorizedData() { - return new Object[][] { - {null, "Basic 123=="}, - {"", "Basic 123=="}, - {"not null but not as expected", "Basic 123=="}, - {"basic 123==", "Basic 123=="} - }; - } - - @DataProvider - public static Object[][] clientVerified() { - return new Object[][] { - {true}, - {false} - }; - } - - @Test(dataProvider = "authorizedData") - public void givenAuthorizationHeader_Authorized(String actualAuth, String expectedAuth){ - ClientCredentialsFilter filter = new ClientCredentialsFilter(); - Assert.assertTrue(filter.verifyClientCredentials(actualAuth, expectedAuth)); - } - - @Test(dataProvider = "notAuthorizedData") - public void givenAuthorizationHeader_NotAuthorized(String actualAuth, String expectedAuth){ - ClientCredentialsFilter filter = new ClientCredentialsFilter(); - Assert.assertFalse(filter.verifyClientCredentials(actualAuth, expectedAuth)); - } - - //@Test(dataProvider = "clientVerified") - public void notAuthorized_return401(Boolean clientVerified) throws IOException, ServletException { - ClientCredentialsFilter filter = Mockito.mock(ClientCredentialsFilter.class); - HttpServletResponse response = Mockito.mock(HttpServletResponse.class); - HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - FilterChain chain = Mockito.mock(FilterChain.class); - - - Mockito.when(filter.verifyClientCredentials(any(),any())).thenReturn(clientVerified); - Mockito.doNothing().when(response).sendError(401); - - Mockito.doCallRealMethod().when(filter).doFilter(request,response,chain); - filter.doFilter(request,response,chain); - - if (clientVerified) - { - Mockito.verify(chain).doFilter(request,response); - - } - else { - Mockito.verify(response).sendError(401); - } - - } - - -} |