Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Feat]: add test suite for running e2e tests behind proxy/not root #5337

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

Closed
2 tasks
jsjoeio opened this issue Jul 14, 2022 · 0 comments · Fixed by #5348
Closed
2 tasks

[Feat]: add test suite for running e2e tests behind proxy/not root #5337

jsjoeio opened this issue Jul 14, 2022 · 0 comments · Fixed by #5348
Assignees
Labels
enhancement Some improvement that isn't a feature
Milestone

Comments

@jsjoeio
Copy link
Contributor

jsjoeio commented Jul 14, 2022

What is your suggestion?

To modify our e2e test setup to run the same tests but in an environment that runs code-server not on the root path i.e. behind /ide or something.

Why do you want this feature?

It mimics how many of our users run code-server and also mimics how we run code-server in both Coder and Coder OSS.

It would have prevented a high-impact bug we accidentally introduced in 4.5.0.

See #5321

Are there any workarounds to get this functionality today?

Manually testing code-server behind a reverse proxy with Caddy before each release 😅

Are you interested in submitting a PR for this?

Yes

Notes

Instead of duplicating tests, it would be cool if we added a new script like yarn test:e2e:caddy or something which spun up Caddy in front of code-server and then ran the tests using that environment.

Currently the e2e tests run in parallel (I believe) and use random ports so we'd have to use a wildcard in Caddy (I'm pretty sure it can do that).

We'd also have to make sure code-server's address had the path in it. I'm guessing we could do some environment variable logic or something like PATH_TO_USE="/ide" and then dynamically set address.

_notes from Discord call with @code-asher _

  • install Caddy
  • launch Caddy
  • set env variable to use proxy or special path

we might be able to use named matchers.

simplest way to do this:

  • write Caddyfile
  • run code-server on one port and make sure it works as expected
  • run it on another port and make sure it works
:80 {
        @portLocalhost header_regexp port Host ^([0-9]+)\.localhost$
        handle @portLocalhost {
                reverse_proxy localhost:{re.port.1}
        }
        
        handle {        
                respond "Bad hostname" 400
        }
}

USE_PROXY=1

caddy start

if(USE_PROXY && USE_PROXY=1) {
  return port.localhost
}
const uri = new URL(address)
const port = uri.port
  • add support for USE_PROXY
  • add Caddyfile
@jsjoeio jsjoeio added the enhancement Some improvement that isn't a feature label Jul 14, 2022
@jsjoeio jsjoeio modified the milestones: July 2022, 4.5.1 Jul 14, 2022
@jsjoeio jsjoeio self-assigned this Jul 15, 2022
@jsjoeio jsjoeio modified the milestones: July 2022, 4.5.1 Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Some improvement that isn't a feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant