2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property
6 * ================================================================================
7 * Modifications Copyright (C) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ================================================================================
23 package org.onap.portalapp.filter;
25 import static org.junit.Assert.assertEquals;
26 import static org.junit.Assert.assertNotNull;
27 import java.io.IOException;
28 import javax.servlet.FilterChain;
29 import javax.servlet.ServletException;
30 import javax.servlet.http.HttpServletResponse;
31 import org.junit.Test;
32 import org.mockito.Mockito;
33 import com.mockrunner.mock.web.MockHttpServletRequest;
34 import com.mockrunner.mock.web.MockHttpServletResponse;
36 public class SecurityXssFilterTest {
38 public void testGets() throws ServletException, IOException {
39 SecurityXssFilter filter = new SecurityXssFilter();
40 assertNotNull(filter);
42 MockHttpServletRequest request = new MockHttpServletRequest();
43 request.setMethod("POST");
44 request.setBodyContent("testBody");
45 request.setupAddParameter("testKey", "testVal");
46 request.setAttribute("testKey", "testVal");
47 request.setRequestURI("testVal");
48 request.setRequestURL("testVal");
49 MockHttpServletResponse response = new MockHttpServletResponse();
50 FilterChain filterChain = Mockito.mock(FilterChain.class);
51 filter.doFilterInternal(request, response, filterChain);
52 assertEquals(response.getStatusCode(), HttpServletResponse.SC_OK);