summaryrefslogtreecommitdiffstats
path: root/src/test/org/onap/sdc/dcae/controller/proxy/DcaeProxyTest.java
blob: 13b9c780fc0276135cae67e230001def9a97a6a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package org.onap.sdc.dcae.controller.proxy;

import org.junit.Test;
import org.mockito.Mockito;

import javax.servlet.http.HttpServletRequest;

import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;


//TODO headers and cookies test (API)
public class DcaeProxyTest {

    private static final String BEHOST = "https://host.xxx.yyy:8443";
    private DcaeProxy proxy = new DcaeProxy(BEHOST);
    private final static HttpServletRequest servletRequest = Mockito.mock(HttpServletRequest.class);


    @Test
    public void testRewriteUrlWithQueryParams(){
        String requestUrl = "/dcaed/dcaeProxy/someBeApi?%20x=1&y=2";
        String expectedUrl = BEHOST + "/dcaed/someBeApi?%20x=1&y=2";
        when(servletRequest.getRequestURI()).thenReturn(requestUrl);
        String target = proxy.rewriteTarget(servletRequest);
        assertTrue(target.equals(expectedUrl));
    }

}