public String apply(NottableString input) { return input.getValue(); } }));
public String apply(NottableString input) { return input.getValue(); } }));
@Override public HttpResponse handle(HttpRequest httpRequest) { if (httpRequest.getPath().getValue().endsWith("/callback")) { return httpResponse; } else { return notFoundResponse(); } } }
private String getCookieHeader(HttpRequest request) { List<Cookie> cookies = new ArrayList<Cookie>(); for (org.mockserver.model.Cookie cookie : request.getCookieList()) { cookies.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } if (cookies.size() > 0) { return " -H '" + COOKIE + ": " + ClientCookieEncoder.LAX.encode(cookies) + "'"; } else { return ""; } } }
public boolean matches(final HttpRequest context, NottableString matched) { boolean result = false; if (matches(matcher.getValue(), matched.getValue(), false)) { result = true; } if (!result) { mockServerLogger.trace(context, "Failed to match [{}] with [{}]", matched, this.matcher); } return matched.isNot() != (matcher.isNot() != (not != result)); }
public boolean matches(final HttpRequest context, NottableString matched) { boolean result = false; if (matches(matcher.getValue(), matched.getValue(), false)) { result = true; } if (!result) { mockServerLogger.trace(context, "Failed to match [{}] with [{}]", matched, this.matcher); } return matched.isNot() != (matcher.isNot() != (not != result)); }
public boolean matches(final HttpRequest context, NottableString matched) { boolean result = false; if (matches(matcher.getValue(), matched.getValue(), false)) { result = true; } if (!result) { mockServerLogger.trace(context, "Failed to match [{}] with [{}]", matched, this.matcher); } return matched.isNot() != (matcher.isNot() != (not != result)); }
@Override public void run() { KeyAndCertificateFactory.addSubjectAlternativeName(request.getPath().getValue()); } });
private void setCookies(HttpRequest httpRequest, FullHttpRequest request) { List<io.netty.handler.codec.http.cookie.Cookie> cookies = new ArrayList<io.netty.handler.codec.http.cookie.Cookie>(); for (org.mockserver.model.Cookie cookie : httpRequest.getCookieList()) { cookies.add(new io.netty.handler.codec.http.cookie.DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } if (cookies.size() > 0) { request.headers().set( COOKIE.toString(), io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(cookies) ); } }
public String getURI(HttpRequest httpRequest) { QueryStringEncoder queryStringEncoder = new QueryStringEncoder(httpRequest.getPath().getValue()); for (Parameter parameter : httpRequest.getQueryStringParameterList()) { for (NottableString value : parameter.getValues()) { queryStringEncoder.addParam(parameter.getName().getValue(), value.getValue()); } } return queryStringEncoder.toString(); }
private void setCookies(HttpResponse response, DefaultFullHttpResponse fullHttpResponse) { if (response.getCookieList() != null) { List<Cookie> cookieValues = new ArrayList<Cookie>(); for (org.mockserver.model.Cookie cookie : response.getCookieList()) { if (!cookieHeaderAlreadyExists(response, cookie)) { cookieValues.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } } for (Cookie cookieValue : cookieValues) { fullHttpResponse.headers().add(SET_COOKIE, ServerCookieEncoder.LAX.encode(cookieValue)); } } }
private boolean cookieHeaderAlreadyExists(HttpResponse response, org.mockserver.model.Cookie cookieValue) { List<String> setCookieHeaders = response.getHeader(SET_COOKIE.toString()); for (String setCookieHeader : setCookieHeaders) { String existingCookieName = ClientCookieDecoder.LAX.decode(setCookieHeader).name(); String existingCookieValue = ClientCookieDecoder.LAX.decode(setCookieHeader).value(); if (existingCookieName.equalsIgnoreCase(cookieValue.getName().getValue()) && existingCookieValue.equalsIgnoreCase(cookieValue.getValue().getValue())) { return true; } } return false; } }
private boolean cookieHeaderAlreadyExists(HttpResponse response, Cookie cookieValue) { List<String> setCookieHeaders = response.getHeader(SET_COOKIE.toString()); for (String setCookieHeader : setCookieHeaders) { String existingCookieName = ClientCookieDecoder.LAX.decode(setCookieHeader).name(); String existingCookieValue = ClientCookieDecoder.LAX.decode(setCookieHeader).value(); if (existingCookieName.equalsIgnoreCase(cookieValue.getName().getValue()) && existingCookieValue.equalsIgnoreCase(cookieValue.getValue().getValue())) { return true; } } return false; }
public NottableString normaliseXmlNottableString(final NottableString input) throws IOException, SAXException, ParserConfigurationException, TransformerException { return string(normaliseXmlString(input.getValue()), input.isNot()); }
private void setCookies(HttpResponse httpResponse, HttpServletResponse httpServletResponse) { if (httpResponse.getCookieList() != null) { for (Cookie cookie : httpResponse.getCookieList()) { if (!cookieHeaderAlreadyExists(httpResponse, cookie)) { httpServletResponse.addHeader(SET_COOKIE.toString(), ServerCookieEncoder.LAX.encode(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue()))); } } } }
public static boolean isPreflightRequest(HttpRequest request) { final Headers headers = request.getHeaders(); return request.getMethod().getValue().equals(OPTIONS.name()) && headers.containsEntry(HttpHeaderNames.ORIGIN.toString()) && headers.containsEntry(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD.toString()); }
public XmlStringMatcher(MockServerLogger mockServerLogger, final NottableString matcher) { this.mockServerLogger = mockServerLogger; try { this.matcher = normaliseXmlNottableString(matcher); this.diffBuilder = DiffBuilder.compare(Input.fromString(this.matcher.getValue())) .ignoreComments() .ignoreWhitespace() .checkForSimilar(); } catch (Exception e) { mockServerLogger.error("Error while creating xml string matcher for [" + matcher + "]" + e.getMessage(), e); } }