Skip to content

Conversation

@AlexKamaev
Copy link
Contributor

No description provided.

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 86e06b0 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 4db9ede have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit c34ef94 have passed. See details:

@AlexKamaev AlexKamaev changed the title [WIP]noproxy Add proxy-bypass option to prevent using proxy depending on rule Mar 5, 2018
@AlexKamaev
Copy link
Contributor Author

see API in tests

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 () {
Copy link
Collaborator

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

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@AlexKamaev AlexKamaev closed this Mar 5, 2018
@AlexKamaev AlexKamaev reopened this Mar 5, 2018
@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit 7376ad1 have failed. See details:

.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')
Copy link
Contributor

@AndreyBelym AndreyBelym Mar 5, 2018

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

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. mistake

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;
Copy link
Collaborator

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) {

Copy link
Collaborator

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

var matchUrl = require('../../lib/utils/check-url');

it('Should check does url match rule', function () {
var rule = ['google.com'];
Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can

.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')
Copy link
Collaborator

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

Copy link
Contributor Author

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?

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 7376ad1 have passed. See details:

.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')
Copy link
Collaborator

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')

Copy link
Collaborator

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 ?

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit b7736b5 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit b054111 have failed. See details:

@AlexKamaev
Copy link
Contributor Author

@testcafe-build-bot \retest

@testcafe-build-bot
Copy link
Collaborator

❌ Tests for the commit b054111 have failed. See details:

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit b054111 have passed. See details:

@AlexKamaev
Copy link
Contributor Author

FPR

@testcafe-build-bot
Copy link
Collaborator

✅ Tests for the commit 06a730f have passed. See details:

@AndreyBelym AndreyBelym merged commit ff555e3 into DevExpress:master Mar 6, 2018
@n0v1
Copy link

n0v1 commented Mar 7, 2018

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 --proxy 172.30.109.30:8080 --proxy-bypass 127.0.0.1:8000. The page and all local ressources load correctly but the remote script does not. It keeps loading forever until a timeout is hit eventually.

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
  } 
}

@AlexKamaev
Copy link
Contributor Author

Hi
Now this feature is implemented only to bypass proxy for specific tests according to the test page url. But your case seems to be important, so I think we'll support it as well.

@amirse80
Copy link

amirse80 commented Sep 6, 2018

Leave a comment

@amirse80
Copy link

amirse80 commented Sep 6, 2018

Hello, can you please clarify how to use this bypass?
E.g: If I run my simple test case from CMD "TestCafe>testcafe chrome test1.js" and in the testfile I have an URL which is copmany internal how do I start it and make sure that URL is bypassed?

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?

@AlexKamaev
Copy link
Contributor Author

Hello @amirse80
TestCafe CLI supports two options for using proxy. Please refer to the following articles:
--proxy and --proxy-bypass.
According to our documentation, the proxyoption specifies the proxy server used in your local network to access the Internet. If you do not have access to the second URL, I suppose that you need to use the proxy option.
The proxy-bypass option can be used together with the proxy option. It's required when you use proxy, but don't need to use proxy only for some specific resources.

@amirse80
Copy link

amirse80 commented Sep 7, 2018

Hello,
Thank you for the input. Unfortunatelly it didn´t solve my problem.
The issue is like this.

  1. I navigate to an company internal page. (.page `http://dap-internal.company.page´)
  2. The chrome is started and initially navigates to the correct server.
  3. During the page opening the URL changes, redirects, to http://pen-internal.company.page. Now this new URL works fine in the same browser that testcafe has started IF i copy the real URL manually into the new tab BUT testcafe adds http://172.30.48.47:61019/DSc6im7OL/ to the URL which makes it not working. So instead of the real redirected URL http://pen-internal.company.page the redirected URL is http://172.30.48.47:61019/DSc6im7OL/http://pen.internal.company.page!

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.

kirovboris pushed a commit to kirovboris/testcafe-phoenix that referenced this pull request Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants