- 
                Notifications
    You must be signed in to change notification settings 
- Fork 678
Add proxy-bypass option to prevent using proxy depending on rule #2187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| ❌ Tests for the commit 86e06b0 have failed. See details: | 
| ❌ Tests for the commit 4db9ede have failed. See details: | 
| ✅ Tests for the commit c34ef94 have passed. See details: | 
| see API in tests | 
        
          
                test/server/match-url-test.js
              
                Outdated
          
        
      | var expect = require('chai').expect; | ||
| var matchUrl = require('../../lib/utils/check-url'); | ||
|  | ||
| it('Should fallback to the default reporter if reporter was not set', function () { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange name for the test
| @testcafe-build-bot \retest | 
| ❌ Tests for the commit 7376ad1 have failed. See details: | 
        
          
                src/cli/argument-parser.js
              
                Outdated
          
        
      | .option('--ports <port1,port2>', 'specify custom port numbers') | ||
| .option('--hostname <name>', 'specify the hostname') | ||
| .option('--proxy <host>', 'specify the host of the proxy server') | ||
| .option('--proxy-bypass <url1,url2>', 'specify the urls to bypass the proxy server') | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it must be more like the reporters method description: <host-wildcard[,...]>
\cc @VasilyStrelyaev
        
          
                test/server/match-url-test.js
              
                Outdated
          
        
      | expect(matchUrl('127.0.0.1', rule)).to.be.true; | ||
| expect(matchUrl('http://127.0.0.1', rule)).to.be.true; | ||
| expect(matchUrl('https://127.0.0.1', rule)).to.be.true; | ||
| expect(matchUrl('https://127.0.0.1', rule)).to.be.true; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. mistake
        
          
                test/server/match-url-test.js
              
                Outdated
          
        
      | expect(matchUrl('127.0.0.1', rule)).to.be.true; | ||
| expect(matchUrl('http://127.0.0.1', rule)).to.be.true; | ||
| expect(matchUrl('https://127.0.0.1', rule)).to.be.true; | ||
| expect(matchUrl('https://127.0.0.1', rule)).to.be.true; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same line as above
| const containsWildcardPlaceholder = new RegExp(wildcardPlaceholder, 'g'); | ||
|  | ||
| function parseUrl (url) { | ||
|  | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this blank line
        
          
                test/server/match-url-test.js
              
                Outdated
          
        
      | var matchUrl = require('../../lib/utils/check-url'); | ||
|  | ||
| it('Should check does url match rule', function () { | ||
| var rule = ['google.com']; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use just string here, can't we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we can
        
          
                src/cli/argument-parser.js
              
                Outdated
          
        
      | .option('--ports <port1,port2>', 'specify custom port numbers') | ||
| .option('--hostname <name>', 'specify the hostname') | ||
| .option('--proxy <host>', 'specify the host of the proxy server') | ||
| .option('--proxy-bypass <url1,url2>', 'specify the urls to bypass the proxy server') | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to check type of url template value and create error for a case when we cannot parse it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it is not required to create error. If rule is incorrent test will run via proxy, and that's all. Rule just will be ignored. Don't you agree?
| ✅ Tests for the commit 7376ad1 have passed. See details: | 
        
          
                src/cli/argument-parser.js
              
                Outdated
          
        
      | .option('--ports <port1,port2>', 'specify custom port numbers') | ||
| .option('--hostname <name>', 'specify the hostname') | ||
| .option('--proxy <host>', 'specify the host of the proxy server') | ||
| .option('--proxy-bypass <url1,url2>', 'specify the urls to bypass the proxy server') | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
            .option('--proxy-bypass <rules>', 'specify a comma-separated list of rules that define URLs accessed bypassing the proxy server')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding #2187 (comment) we can just add Rules consist of URLs with wildcards enabled.
Is that simpler. @AndreyBelym ?
| ❌ Tests for the commit b7736b5 have failed. See details: | 
| ❌ Tests for the commit b054111 have failed. See details: | 
| @testcafe-build-bot \retest | 
| ❌ Tests for the commit b054111 have failed. See details: | 
| ✅ Tests for the commit b054111 have passed. See details: | 
| FPR | 
| ✅ Tests for the commit 06a730f have passed. See details: | 
| Great to see this feature beeing added! Thank you! Is this expected to work for ressources like CSS stylesheets or JavaScript files that are linked from the page under test? I'm sitting behind a corporate proxy and want to test a page that is served by a web server on localhost. The page loads a JavaScript library from a remote host. So the request to load the page should bypass the proxy, the request to get the library should go through the proxy. I call TestCafé CLI with  To test in isolation I created this small repo: n0v1/testcafe-proxy-bypass-test Update: When debugging this, testcafe-hammerhead/src/request-pipeline/destination-request/_onError receives this error object: {
  Error: connect ETIMEDOUT 104.16.86.20:80
    at Object._errnoException (util.js:1022:11)
    at _exceptionWithHostPort (util.js:1044:20)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
  code: 'ETIMEDOUT',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '104.16.86.20',
  port: 80
}this.opts = ... (click to expand)this.opts = {
  url: 'http://cdn.jsdelivr.net/npm/[email protected]/lodash.min.js',
  protocol: 'http:',
  hostname: 'cdn.jsdelivr.net',
  host: 'cdn.jsdelivr.net',
  port: undefined,
  path: '/npm/[email protected]/lodash.min.js',
  method: 'GET',
  credentials: null,
  body: <Buffer >,
  isXhr: false,
  proxy: null,
  headers: {
    host: 'cdn.jsdelivr.net',
    'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0',
    accept: '*/*',
    'accept-language': 'de,en-US;q=0.7,en;q=0.3',
    'accept-encoding': 'gzip, deflate',
    referer: 'http://127.0.0.1:8000/test.html',
    connection: 'keep-alive'
  },
  agent: {
    domain: null,
    _events: { free: [Function] },
    _eventsCount: 1,
    _maxListeners: undefined,
    defaultPort: 80,
    protocol: 'http:',
    options: { secureProtocol: undefined, keepAlive: true, path: null },
    requests: {},
    sockets: { 'cdn.jsdelivr.net:80::': [Array] },
    freeSockets: {},
    keepAliveMsecs: 1000,
    keepAlive: true,
    maxSockets: Infinity,
    maxFreeSockets: 256
  } 
} | 
| Hi | 
| Leave a comment | 
| Hello, can you please clarify how to use this bypass? The problem we have is that we first do a GET to one webpage but then during the load it is redirected to another one. And in TestCafe the first page loads correctly but the next one gets UNAUTHORIZED. However pasting that second URL in the same browser manually loads the page correctly. So, what can I do in TestCafe to also bypass proxy for the redirected page? | 
| Hello @amirse80 | 
| Hello, 
 So if I would be able to just remove this part that testCafe adds, http://172.30.48.47:61019/DSc6im7OL/, it would probably work, because it does work if I manually add the redirected URL in the same browser. | 
No description provided.