/** * Specify the hostname for of the proxy. Will use port {@value #DEFAULT_PORT} and scheme {@value #DEFAULT_SCHEME}. * * @param host The hostname * @return A new ProxySpecification instance */ public static ProxySpecification host(String host) { return new ProxySpecification(host, DEFAULT_PORT, DEFAULT_SCHEME, DEFAULT_USERNAME, DEFAULT_PASSWORD); }
/** * Creates a new proxy selector route planner. * * @param schemeRegistry the scheme registry * @param proxySelector the proxy selector */ public RestAssuredProxySelectorRoutePlanner(SchemeRegistry schemeRegistry, ProxySelector proxySelector, ProxySpecification proxySpecification) { super(schemeRegistry, proxySelector); this.scheme = proxySpecification == null ? null : proxySpecification.getScheme(); }
/** * Instruct REST Assured to connect to a proxy on the specified host and port. * * @param host The hostname of the proxy to connect to (for example <code>127.0.0.1</code>) * @param port The port of the proxy to connect to (for example <code>8888</code>) */ public static void proxy(String host, int port) { proxy(host(host).withPort(port)); }
/** * Instruct REST Assured to connect to a proxy on the specified port on localhost. * * @param port The port of the proxy to connect to (for example <code>8888</code>) * @see #proxy(String, int) */ public static void proxy(int port) { proxy(ProxySpecification.port(port)); }
private static void addProxy(FilterableRequestSpecification requestSpec, StringBuilder builder) { builder.append("Proxy:"); ProxySpecification proxySpec = requestSpec.getProxySpecification(); appendThreeTabs(builder); if (proxySpec == null) { builder.append(NONE); } else { builder.append(proxySpec.toString()); } builder.append(NEW_LINE); }
/** * Instruct REST Assured to connect to a proxy on the specified host on port <code>8888</code>. * * @param host The hostname of the proxy to connect to (for example <code>127.0.0.1</code>). Can also be a URI represented as a String. * @see #proxy(String, int) */ public static void proxy(String host) { if (UriValidator.isUri(host)) { try { proxy(new URI(host)); } catch (URISyntaxException e) { throw new RuntimeException("Internal error in REST Assured when constructing URI for Proxy.", e); } } else { proxy(host(host)); } }
/** * Specify the scheme of the proxy. * * @param scheme The scheme of the proxy. * @return A new ProxySpecification instance */ public ProxySpecification withScheme(String scheme) { return new ProxySpecification(host, port, scheme); }
/** * Specify the port of the proxy. Will use hostname {@value #DEFAULT_HOST} and scheme {@value #DEFAULT_SCHEME}. * * @param port The port on localhost to connect to. * @return A new ProxySpecification instance */ public static ProxySpecification port(int port) { return new ProxySpecification(DEFAULT_HOST, port, DEFAULT_SCHEME, DEFAULT_USERNAME, DEFAULT_PASSWORD); }
/** * Specify the port of the proxy. * * @param port The port of the proxy. * @return A new ProxySpecification instance */ public ProxySpecification withPort(int port) { return new ProxySpecification(host, port, scheme, username, password); }
/** * Specify the hostname of the proxy. * * @param host The hostname of the proxy. * @return A new ProxySpecification instance */ public ProxySpecification withHost(String host) { return new ProxySpecification(host, port, scheme, username, password); }
/** * Instruct REST Assured to connect to a proxy on the specified port on localhost with a specific scheme. * * @param host The hostname of the proxy to connect to (for example <code>127.0.0.1</code>) * @param port The port of the proxy to connect to (for example <code>8888</code>) * @param scheme The http scheme (http or https) */ public static void proxy(String host, int port, String scheme) { proxy(new ProxySpecification(host, port, scheme)); }
/** * Instruct REST Assured to connect to a proxy using a URI. * * @param uri The URI of the proxy */ public static void proxy(URI uri) { if (uri == null) { throw new IllegalArgumentException("Proxy URI cannot be null"); } proxy(new ProxySpecification(uri.getHost(), uri.getPort(), uri.getScheme())); }
/** * Specify (preemptive) basic authentication for the proxy * * @param username The username * @param password The username * @return A new ProxySpecification instance */ public ProxySpecification withAuth(String username, String password) { notNull(username, "username"); notNull(password, "password"); return new ProxySpecification(host, port, scheme, username, password); }
/** * Specify preemptive basic authentication for the proxy. Will use hostname {@value #DEFAULT_HOST}, port {@value #DEFAULT_PORT} and scheme {@value #DEFAULT_SCHEME}. * * @param username The username * @param password The username * @return A new ProxySpecification instance */ public static ProxySpecification auth(String username, String password) { notNull(username, "username"); notNull(password, "password"); return new ProxySpecification(DEFAULT_HOST, DEFAULT_PORT, DEFAULT_SCHEME, username, password); }