mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 15:33:11 +01:00
proxy settings
This commit is contained in:
parent
97a300fbfc
commit
470e9d0442
28
package-lock.json
generated
28
package-lock.json
generated
@ -2418,11 +2418,6 @@
|
|||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@coolaj86/urequest": {
|
|
||||||
"version": "1.3.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@coolaj86/urequest/-/urequest-1.3.7.tgz",
|
|
||||||
"integrity": "sha512-PPrVYra9aWvZjSCKl/x1pJ9ZpXda1652oJrPBYy5rQumJJMkmTBN3ux+sK2xAUwVvv2wnewDlaQaHLxLwSHnIA=="
|
|
||||||
},
|
|
||||||
"node_modules/@develar/schema-utils": {
|
"node_modules/@develar/schema-utils": {
|
||||||
"version": "2.6.5",
|
"version": "2.6.5",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -14796,14 +14791,6 @@
|
|||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ssl-root-cas": {
|
|
||||||
"version": "1.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/ssl-root-cas/-/ssl-root-cas-1.3.1.tgz",
|
|
||||||
"integrity": "sha512-KR8J210Wfvjh+iNE9jcQEgbG0VG2713PHreItx6aNCPnkFO8XChz1cJ4iuCGeBj0+8wukLmgHgJqX+O5kRjPkQ==",
|
|
||||||
"dependencies": {
|
|
||||||
"@coolaj86/urequest": "^1.3.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/stable": {
|
"node_modules/stable": {
|
||||||
"version": "0.1.8",
|
"version": "0.1.8",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -16761,7 +16748,6 @@
|
|||||||
"node-machine-id": "^1.1.12",
|
"node-machine-id": "^1.1.12",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"socks-proxy-agent": "^8.0.2",
|
"socks-proxy-agent": "^8.0.2",
|
||||||
"ssl-root-cas": "^1.3.1",
|
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"vm2": "^3.9.13",
|
"vm2": "^3.9.13",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
@ -18765,11 +18751,6 @@
|
|||||||
"version": "0.2.3",
|
"version": "0.2.3",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@coolaj86/urequest": {
|
|
||||||
"version": "1.3.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@coolaj86/urequest/-/urequest-1.3.7.tgz",
|
|
||||||
"integrity": "sha512-PPrVYra9aWvZjSCKl/x1pJ9ZpXda1652oJrPBYy5rQumJJMkmTBN3ux+sK2xAUwVvv2wnewDlaQaHLxLwSHnIA=="
|
|
||||||
},
|
|
||||||
"@develar/schema-utils": {
|
"@develar/schema-utils": {
|
||||||
"version": "2.6.5",
|
"version": "2.6.5",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
@ -21658,7 +21639,6 @@
|
|||||||
"node-machine-id": "^1.1.12",
|
"node-machine-id": "^1.1.12",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"socks-proxy-agent": "^8.0.2",
|
"socks-proxy-agent": "^8.0.2",
|
||||||
"ssl-root-cas": "^1.3.1",
|
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"vm2": "^3.9.13",
|
"vm2": "^3.9.13",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
@ -27279,14 +27259,6 @@
|
|||||||
"tweetnacl": "~0.14.0"
|
"tweetnacl": "~0.14.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ssl-root-cas": {
|
|
||||||
"version": "1.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/ssl-root-cas/-/ssl-root-cas-1.3.1.tgz",
|
|
||||||
"integrity": "sha512-KR8J210Wfvjh+iNE9jcQEgbG0VG2713PHreItx6aNCPnkFO8XChz1cJ4iuCGeBj0+8wukLmgHgJqX+O5kRjPkQ==",
|
|
||||||
"requires": {
|
|
||||||
"@coolaj86/urequest": "^1.3.6"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"stable": {
|
"stable": {
|
||||||
"version": "0.1.8",
|
"version": "0.1.8",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'github-markdown-css/github-markdown.css';
|
import 'github-markdown-css/github-markdown.css';
|
||||||
import get from 'lodash/get';
|
import get from 'lodash/get';
|
||||||
import { updateCollectionDocs } from 'providers/ReduxStore/slices/collections';
|
import { updateCollectionDocs } from 'providers/ReduxStore/slices/collections';
|
||||||
import { useTheme } from 'providers/Theme/index';
|
import { useTheme } from 'providers/Theme';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useDispatch } from 'react-redux';
|
||||||
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions';
|
import { saveCollectionRoot } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
|
@ -1,10 +1,52 @@
|
|||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useFormik } from 'formik';
|
import { useFormik } from 'formik';
|
||||||
import * as Yup from 'yup';
|
|
||||||
|
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
import * as Yup from 'yup';
|
||||||
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
const ProxySettings = ({ proxyConfig, onUpdate }) => {
|
const ProxySettings = ({ proxyConfig, onUpdate }) => {
|
||||||
|
const proxySchema = Yup.object({
|
||||||
|
enabled: Yup.string().oneOf(['global', 'enabled', 'disabled']),
|
||||||
|
protocol: Yup.string().oneOf(['http', 'https', 'socks4', 'socks5']),
|
||||||
|
hostname: Yup.string()
|
||||||
|
.when('enabled', {
|
||||||
|
is: 'enabled',
|
||||||
|
then: (hostname) => hostname.required('Specify the hostname for your proxy.'),
|
||||||
|
otherwise: (hostname) => hostname.nullable()
|
||||||
|
})
|
||||||
|
.max(1024),
|
||||||
|
port: Yup.number()
|
||||||
|
.when('enabled', {
|
||||||
|
is: 'enabled',
|
||||||
|
then: (port) => port.typeError('Specify port between 1 and 65535'),
|
||||||
|
otherwise: (port) => port.nullable().transform((_, val) => (val ? Number(val) : null))
|
||||||
|
})
|
||||||
|
.min(1)
|
||||||
|
.max(65535),
|
||||||
|
auth: Yup.object()
|
||||||
|
.when('enabled', {
|
||||||
|
is: 'enabled',
|
||||||
|
then: Yup.object({
|
||||||
|
enabled: Yup.boolean(),
|
||||||
|
username: Yup.string()
|
||||||
|
.when(['enabled'], {
|
||||||
|
is: true,
|
||||||
|
then: (username) => username.required('Specify username for proxy authentication.')
|
||||||
|
})
|
||||||
|
.max(1024),
|
||||||
|
password: Yup.string()
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (password) => password.required('Specify password for proxy authentication.')
|
||||||
|
})
|
||||||
|
.max(1024)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
noProxy: Yup.string().optional().max(1024)
|
||||||
|
});
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
enabled: proxyConfig.enabled || 'global',
|
enabled: proxyConfig.enabled || 'global',
|
||||||
@ -18,20 +60,17 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
|
|||||||
},
|
},
|
||||||
noProxy: proxyConfig.noProxy || ''
|
noProxy: proxyConfig.noProxy || ''
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: proxySchema,
|
||||||
enabled: Yup.string().oneOf(['global', 'enabled', 'disabled']),
|
|
||||||
protocol: Yup.string().oneOf(['http', 'https', 'socks5']),
|
|
||||||
hostname: Yup.string().max(1024),
|
|
||||||
port: Yup.number().min(0).max(65535),
|
|
||||||
auth: Yup.object({
|
|
||||||
enabled: Yup.boolean(),
|
|
||||||
username: Yup.string().max(1024),
|
|
||||||
password: Yup.string().max(1024)
|
|
||||||
}),
|
|
||||||
noProxy: Yup.string().max(1024)
|
|
||||||
}),
|
|
||||||
onSubmit: (values) => {
|
onSubmit: (values) => {
|
||||||
onUpdate(values);
|
proxySchema
|
||||||
|
.validate(values, { abortEarly: true })
|
||||||
|
.then((validatedProxy) => {
|
||||||
|
onUpdate(validatedProxy);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
let errMsg = error.message || 'Preferences validation error';
|
||||||
|
toast.error(errMsg);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -55,15 +94,15 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
|
|||||||
<h1 className="font-medium mb-3">Proxy Settings</h1>
|
<h1 className="font-medium mb-3">Proxy Settings</h1>
|
||||||
<label className="settings-label">
|
<label className="settings-label">
|
||||||
<ul className="mb-3">
|
<ul className="mb-3">
|
||||||
<li>To use the global proxy configuration, choose 'use global setting'</li>
|
<li>global - use global config</li>
|
||||||
<li>To use collection level configuration, choose 'enabled'</li>
|
<li>enabled - use collection config</li>
|
||||||
<li>To disable the proxy for this collection, choose 'disabled'</li>
|
<li>disable - disable proxy</li>
|
||||||
</ul>
|
</ul>
|
||||||
</label>
|
</label>
|
||||||
<form className="bruno-form" onSubmit={formik.handleSubmit}>
|
<form className="bruno-form" onSubmit={formik.handleSubmit}>
|
||||||
<div className="mb-3 flex items-center">
|
<div className="mb-3 flex items-center">
|
||||||
<label className="settings-label" htmlFor="enabled">
|
<label className="settings-label" htmlFor="enabled">
|
||||||
Usage
|
Config
|
||||||
</label>
|
</label>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<label className="flex items-center">
|
<label className="flex items-center">
|
||||||
@ -75,7 +114,7 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
|
|||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
className="mr-1"
|
className="mr-1"
|
||||||
/>
|
/>
|
||||||
use global settings
|
global
|
||||||
</label>
|
</label>
|
||||||
<label className="flex items-center ml-4">
|
<label className="flex items-center ml-4">
|
||||||
<input
|
<input
|
||||||
@ -128,6 +167,17 @@ const ProxySettings = ({ proxyConfig, onUpdate }) => {
|
|||||||
/>
|
/>
|
||||||
https
|
https
|
||||||
</label>
|
</label>
|
||||||
|
<label className="flex items-center ml-4">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="protocol"
|
||||||
|
value="socks5"
|
||||||
|
checked={formik.values.protocol === 'socks4'}
|
||||||
|
onChange={formik.handleChange}
|
||||||
|
className="mr-1"
|
||||||
|
/>
|
||||||
|
socks4
|
||||||
|
</label>
|
||||||
<label className="flex items-center ml-4">
|
<label className="flex items-center ml-4">
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
|
@ -24,7 +24,7 @@ const ProxySettings = () => {
|
|||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
enabled: Yup.boolean(),
|
enabled: Yup.boolean(),
|
||||||
protocol: Yup.string().oneOf(['http', 'https', 'socks5']),
|
protocol: Yup.string().oneOf(['http', 'https', 'socks4', 'socks5']),
|
||||||
hostname: Yup.string().max(1024),
|
hostname: Yup.string().max(1024),
|
||||||
port: Yup.number().min(0).max(65535),
|
port: Yup.number().min(0).max(65535),
|
||||||
auth: Yup.object({
|
auth: Yup.object({
|
||||||
@ -106,6 +106,17 @@ const ProxySettings = () => {
|
|||||||
/>
|
/>
|
||||||
https
|
https
|
||||||
</label>
|
</label>
|
||||||
|
<label className="flex items-center ml-4">
|
||||||
|
<input
|
||||||
|
type="radio"
|
||||||
|
name="protocol"
|
||||||
|
value="socks5"
|
||||||
|
checked={formik.values.protocol === 'socks4'}
|
||||||
|
onChange={formik.handleChange}
|
||||||
|
className="mr-1"
|
||||||
|
/>
|
||||||
|
socks4
|
||||||
|
</label>
|
||||||
<label className="flex items-center ml-4">
|
<label className="flex items-center ml-4">
|
||||||
<input
|
<input
|
||||||
type="radio"
|
type="radio"
|
||||||
|
@ -12,23 +12,54 @@ import * as Yup from 'yup';
|
|||||||
import useLocalStorage from 'hooks/useLocalStorage/index';
|
import useLocalStorage from 'hooks/useLocalStorage/index';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
|
|
||||||
|
const requestSchema = Yup.object({
|
||||||
|
sslVerification: Yup.boolean(),
|
||||||
|
caCert: Yup.string().max(1024)
|
||||||
|
});
|
||||||
|
const proxySchema = Yup.object({
|
||||||
|
enabled: Yup.boolean(),
|
||||||
|
protocol: Yup.string().oneOf(['http', 'https', 'socks5']),
|
||||||
|
hostname: Yup.string()
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (hostname) => hostname.required('Specify the hostname for your proxy.'),
|
||||||
|
otherwise: (hostname) => hostname.nullable()
|
||||||
|
})
|
||||||
|
.max(1024),
|
||||||
|
port: Yup.number()
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (port) => port.typeError('Specify port between 1 and 65535'),
|
||||||
|
otherwise: (port) => port.nullable().transform((_, val) => (val ? Number(val) : null))
|
||||||
|
})
|
||||||
|
.min(1)
|
||||||
|
.max(65535),
|
||||||
|
auth: Yup.object()
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: Yup.object({
|
||||||
|
enabled: Yup.boolean(),
|
||||||
|
username: Yup.string()
|
||||||
|
.when(['enabled'], {
|
||||||
|
is: true,
|
||||||
|
then: (username) => username.required('Specify username for proxy authentication.')
|
||||||
|
})
|
||||||
|
.max(1024),
|
||||||
|
password: Yup.string()
|
||||||
|
.when('enabled', {
|
||||||
|
is: true,
|
||||||
|
then: (password) => password.required('Specify password for proxy authentication.')
|
||||||
|
})
|
||||||
|
.max(1024)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
noProxy: Yup.string().optional().max(1024)
|
||||||
|
});
|
||||||
|
|
||||||
const preferencesSchema = Yup.object({
|
const preferencesSchema = Yup.object({
|
||||||
request: Yup.object({
|
request: requestSchema,
|
||||||
sslVerification: Yup.boolean(),
|
proxy: proxySchema
|
||||||
caCert: Yup.string().max(1024)
|
|
||||||
}),
|
|
||||||
proxy: Yup.object({
|
|
||||||
enabled: Yup.boolean(),
|
|
||||||
protocol: Yup.string().oneOf(['http', 'https', 'socks5']),
|
|
||||||
hostname: Yup.string().max(1024),
|
|
||||||
port: Yup.number().min(0).max(65535),
|
|
||||||
auth: Yup.object({
|
|
||||||
enabled: Yup.boolean(),
|
|
||||||
username: Yup.string().max(1024),
|
|
||||||
password: Yup.string().max(1024)
|
|
||||||
}),
|
|
||||||
noProxy: Yup.string().max(1024)
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const PreferencesContext = createContext();
|
export const PreferencesContext = createContext();
|
||||||
|
@ -162,9 +162,7 @@ const getCollectionRoot = (dir) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = fs.readFileSync(collectionRootPath, 'utf8');
|
const content = fs.readFileSync(collectionRootPath, 'utf8');
|
||||||
const json = collectionBruToJson(content);
|
return collectionBruToJson(content);
|
||||||
|
|
||||||
return json;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const builder = async (yargs) => {
|
const builder = async (yargs) => {
|
||||||
|
@ -16,6 +16,7 @@ const { HttpsProxyAgent } = require('https-proxy-agent');
|
|||||||
const { HttpProxyAgent } = require('http-proxy-agent');
|
const { HttpProxyAgent } = require('http-proxy-agent');
|
||||||
const { SocksProxyAgent } = require('socks-proxy-agent');
|
const { SocksProxyAgent } = require('socks-proxy-agent');
|
||||||
const { makeAxiosInstance } = require('../utils/axios-instance');
|
const { makeAxiosInstance } = require('../utils/axios-instance');
|
||||||
|
const { shouldUseProxy } = require('../utils/proxy-util');
|
||||||
|
|
||||||
const runSingleRequest = async function (
|
const runSingleRequest = async function (
|
||||||
filename,
|
filename,
|
||||||
@ -86,22 +87,22 @@ const runSingleRequest = async function (
|
|||||||
const httpsAgentRequestFields = {};
|
const httpsAgentRequestFields = {};
|
||||||
if (insecure) {
|
if (insecure) {
|
||||||
httpsAgentRequestFields['rejectUnauthorized'] = false;
|
httpsAgentRequestFields['rejectUnauthorized'] = false;
|
||||||
} else {
|
}
|
||||||
const cacertArray = [options['cacert'], process.env.SSL_CERT_FILE, process.env.NODE_EXTRA_CA_CERTS];
|
|
||||||
const cacert = cacertArray.find((el) => el);
|
const caCertArray = [options['cacert'], process.env.SSL_CERT_FILE, process.env.NODE_EXTRA_CA_CERTS];
|
||||||
if (cacert && cacert.length > 1) {
|
const caCert = caCertArray.find((el) => el);
|
||||||
try {
|
if (caCert && caCert.length > 1) {
|
||||||
caCrt = fs.readFileSync(cacert);
|
try {
|
||||||
httpsAgentRequestFields['ca'] = caCrt;
|
httpsAgentRequestFields['ca'] = fs.readFileSync(caCert);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log('Error reading CA cert file:' + cacert, err);
|
console.log('Error reading CA cert file:' + caCert, err);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set proxy if enabled
|
// set proxy if enabled
|
||||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
||||||
if (proxyEnabled) {
|
const proxyByPass = shouldUseProxy(request.url, get(brunoConfig, 'proxy.noProxy', ''));
|
||||||
|
if (proxyEnabled && !proxyByPass) {
|
||||||
let proxyUri;
|
let proxyUri;
|
||||||
const interpolationOptions = {
|
const interpolationOptions = {
|
||||||
envVars: envVariables,
|
envVars: envVariables,
|
||||||
@ -115,8 +116,6 @@ const runSingleRequest = async function (
|
|||||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
||||||
const socksEnabled = proxyProtocol.includes('socks');
|
const socksEnabled = proxyProtocol.includes('socks');
|
||||||
|
|
||||||
interpolateString;
|
|
||||||
|
|
||||||
if (proxyAuthEnabled) {
|
if (proxyAuthEnabled) {
|
||||||
const proxyAuthUsername = interpolateString(get(brunoConfig, 'proxy.auth.username'), interpolationOptions);
|
const proxyAuthUsername = interpolateString(get(brunoConfig, 'proxy.auth.username'), interpolationOptions);
|
||||||
const proxyAuthPassword = interpolateString(get(brunoConfig, 'proxy.auth.password'), interpolationOptions);
|
const proxyAuthPassword = interpolateString(get(brunoConfig, 'proxy.auth.password'), interpolationOptions);
|
||||||
@ -128,16 +127,13 @@ const runSingleRequest = async function (
|
|||||||
|
|
||||||
if (socksEnabled) {
|
if (socksEnabled) {
|
||||||
const socksProxyAgent = new SocksProxyAgent(proxyUri);
|
const socksProxyAgent = new SocksProxyAgent(proxyUri);
|
||||||
|
|
||||||
request.httpsAgent = socksProxyAgent;
|
request.httpsAgent = socksProxyAgent;
|
||||||
|
|
||||||
request.httpAgent = socksProxyAgent;
|
request.httpAgent = socksProxyAgent;
|
||||||
} else {
|
} else {
|
||||||
request.httpsAgent = new HttpsProxyAgent(
|
request.httpsAgent = new HttpsProxyAgent(
|
||||||
proxyUri,
|
proxyUri,
|
||||||
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
request.httpAgent = new HttpProxyAgent(proxyUri);
|
request.httpAgent = new HttpProxyAgent(proxyUri);
|
||||||
}
|
}
|
||||||
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||||
|
@ -4,10 +4,10 @@ const axios = require('axios');
|
|||||||
* Function that configures axios with timing interceptors
|
* Function that configures axios with timing interceptors
|
||||||
* Important to note here that the timings are not completely accurate.
|
* Important to note here that the timings are not completely accurate.
|
||||||
* @see https://github.com/axios/axios/issues/695
|
* @see https://github.com/axios/axios/issues/695
|
||||||
* @returns {import('axios').AxiosStatic}
|
* @returns {axios.AxiosInstance}
|
||||||
*/
|
*/
|
||||||
function makeAxiosInstance() {
|
function makeAxiosInstance() {
|
||||||
/** @type {import('axios').AxiosStatic} */
|
/** @type {axios.AxiosInstance} */
|
||||||
const instance = axios.create();
|
const instance = axios.create();
|
||||||
|
|
||||||
instance.interceptors.request.use((config) => {
|
instance.interceptors.request.use((config) => {
|
||||||
@ -26,9 +26,7 @@ function makeAxiosInstance() {
|
|||||||
if (error.response) {
|
if (error.response) {
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
const start = error.config.headers['request-start-time'];
|
const start = error.config.headers['request-start-time'];
|
||||||
if (error.response) {
|
error.response.headers['request-duration'] = end - start;
|
||||||
error.response.headers['request-duration'] = end - start;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
65
packages/bruno-cli/src/utils/proxy-util.js
Normal file
65
packages/bruno-cli/src/utils/proxy-util.js
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
const parseUrl = require('url').parse;
|
||||||
|
|
||||||
|
const DEFAULT_PORTS = {
|
||||||
|
ftp: 21,
|
||||||
|
gopher: 70,
|
||||||
|
http: 80,
|
||||||
|
https: 443,
|
||||||
|
ws: 80,
|
||||||
|
wss: 443
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* check for proxy bypass, Copied form 'proxy-from-env'
|
||||||
|
*/
|
||||||
|
const shouldUseProxy = (url, proxyByPass) => {
|
||||||
|
if (proxyByPass === '*') {
|
||||||
|
return false; // Never proxy if wildcard is set.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!proxyByPass) {
|
||||||
|
return true; // use proxy if enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedUrl = typeof url === 'string' ? parseUrl(url) : url || {};
|
||||||
|
let proto = parsedUrl.protocol;
|
||||||
|
let hostname = parsedUrl.host;
|
||||||
|
let port = parsedUrl.port;
|
||||||
|
if (typeof hostname !== 'string' || !hostname || typeof proto !== 'string') {
|
||||||
|
return false; // Don't proxy URLs without a valid scheme or host.
|
||||||
|
}
|
||||||
|
|
||||||
|
proto = proto.split(':', 1)[0];
|
||||||
|
// Stripping ports in this way instead of using parsedUrl.hostname to make
|
||||||
|
// sure that the brackets around IPv6 addresses are kept.
|
||||||
|
hostname = hostname.replace(/:\d*$/, '');
|
||||||
|
port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
|
||||||
|
|
||||||
|
return proxyByPass.split(/[,;\s]/).every(function (dontProxyFor) {
|
||||||
|
if (!dontProxyFor) {
|
||||||
|
return true; // Skip zero-length hosts.
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedProxy = dontProxyFor.match(/^(.+):(\d+)$/);
|
||||||
|
let parsedProxyHostname = parsedProxy ? parsedProxy[1] : dontProxyFor;
|
||||||
|
const parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
|
||||||
|
if (parsedProxyPort && parsedProxyPort !== port) {
|
||||||
|
return true; // Skip if ports don't match.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!/^[.*]/.test(parsedProxyHostname)) {
|
||||||
|
// No wildcards, so stop proxying if there is an exact match.
|
||||||
|
return hostname !== parsedProxyHostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedProxyHostname.charAt(0) === '*') {
|
||||||
|
// Remove leading wildcard.
|
||||||
|
parsedProxyHostname = parsedProxyHostname.slice(1);
|
||||||
|
}
|
||||||
|
// Stop proxying if the hostname ends with the no_proxy host.
|
||||||
|
return !hostname.endsWith(parsedProxyHostname);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
shouldUseProxy
|
||||||
|
};
|
@ -48,7 +48,6 @@
|
|||||||
"node-machine-id": "^1.1.12",
|
"node-machine-id": "^1.1.12",
|
||||||
"qs": "^6.11.0",
|
"qs": "^6.11.0",
|
||||||
"socks-proxy-agent": "^8.0.2",
|
"socks-proxy-agent": "^8.0.2",
|
||||||
"ssl-root-cas": "^1.3.1",
|
|
||||||
"uuid": "^9.0.0",
|
"uuid": "^9.0.0",
|
||||||
"vm2": "^3.9.13",
|
"vm2": "^3.9.13",
|
||||||
"yup": "^0.32.11"
|
"yup": "^0.32.11"
|
||||||
|
@ -4,10 +4,10 @@ const axios = require('axios');
|
|||||||
* Function that configures axios with timing interceptors
|
* Function that configures axios with timing interceptors
|
||||||
* Important to note here that the timings are not completely accurate.
|
* Important to note here that the timings are not completely accurate.
|
||||||
* @see https://github.com/axios/axios/issues/695
|
* @see https://github.com/axios/axios/issues/695
|
||||||
* @returns {import('axios').AxiosStatic}
|
* @returns {axios.AxiosInstance}
|
||||||
*/
|
*/
|
||||||
function makeAxiosInstance() {
|
function makeAxiosInstance() {
|
||||||
/** @type {import('axios').AxiosStatic} */
|
/** @type {axios.AxiosInstance} */
|
||||||
const instance = axios.create();
|
const instance = axios.create();
|
||||||
|
|
||||||
instance.interceptors.request.use((config) => {
|
instance.interceptors.request.use((config) => {
|
||||||
|
@ -2,6 +2,7 @@ const os = require('os');
|
|||||||
const qs = require('qs');
|
const qs = require('qs');
|
||||||
const https = require('https');
|
const https = require('https');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
|
const fs = require('fs');
|
||||||
const decomment = require('decomment');
|
const decomment = require('decomment');
|
||||||
const Mustache = require('mustache');
|
const Mustache = require('mustache');
|
||||||
const FormData = require('form-data');
|
const FormData = require('form-data');
|
||||||
@ -23,6 +24,7 @@ const { HttpProxyAgent } = require('http-proxy-agent');
|
|||||||
const { SocksProxyAgent } = require('socks-proxy-agent');
|
const { SocksProxyAgent } = require('socks-proxy-agent');
|
||||||
const { makeAxiosInstance } = require('./axios-instance');
|
const { makeAxiosInstance } = require('./axios-instance');
|
||||||
const { addAwsV4Interceptor, resolveCredentials } = require('./awsv4auth-helper');
|
const { addAwsV4Interceptor, resolveCredentials } = require('./awsv4auth-helper');
|
||||||
|
const { shouldUseProxy } = require('../../utils/proxy-util');
|
||||||
|
|
||||||
// override the default escape function to prevent escaping
|
// override the default escape function to prevent escaping
|
||||||
Mustache.escape = function (value) {
|
Mustache.escape = function (value) {
|
||||||
@ -82,6 +84,24 @@ const getSize = (data) => {
|
|||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getHttpsAgentRequestFields() {
|
||||||
|
const httpsAgentRequestFields = {};
|
||||||
|
if (!preferences.isTlsVerification()) {
|
||||||
|
httpsAgentRequestFields['rejectUnauthorized'] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacCrtArray = [preferences.getCaCert(), process.env.SSL_CERT_FILE, process.env.NODE_EXTRA_CA_CERTS];
|
||||||
|
let caCertFile = cacCrtArray.find((el) => el);
|
||||||
|
if (caCertFile && caCertFile.length > 1) {
|
||||||
|
try {
|
||||||
|
httpsAgentRequestFields['ca'] = fs.readFileSync(caCertFile);
|
||||||
|
} catch (err) {
|
||||||
|
console.log('Error reading CA cert file:' + caCertFile, err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return httpsAgentRequestFields;
|
||||||
|
}
|
||||||
|
|
||||||
const registerNetworkIpc = (mainWindow) => {
|
const registerNetworkIpc = (mainWindow) => {
|
||||||
// handler for sending http request
|
// handler for sending http request
|
||||||
ipcMain.handle('send-http-request', async (event, item, collection, environment, collectionVariables) => {
|
ipcMain.handle('send-http-request', async (event, item, collection, environment, collectionVariables) => {
|
||||||
@ -204,43 +224,34 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
cancelTokenUid
|
cancelTokenUid
|
||||||
});
|
});
|
||||||
|
|
||||||
const httpsAgentRequestFields = {};
|
const httpsAgentRequestFields = getHttpsAgentRequestFields();
|
||||||
if (!preferences.isTlsVerification()) {
|
|
||||||
httpsAgentRequestFields['rejectUnauthorized'] = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cacertArray = [preferences.getCaCert(), process.env.SSL_CERT_FILE, process.env.NODE_EXTRA_CA_CERTS];
|
|
||||||
let cacertFile = cacertArray.find((el) => el);
|
|
||||||
if (cacertFile && cacertFile.length > 1) {
|
|
||||||
try {
|
|
||||||
const sslRootCas = require('ssl-root-cas').inject();
|
|
||||||
sslRootCas.addFile(cacertFile);
|
|
||||||
} catch (err) {
|
|
||||||
console.log('Error reading CA cert file:' + cacertFile, err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// proxy configuration
|
// proxy configuration
|
||||||
const brunoConfig = getBrunoConfig(collectionUid);
|
const brunoConfig = getBrunoConfig(collectionUid);
|
||||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', 'disabled');
|
let proxyConfig = get(brunoConfig, 'proxy', {});
|
||||||
if (proxyEnabled === 'enabled') {
|
let proxyEnabled = get(proxyConfig, 'enabled', 'disabled');
|
||||||
|
if (proxyEnabled === 'global') {
|
||||||
|
proxyConfig = preferences.getProxyConfig();
|
||||||
|
proxyEnabled = get(proxyConfig, 'enabled', false);
|
||||||
|
}
|
||||||
|
const proxyByPass = shouldUseProxy(request.url, get(proxyConfig, 'noProxy', ''));
|
||||||
|
if ((proxyEnabled === true || proxyEnabled === 'enabled') && !proxyByPass) {
|
||||||
let proxyUri;
|
let proxyUri;
|
||||||
|
|
||||||
const interpolationOptions = {
|
const interpolationOptions = {
|
||||||
envVars,
|
envVars,
|
||||||
collectionVariables,
|
collectionVariables,
|
||||||
processEnvVars
|
processEnvVars
|
||||||
};
|
};
|
||||||
|
|
||||||
const proxyProtocol = interpolateString(get(brunoConfig, 'proxy.protocol'), interpolationOptions);
|
const proxyProtocol = interpolateString(get(proxyConfig, 'protocol'), interpolationOptions);
|
||||||
const proxyHostname = interpolateString(get(brunoConfig, 'proxy.hostname'), interpolationOptions);
|
const proxyHostname = interpolateString(get(proxyConfig, 'hostname'), interpolationOptions);
|
||||||
const proxyPort = interpolateString(get(brunoConfig, 'proxy.port'), interpolationOptions);
|
const proxyPort = interpolateString(get(proxyConfig, 'port'), interpolationOptions);
|
||||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
const proxyAuthEnabled = get(proxyConfig, 'auth.enabled', false);
|
||||||
const socksEnabled = proxyProtocol.includes('socks');
|
const socksEnabled = proxyProtocol.includes('socks');
|
||||||
|
|
||||||
if (proxyAuthEnabled) {
|
if (proxyAuthEnabled) {
|
||||||
const proxyAuthUsername = interpolateString(get(brunoConfig, 'proxy.auth.username'), interpolationOptions);
|
const proxyAuthUsername = interpolateString(get(proxyConfig, 'auth.username'), interpolationOptions);
|
||||||
const proxyAuthPassword = interpolateString(get(brunoConfig, 'proxy.auth.password'), interpolationOptions);
|
const proxyAuthPassword = interpolateString(get(proxyConfig, 'auth.password'), interpolationOptions);
|
||||||
|
|
||||||
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
||||||
} else {
|
} else {
|
||||||
@ -673,10 +684,18 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
...eventData
|
...eventData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const httpsAgentRequestFields = getHttpsAgentRequestFields();
|
||||||
|
|
||||||
// proxy configuration
|
// proxy configuration
|
||||||
const brunoConfig = getBrunoConfig(collectionUid);
|
const brunoConfig = getBrunoConfig(collectionUid);
|
||||||
const proxyEnabled = get(brunoConfig, 'proxy.enabled', false);
|
let proxyConfig = get(brunoConfig, 'proxy', {});
|
||||||
if (proxyEnabled) {
|
let proxyEnabled = get(proxyConfig, 'enabled', 'disabled');
|
||||||
|
if (proxyEnabled === 'global') {
|
||||||
|
proxyConfig = preferences.getProxyConfig();
|
||||||
|
proxyEnabled = get(proxyConfig, 'enabled', false);
|
||||||
|
}
|
||||||
|
const proxyByPass = shouldUseProxy(request.url, get(proxyConfig, 'noProxy', ''));
|
||||||
|
if ((proxyEnabled === true || proxyEnabled === 'enabled') && !proxyByPass) {
|
||||||
let proxyUri;
|
let proxyUri;
|
||||||
const interpolationOptions = {
|
const interpolationOptions = {
|
||||||
envVars,
|
envVars,
|
||||||
@ -684,22 +703,15 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
processEnvVars
|
processEnvVars
|
||||||
};
|
};
|
||||||
|
|
||||||
const proxyProtocol = interpolateString(get(brunoConfig, 'proxy.protocol'), interpolationOptions);
|
const proxyProtocol = interpolateString(get(proxyConfig, 'protocol'), interpolationOptions);
|
||||||
const proxyHostname = interpolateString(get(brunoConfig, 'proxy.hostname'), interpolationOptions);
|
const proxyHostname = interpolateString(get(proxyConfig, 'hostname'), interpolationOptions);
|
||||||
const proxyPort = interpolateString(get(brunoConfig, 'proxy.port'), interpolationOptions);
|
const proxyPort = interpolateString(get(proxyConfig, 'port'), interpolationOptions);
|
||||||
const proxyAuthEnabled = get(brunoConfig, 'proxy.auth.enabled', false);
|
const proxyAuthEnabled = get(proxyConfig, 'auth.enabled', false);
|
||||||
const socksEnabled = proxyProtocol.includes('socks');
|
const socksEnabled = proxyProtocol.includes('socks');
|
||||||
|
|
||||||
if (proxyAuthEnabled) {
|
if (proxyAuthEnabled) {
|
||||||
const proxyAuthUsername = interpolateString(
|
const proxyAuthUsername = interpolateString(get(proxyConfig, 'auth.username'), interpolationOptions);
|
||||||
get(brunoConfig, 'proxy.auth.username'),
|
const proxyAuthPassword = interpolateString(get(proxyConfig, 'auth.password'), interpolationOptions);
|
||||||
interpolationOptions
|
|
||||||
);
|
|
||||||
|
|
||||||
const proxyAuthPassword = interpolateString(
|
|
||||||
get(brunoConfig, 'proxy.auth.password'),
|
|
||||||
interpolationOptions
|
|
||||||
);
|
|
||||||
|
|
||||||
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
proxyUri = `${proxyProtocol}://${proxyAuthUsername}:${proxyAuthPassword}@${proxyHostname}:${proxyPort}`;
|
||||||
} else {
|
} else {
|
||||||
@ -708,19 +720,18 @@ const registerNetworkIpc = (mainWindow) => {
|
|||||||
|
|
||||||
if (socksEnabled) {
|
if (socksEnabled) {
|
||||||
const socksProxyAgent = new SocksProxyAgent(proxyUri);
|
const socksProxyAgent = new SocksProxyAgent(proxyUri);
|
||||||
|
|
||||||
request.httpsAgent = socksProxyAgent;
|
request.httpsAgent = socksProxyAgent;
|
||||||
request.httpAgent = socksProxyAgent;
|
request.httpAgent = socksProxyAgent;
|
||||||
} else {
|
} else {
|
||||||
request.httpsAgent = new HttpsProxyAgent(proxyUri, {
|
request.httpsAgent = new HttpsProxyAgent(
|
||||||
rejectUnauthorized: preferences.isTlsVerification()
|
proxyUri,
|
||||||
});
|
Object.keys(httpsAgentRequestFields).length > 0 ? { ...httpsAgentRequestFields } : undefined
|
||||||
|
);
|
||||||
request.httpAgent = new HttpProxyAgent(proxyUri);
|
request.httpAgent = new HttpProxyAgent(proxyUri);
|
||||||
}
|
}
|
||||||
} else if (!preferences.isTlsVerification()) {
|
} else if (Object.keys(httpsAgentRequestFields).length > 0) {
|
||||||
request.httpsAgent = new https.Agent({
|
request.httpsAgent = new https.Agent({
|
||||||
rejectUnauthorized: false
|
...httpsAgentRequestFields
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,12 +76,17 @@ const preferences = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
isTlsVerification: () => {
|
isTlsVerification: () => {
|
||||||
return get(getPreferences(), ['request.tlsVerification'], true);
|
return get(getPreferences(), 'request.tlsVerification', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
getCaCert: () => {
|
getCaCert: () => {
|
||||||
return get(getPreferences(), 'request.cacert');
|
return get(getPreferences(), 'request.cacert');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getProxyConfig: () => {
|
||||||
|
return get(getPreferences(), 'proxy', {});
|
||||||
|
},
|
||||||
|
|
||||||
setPreferences: (validatedPreferences) => {
|
setPreferences: (validatedPreferences) => {
|
||||||
const updatedPreferences = {
|
const updatedPreferences = {
|
||||||
...getPreferences(),
|
...getPreferences(),
|
||||||
|
64
packages/bruno-electron/src/utils/proxy-util.js
Normal file
64
packages/bruno-electron/src/utils/proxy-util.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
const parseUrl = require('url').parse;
|
||||||
|
|
||||||
|
const DEFAULT_PORTS = {
|
||||||
|
ftp: 21,
|
||||||
|
gopher: 70,
|
||||||
|
http: 80,
|
||||||
|
https: 443,
|
||||||
|
ws: 80,
|
||||||
|
wss: 443
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* check for proxy bypass, copied form 'proxy-from-env'
|
||||||
|
*/
|
||||||
|
const shouldUseProxy = (url, proxyByPass) => {
|
||||||
|
if (proxyByPass === '*') {
|
||||||
|
return false; // Never proxy if wildcard is set.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!proxyByPass) {
|
||||||
|
return true; // use proxy if enabled
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsedUrl = typeof url === 'string' ? parseUrl(url) : url || {};
|
||||||
|
let proto = parsedUrl.protocol;
|
||||||
|
let hostname = parsedUrl.host;
|
||||||
|
let port = parsedUrl.port;
|
||||||
|
if (typeof hostname !== 'string' || !hostname || typeof proto !== 'string') {
|
||||||
|
return false; // Don't proxy URLs without a valid scheme or host.
|
||||||
|
}
|
||||||
|
|
||||||
|
proto = proto.split(':', 1)[0];
|
||||||
|
// Stripping ports in this way instead of using parsedUrl.hostname to make
|
||||||
|
// sure that the brackets around IPv6 addresses are kept.
|
||||||
|
hostname = hostname.replace(/:\d*$/, '');
|
||||||
|
port = parseInt(port) || DEFAULT_PORTS[proto] || 0;
|
||||||
|
|
||||||
|
return proxyByPass.split(/[,;\s]/).every(function (dontProxyFor) {
|
||||||
|
if (!dontProxyFor) {
|
||||||
|
return true; // Skip zero-length hosts.
|
||||||
|
}
|
||||||
|
const parsedProxy = dontProxyFor.match(/^(.+):(\d+)$/);
|
||||||
|
let parsedProxyHostname = parsedProxy ? parsedProxy[1] : dontProxyFor;
|
||||||
|
const parsedProxyPort = parsedProxy ? parseInt(parsedProxy[2]) : 0;
|
||||||
|
if (parsedProxyPort && parsedProxyPort !== port) {
|
||||||
|
return true; // Skip if ports don't match.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!/^[.*]/.test(parsedProxyHostname)) {
|
||||||
|
// No wildcards, so stop proxying if there is an exact match.
|
||||||
|
return hostname !== parsedProxyHostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parsedProxyHostname.charAt(0) === '*') {
|
||||||
|
// Remove leading wildcard.
|
||||||
|
parsedProxyHostname = parsedProxyHostname.slice(1);
|
||||||
|
}
|
||||||
|
// Stop proxying if the hostname ends with the no_proxy host.
|
||||||
|
return !hostname.endsWith(parsedProxyHostname);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
shouldUseProxy
|
||||||
|
};
|
50
packages/bruno-electron/tests/utils/proxy-util.spec.js
Normal file
50
packages/bruno-electron/tests/utils/proxy-util.spec.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
const { shouldUseProxy } = require('../../src/utils/proxy-util');
|
||||||
|
|
||||||
|
test('no proxy necessary - star', () => {
|
||||||
|
const url = 'http://wwww.example.org/test';
|
||||||
|
const noProxy = '*';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('no proxy necessary - no noProxy bypass', () => {
|
||||||
|
const url = 'http://wwww.example.org/test';
|
||||||
|
const noProxy = '';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('no proxy necessary - wildcard match', () => {
|
||||||
|
const url = 'http://wwww.example.org/test';
|
||||||
|
const noProxy = '*example.org';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('no proxy necessary - direct proxy', () => {
|
||||||
|
const url = 'http://wwww.example.org/test';
|
||||||
|
const noProxy = 'wwww.example.org';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('no proxy necessary - multiple proxy', () => {
|
||||||
|
const url = 'http://wwww.example.org/test';
|
||||||
|
const noProxy = 'www.example.com,wwww.example.org';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('proxy necessary - no proxy match multiple', () => {
|
||||||
|
const url = 'https://wwww.example.test/test';
|
||||||
|
const noProxy = 'www.example.com,wwww.example.org';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('proxy necessary - no proxy match', () => {
|
||||||
|
const url = 'https://wwww.example.test/test';
|
||||||
|
const noProxy = 'www.example.com';
|
||||||
|
|
||||||
|
expect(shouldUseProxy(url, noProxy)).toEqual(true);
|
||||||
|
});
|
@ -1,6 +1,6 @@
|
|||||||
const { test, expect } = require('@playwright/test');
|
const { test, expect } = require('@playwright/test');
|
||||||
const { HomePage } = require('../tests/pages/home.page');
|
const { HomePage } = require('../tests/pages/home.page');
|
||||||
import * as faker from './utils/data-faker';
|
const { faker } = require('./utils/data-faker');
|
||||||
|
|
||||||
test.describe('bruno e2e test', () => {
|
test.describe('bruno e2e test', () => {
|
||||||
let homePage;
|
let homePage;
|
||||||
|
Loading…
Reference in New Issue
Block a user