components/global/core/io.cellery.observability.api/src/test/java/io/cellery/observability/api/interceptor/AuthInterceptorTestCase.java
private Request mockRequest(String tokenFirstPart, String tokenSecondPart) {
        HttpHeaders httpHeaders = Mockito.mock(HttpHeaders.class);
        Map<String, Cookie> cookiesMap = new HashMap<>();
        Cookie oAuthCookie = Mockito.mock(Cookie.class);
        if (tokenSecondPart != null) {
            Mockito.when(oAuthCookie.getValue()).thenReturn(tokenSecondPart);
        }
        cookiesMap.put(Constants.HTTP_ONLY_SESSION_COOKIE, oAuthCookie);
        Mockito.when(httpHeaders.getCookies()).thenReturn(cookiesMap);

        Request request = Mockito.mock(Request.class);
        Mockito.when(request.getHttpMethod()).thenReturn(HttpMethod.GET);
        Mockito.when(request.getHeaders()).thenReturn(httpHeaders);
        if (tokenFirstPart != null) {
            Mockito.when(request.getHeader(HttpHeaders.AUTHORIZATION)).thenReturn(BEARER_PREFIX + tokenFirstPart);
        }
        return request;
    }
/**
     * Mock a request for the interceptor.
     *
     * @param tokenFirstPart The first part of the partial token
     * @param tokenSecondPart The second part of the partial token
     * @return The mocked request
     */
Mock a request for the interceptor.
@param tokenFirstPart The first part of the partial token
@param tokenSecondPart The second part of the partial token
@return The mocked request
Mock a request for the interceptor . @param tokenFirstPart The first part of the partial token @param tokenSecondPart The second part of the partial token @return The mocked request
private Request mockRequest(String tokenFirstPart, String tokenSecondPart) {
        HttpHeaders httpHeaders = Mockito.mock(HttpHeaders.class);
        Map<String, Cookie> cookiesMap = new HashMap<>();
        Cookie oAuthCookie = Mockito.mock(Cookie.class);
        if (tokenSecondPart != null) {
            Mockito.when(oAuthCookie.getValue()).thenReturn(tokenSecondPart);
        }
        cookiesMap.put(Constants.HTTP_ONLY_SESSION_COOKIE, oAuthCookie);
        Mockito.when(httpHeaders.getCookies()).thenReturn(cookiesMap);
        Request request = Mockito.mock(Request.class);
        Mockito.when(request.getHttpMethod()).thenReturn(HttpMethod.GET);
        Mockito.when(request.getHeaders()).thenReturn(httpHeaders);
        if (tokenFirstPart != null) {
            Mockito.when(request.getHeader(HttpHeaders.AUTHORIZATION)).thenReturn(BEARER_PREFIX + tokenFirstPart);
        }
        return request;
    }
private Request mockRequest ( String tokenFirstPart , String tokenSecondPart ) { HttpHeaders httpHeaders = Mockito . mock ( HttpHeaders . class ) ; Map < String , Cookie > cookiesMap = new HashMap < > ( ) ; Cookie oAuthCookie = Mockito . mock ( Cookie . class ) ; if ( tokenSecondPart != null ) { Mockito . when ( oAuthCookie . getValue ( ) ) . thenReturn ( tokenSecondPart ) ; } cookiesMap . put ( Constants . HTTP_ONLY_SESSION_COOKIE , oAuthCookie ) ; Mockito . when ( httpHeaders . getCookies ( ) ) . thenReturn ( cookiesMap ) ; Request request = Mockito . mock ( Request . class ) ; Mockito . when ( request . getHttpMethod ( ) ) . thenReturn ( HttpMethod . GET ) ; Mockito . when ( request . getHeaders ( ) ) . thenReturn ( httpHeaders ) ; if ( tokenFirstPart != null ) { Mockito . when ( request . getHeader ( HttpHeaders . AUTHORIZATION ) ) . thenReturn ( BEARER_PREFIX + tokenFirstPart ) ; } return request ; }
Mock a request for the interceptor.
Mock a request for the interceptor .