Skip to content

Commit

Permalink
[Jupyter-Web-App]:Add basic E2E Tests (kubeflow#4773)
Browse files Browse the repository at this point in the history
* Add basic e2e tests for JWA

This test has two basic test cases for now.

* Navigate to index page and ensure that no error appeared
* Navigate to form page and ensure that no error appeared

Needs to add logic for IAP authentication

Signed-off-by: Kimonas Sotirchos <[email protected]>

* Handle IAP login logic

We need to set the driver request headers in order to allow the tests to
conect to the IAP protected cluster. For this we use the selenium-wire
which will create a proxy server which will be setting the necessary
headers.

Signed-off-by: Kimonas Sotirchos <[email protected]>
  • Loading branch information
kimwnasptd authored Apr 3, 2020
1 parent 6188f27 commit bf00f9e
Show file tree
Hide file tree
Showing 3 changed files with 467 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,7 @@ components/gcp-click-to-deploy/src/user_config/**

# This is generated by bootstrap
**/reg_tmp
scripts/gke/build/**
scripts/gke/build/**

# Created after running JWA e2e tests
**/geckodriver.log
40 changes: 40 additions & 0 deletions testing/auth.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import logging

from . import gcp_util as gcp

logging.basicConfig(
level=logging.INFO,
format=("%(levelname)s | %(lineno)d | AUTH | %(message)s"),
)


def login_to_kubeflow_iap(driver, kubeflow_url):
"""
This function logs in to the kubeflow cluster via IAP
"""
service_account_credentials = gcp.get_service_account_credentials(
"CLIENT_ID"
)
google_open_id_connect_token = gcp.get_google_open_id_connect_token(
service_account_credentials
)

driver.header_overrides = {
"Authorization": "Bearer {}".format(google_open_id_connect_token)
}

driver.get(kubeflow_url)


def login_to_kubeflow_dex(driver, kubeflow_url, username, password):
"""
This function logs in to the kubeflow cluster via DEX
"""
driver.get(kubeflow_url)
username_input = driver.find_element_by_id("login")
password_input = driver.find_element_by_id("password")
login_button = driver.find_element_by_id("submit-login")

username_input.send_keys(username)
password_input.send_keys(password)
login_button.click()
Loading

0 comments on commit bf00f9e

Please sign in to comment.