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

Skip to content

feat(e2e): add support running behind proxy #5348

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

Merged
merged 14 commits into from
Aug 9, 2022
Merged

feat(e2e): add support running behind proxy #5348

merged 14 commits into from
Aug 9, 2022

Conversation

jsjoeio
Copy link
Contributor

@jsjoeio jsjoeio commented Jul 15, 2022

Description

This PR adds a new job to run our end-to-end tests behind a reverse-proxy (with Caddy) to simulate how code-server runs in coder/coder and in many community-member deployments.

Changes

  • add new job to ci along with Caddyfile
  • refactor auth in e2e tests
  • refactor address() method in e2e model to work with reverse-proxy
  • add USE_PROXY env var used in e2e tests and scripts

Fixes #5337

@jsjoeio jsjoeio requested a review from a team July 15, 2022 20:58
@jsjoeio jsjoeio self-assigned this Jul 15, 2022
@jsjoeio jsjoeio marked this pull request as draft July 15, 2022 20:58
@github-actions
Copy link

github-actions bot commented Jul 15, 2022

✨ code-server docs for PR #5348 is ready! It will be updated on every commit.

@codecov
Copy link

codecov bot commented Jul 15, 2022

Codecov Report

Merging #5348 (b991350) into main (efb5bae) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #5348   +/-   ##
=======================================
  Coverage   72.42%   72.42%           
=======================================
  Files          30       30           
  Lines        1672     1672           
  Branches      366      366           
=======================================
  Hits         1211     1211           
  Misses        398      398           
  Partials       63       63           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update efb5bae...b991350. Read the comment docs.

@jsjoeio jsjoeio temporarily deployed to npm July 15, 2022 21:03 Inactive
@github-actions
Copy link

github-actions bot commented Jul 15, 2022

✨ code-server dev build published to npm for PR #5348!

  • Last publish status: success
  • Commit: b991350

To install in a local project, run:

npm install @coder/code-server-pr@5348

To install globally, run:

npm install -g @coder/code-server-pr@5348

code-asher
code-asher previously approved these changes Jul 15, 2022
@jsjoeio jsjoeio temporarily deployed to npm July 15, 2022 22:10 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 20, 2022 19:18 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 21, 2022 20:42 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 21, 2022 21:00 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 21, 2022 21:54 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 21, 2022 22:10 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 21, 2022 22:28 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 22, 2022 17:29 Inactive
@jsjoeio jsjoeio temporarily deployed to npm July 22, 2022 21:48 Inactive
@jsjoeio
Copy link
Contributor Author

jsjoeio commented Jul 22, 2022

Need to figure out Caddyfile issues.

Opened forum post here: https://caddy.community/t/automatically-forward-subpath-to-port-on-localhost/16629

Oddly enough:

{
	admin    localhost:4444
}
:8000/*/ide/* {
        handle {
                respond "hello world" 200
        }

}

Doesn't work with http://localhost:8000/8080/ide/hi so something is up

@jsjoeio jsjoeio temporarily deployed to npm July 22, 2022 23:35 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 1, 2022 21:06 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 1, 2022 21:29 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 1, 2022 22:06 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 3, 2022 22:34 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 5, 2022 21:48 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 5, 2022 22:17 Inactive
jsjoeio added 5 commits August 8, 2022 10:16
We don't need the submodules for the e2e job. This will speed up the
checkout step.
This adds a new job to CI to run our tests behind Caddy and simulate
code-server running against a reverse-proxy.
This refactors the e2e test in a couple ways:
- remove setting cookie in localStorage (instead we pass --auth none)
- refactor address() method to account for reverse proxy logic
@jsjoeio jsjoeio force-pushed the jsjoeio/proxy-e2e branch from a223de2 to 070a328 Compare August 8, 2022 17:25
@jsjoeio jsjoeio marked this pull request as ready for review August 8, 2022 17:30
@jsjoeio jsjoeio requested a review from code-asher August 8, 2022 17:30
@jsjoeio jsjoeio temporarily deployed to npm August 8, 2022 17:32 Inactive
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

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

May reverse proxies never break again! 🥂

*/
export async function getMaybeProxiedCodeServer(codeServer: CodeServerPage | CodeServer): Promise<string> {
let address = await codeServer.address()
if (process.env.USE_PROXY && process.env.USE_PROXY === "1") {
Copy link
Member

Choose a reason for hiding this comment

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

nit: we could do with just the latter check

Suggested change
if (process.env.USE_PROXY && process.env.USE_PROXY === "1") {
if (process.env.USE_PROXY === "1") {

Copy link
Member

Choose a reason for hiding this comment

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

Ooops sorry my suggestion removed the indent, I keep forgetting copy does not copy the indent and I have to add it back in manually.

Copy link
Contributor Author

@jsjoeio jsjoeio Aug 9, 2022

Choose a reason for hiding this comment

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

😂 i'll fix locally, no worries. i didn't realize that either

@jsjoeio jsjoeio enabled auto-merge (squash) August 9, 2022 17:22
@jsjoeio jsjoeio temporarily deployed to npm August 9, 2022 17:37 Inactive
@jsjoeio jsjoeio temporarily deployed to npm August 9, 2022 18:07 Inactive
@jsjoeio jsjoeio merged commit f178f04 into main Aug 9, 2022
@jsjoeio jsjoeio deleted the jsjoeio/proxy-e2e branch August 9, 2022 18:24
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.

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