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

refactor jupyterhub user token retrieval within pytest #2645

Merged
merged 6 commits into from
Aug 30, 2024

Conversation

viniciusdc
Copy link
Contributor

Reference Issues or PRs

closes #2643
closes #2641

What does this implement/fix?

  • Includes two new parameters to paramiko ssh client to resolve issues with authentication keys when running tests locally;
  • Include CookieConflictError exception to handle duplicate cookies entries during jupyterhub authentication;
  • Add a new function to generate new jupyterhub user access tokens using the previous one; this reduces the requirement to simulate the whole user authentication workflow only once. Thus, we rely solely on jupytehrub API for all subsequent token requests.
  • Include a fixture/decorator to speed up new token generation for each test

Put a x in the boxes that apply

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds a feature)
  • Breaking change (fix or feature that would cause existing features not to work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build related changes
  • Other (please describe):

Testing

  • Did you test the pull request locally?
  • Did you add new tests?

Any other comments?

@viniciusdc viniciusdc added the needs: review 👀 This PR is complete and ready for reviewing label Aug 28, 2024
@viniciusdc
Copy link
Contributor Author

pytests are passing, playwright-related tests should be fixed by #2644, though I expect this PR to be merged first

tests/tests_deployment/test_jupyterhub_ssh.py::test_simple_jupyterhub_ssh 
-------------------------------- live log setup --------------------------------
2024-08-28 01:47:28      INFO 1923 transport: Connected (version 2.0, client AsyncSSH_2.13.2)
2024-08-28 01:47:28      INFO 1923 transport: Auth banner: b'Starting your server...'
2024-08-28 01:47:29      INFO 1923 transport: Auth banner: b'.'
...
2024-08-28 01:47:36      INFO 1923 transport: Auth banner: b'.'
2024-08-28 01:47:[37](https://github.com/nebari-dev/nebari/actions/runs/10588577627/job/29341302387?pr=2645#step:16:38)      INFO 1923 transport: Auth banner: b'.'
...
2024-08-28 01:47:47      INFO 1923 transport: Auth banner: b'.'
2024-08-28 01:47:47      INFO 1923 transport: Auth banner: b'done!\n'
2024-08-28 01:47:47      INFO 1923 transport: Authentication (password) successful!
PASSED
tests/tests_deployment/test_jupyterhub_ssh.py::test_print_jupyterhub_ssh 
-------------------------------- live log setup --------------------------------
2024-08-28 01:47:47      INFO 1923 transport: Connected (version 2.0, client AsyncSSH_2.13.2)
2024-08-28 01:47:47      INFO 1923 transport: Authentication (password) successful!

and

tests/tests_deployment/test_grafana_api.py::test_grafana_api_not_accessible_with_default_credentials PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_jupyterhub_loads_roles_from_keycloak PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_default_user_role_scopes[get-default-scopes] PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_check_default_roles_added_in_keycloak PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_keycloak_roles_attributes_parsed_as_jhub_scopes[jupyterhub-read:users:shares,read:groups:shares,users:shares-expected_scopes_difference0-before-role-creation-and-assignment] PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_keycloak_roles_attributes_parsed_as_jhub_scopes[invalid-component-read:users:shares,read:groups:shares,users:shares-expected_scopes_difference1-before-role-creation-and-assignment] PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_keycloak_roles_attributes_parsed_as_jhub_scopes[invalid-component-admin:invalid-scope-expected_scopes_difference2-before-role-creation-and-assignment] PASSED
tests/tests_deployment/test_jupyterhub_api.py::test_jupyterhub_loads_groups_from_keycloak PASSED

Copy link
Member

@marcelovilla marcelovilla left a comment

Choose a reason for hiding this comment

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

Thanks @viniciusdc !

@viniciusdc
Copy link
Contributor Author

blocked by #2672

@viniciusdc viniciusdc merged commit 1dfe968 into nebari-dev:develop Aug 30, 2024
10 checks passed
@viniciusdc viniciusdc deleted the 2643-cookie-conflict branch August 30, 2024 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: review 👀 This PR is complete and ready for reviewing
Projects
None yet
2 participants