/** * 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); }
/** * 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); }
/** * 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); }
/** * 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. 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); }
/** * 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); }