Skip to content
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

Exotic Proxy support #86

Closed
DavidSouther opened this issue Oct 5, 2012 · 13 comments
Closed

Exotic Proxy support #86

DavidSouther opened this issue Oct 5, 2012 · 13 comments

Comments

@DavidSouther
Copy link
Contributor

Proxy support currently only works for the most basic URL renaming situations. Anything more exotic, like

proxies = [
  '/': 'http://other.host.example.local'
]

will generally fail, because the underlying HTTP Proxy isn't correctly configured to change origin, etc. I propose an extended syntax for proxies:

proxies = [
  '/path': '/rewrite/local/path',
  '/remote': {
    server: 'other.host.example.local',
    port: 80,
    path: '/app/dir'
  }
]

with path being the minimum required; with no other options, 'url' and {path:'url'} would be equivalent.

@DavidSouther
Copy link
Contributor Author

I will be implementing this change locally over the weekend, since I need it now, and will offer a pull request early next week. In the meantime, I'd love to hear any thoughts on this proposal. (Though I am camping through mid-sunday, so won't be replying asap)

@DavidSouther
Copy link
Contributor Author

On closer examination, it just seems like changing the proxy server to always change origin might be enough, as url::parse handles pretty much everything else I'd considered in the original post. My original question of when changeOrigin should be set is still open- are there times where it would be detrimental? It seems that whenever the proxy host is different, it should certainly be set.

@vojtajina
Copy link
Contributor

Hey @DavidSouther, I'm not sure, what is the missing feature ?

This should work just fine:

proxies = {
  '/': 'http://other.host.example.local:80/app/dir/'
};

@DavidSouther
Copy link
Contributor Author

That does not work for http servers using name-based virtual hosts (which happen to be the only configuration I use :))

@vojtajina
Copy link
Contributor

I just put 127.0.0.1 other.host.local to my /etc/hosts, run simple web server on port 8000 and testacular proxy works fine with:

proxies = {
  '/': 'http://other.host.local:80/'
};

So I'm still confused, what am I missing ? Why specifying proxy with object (your proposal):

proxies = {
  '/remote': {
    server: 'other.host.example.local',
    port: 80,
    path: '/app/dir'
  }
}

Would be better than current:

proxies = {
  '/remote': 'http://other.host.example.local:80/app/dir/'
};

@DavidSouther
Copy link
Contributor Author

I believe I have muddled the issue. I no longer see any issues with the current syntax for defining proxies- that was a misunderstanding on my part of the proxy configuration method.

My issue with proxies is that changeOrigin is not set to true on the HttpProxy in web-server.js, making proxies behind name-based virtual servers (http servers that depend on the Host: header being set) unusable behind proxies.

It if would help, I could close this issue and open a new ticket for changeOrigin specifically, but it still falls under more "exotic" proxy support (albeit without needing changes to the configuration).

@DavidSouther
Copy link
Contributor Author

Slight edification: if there were additional configuration options that needed to be set on a per-proxy basis, an extended configuration block could be necessary. That would require reworking the proxy configuration to have one proxy per proxies entry. I don't think that is needed at this point.

@rishabhmhjn
Copy link

I am trying to do something like

proxies = {
    "/" : "https://local-domain/"
};

And I am getting an error something like

http://local-sandbox:8080/base/testSpec.js?1357741324000:11:6: Sandbox Error: Application document not accessible.

And the testacular browser console give something like

Unsafe JavaScript attempt to access frame with URL data:text/html,chromewebdata from frame with URL http://local-sandbox:8080/__testacular/context.html. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of ''. Protocols must match.
 angular-scenario.js:24385
angular.scenario.Application.executeAction angular-scenario.js:24385
(anonymous function) angular-scenario.js:24366
jQuery.event.dispatch angular-scenario.js:3333
elemData.handle.eventHandle angular-scenario.js:2942

Is there any possibility of e2e testing on an https based website?

@DavidSouther
Copy link
Contributor Author

At this point, testacular doesn't set up https proxies. You should serve
your app using http during development.
On Jan 9, 2013 9:35 AM, "Rishabh Mahajan" notifications@github.com wrote:

I am trying to do something like

proxies = {
"/" : "https://local-domain/"};

And I am getting an error something like

http://local-sandbox:8080/base/testSpec.js?1357741324000:11:6: Sandbox Error: Application document not accessible.

And the testacular browser console give something like

Unsafe JavaScript attempt to access frame with URL data:text/html,chromewebdata from frame with URL http://local-sandbox:8080/__testacular/context.html. The frame requesting access has a protocol of 'http', the frame being accessed has a protocol of ''. Protocols must match.
angular-scenario.js:24385
angular.scenario.Application.executeAction angular-scenario.js:24385
(anonymous function) angular-scenario.js:24366
jQuery.event.dispatch angular-scenario.js:3333
elemData.handle.eventHandle angular-scenario.js:2942

Is there any possibility of e2e testing on an https based website?


Reply to this email directly or view it on GitHubhttps://github.com/vojtajina/testacular/issues/86#issuecomment-12046511.

@rishabhmhjn
Copy link

Ouch! That hurts.
But thanks for the quick response. Saved my time.

@vojtajina
Copy link
Contributor

@rishabhmhjn Created issue/feature request for it https://github.com/vojtajina/testacular/issues/293

@rishabhmhjn
Copy link

I guess the repository moved. Re-referencing - #293

@b1alpha
Copy link

b1alpha commented Aug 14, 2013

I am having trouble using the proxy, my shared.conf.js has
shared.defaultProxies = {
'/': 'http://mydomain:8088'
};

but when I run my scenario.js
...
browser().navigateTo('/');
expect(browser().location().url()).toBe("/");
..

I get an error;

Chrome 28.0 (Windows) E2E: Testing for Smoke should verify the test server is on FAILED
E:/PheonixManager/trunk/Phoenix.Manager.Web.Client.Tests/test/e2e/scenarios.js:41:15: TypeError: Object [object Object] has no method 'injector'
Chrome 28.0 (Windows): Executed 1 of 1 (1 FAILED) (0.995 secs / 0.467 secs)
##teamcity[browserStart name='Chrome 28.0 (Windows)']
##teamcity[testSuiteStarted name='E2E: Testing for Smoke']
##teamcity[testStarted name='should verify the test server is on']
##teamcity[testFailed name='should verify the test server is on' message='FAILED' details='|["http://localhost:9876/base/test/e2e/scenarios.js?1376520546000:41:15: T
ypeError: Object |[object Object|] has no method |'injector|'"|]']
##teamcity[testFinished name='should verify the test server is on' duration='467']
##teamcity[testSuiteFinished name='E2E: Testing for Smoke']
##teamcity[browserEnd name='Chrome 28.0 (Windows)']
Chrome 28.0 (Windows): Executed 1 of 1 (1 FAILED) (0.995 secs / 0.467 secs)

I am running a application on mydomain:8088
I am running karma on localhost
I am running the angular test runner on node localhost:8100

Is this not a normal setup? What more must be done with the proxy, I am having trouble finding any examples of this. Thanks for the help.

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

No branches or pull requests

4 participants