Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Fix an incorrect pathname in a WebView endpoint URL #940

Merged
merged 1 commit into from
Nov 30, 2020

Conversation

azatsarynnyy
Copy link
Member

@azatsarynnyy azatsarynnyy commented Nov 30, 2020

Signed-off-by: Artem Zatsarynnyi [email protected]

What does this PR do?

It fixes an incorrect pathname in a WebView endpoint URL.

When Theia/WebView Che endpoint URL contains pathname,
e.g. https://192.168.99.237.nip.io/server9u2gtltn-jwtproxy/webviews
Che Theia forms an incorrect URL for fetching WebView content,
like https://192.168.99.237.nip.io/server9u2gtltn-jwtproxy/server-4402/webview/.
The last one is actually an URL for Theia endpoint but not for WebView endpoint.
It works well as both URLs are forward to the same internal container and port, but it may cause problems in the future.

The problem comes from the upstream WebviewEnvironment that uses Endpoint for constructing an endpoint URL.
Endpoint class relies on self.location browser API to get the pathname. That works incorrectly for Che when a WebView endpoint has a different hostname+pathname.
That's why I've overrided externalEndpointUrl function in this PR to get WebView Che endpoint URL as is and not form it with help of Endpoint class.

Screenshot/screencast of this PR

What issues does this PR fix or reference?

It's an additional patch for eclipse-che/che#17694

How to test this PR?

  1. Deploy Che in single host mode
    chectl server:deploy --platform=minikube --installer=operator --che-operator-cr-patch-yaml=patch.yaml
    where patch.yaml content is
apiVersion: org.eclipse.che/v1
kind: CheCluster
metadata:
  name: eclipse-che
spec:
  server:
    serverExposureStrategy: 'single-host'
  k8s:
    singleHostExposureType: 'native'
  1. Start a Workspace from the Devfile
apiVersion: 1.0.0
metadata:
  generateName: pr-che_theia-940-
components:
  - reference: https://raw.githubusercontent.com/chepullreq4/pr-check-files/master/che-theia/pr-940/simple/che-theia-editor.yaml
    type: cheEditor
  1. Using the browser's DevTools, make sure that WebView IFRAME content is loaded through the webviews Che endpoint, but not through the theia Che endpoint. Also, make sure that the Welcome page is rendered and works correctly, e.g. the links are working.

PR Checklist

As the author of this Pull Request I made sure that:

Reviewers

Reviewers, please comment how you tested the PR when approving it.

Happy Path Channel

HAPPY_PATH_CHANNEL=stable

Signed-off-by: Artem Zatsarynnyi <[email protected]>
@che-bot
Copy link
Contributor

che-bot commented Nov 30, 2020

✅ E2E Happy path tests succeed 🎉

Try Che-Theia editor only Try Che-Theia with Java/maven example Try Che-Theia with NodeJs example

See Details

name link
che-theia docker.io/maxura/che-theia:940
che-theia-endpoint-runtime-binary docker.io/maxura/che-theia-endpoint-runtime-binary:940

Tested with Eclipse Che Single User on K8S (minikube v1.1.1)

  • Use comment "[crw-ci-test]" to rerun happy path E2E test.
  • Use comment "[crw-ci-test --rebuild]" to re-build the images and rerun happy path E2E test.

@azatsarynnyy
Copy link
Member Author

Added Devfile for testing.

Copy link
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

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

image

iframe served by the webview endpoint

@azatsarynnyy azatsarynnyy merged commit 6bcf834 into master Nov 30, 2020
@azatsarynnyy azatsarynnyy deleted the web-view-endpoint branch November 30, 2020 13:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants