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

Allow specifying the ssh key for the tests and loosen fallbacks to default ssh key #6563

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

agoscinski
Copy link
Contributor

@agoscinski agoscinski commented Sep 11, 2024

This PR allows to specify a ssh key that is used in the tests by the environment variable AIIDA_PYTEST_SSH_KEY. Using ~/.ssh/id_rsa as key and not specifying the environment variable still should work as the fallbacks should start to work.

The tests were relying on ~/.ssh/id_rsa to be used to allow ssh to localhost. This had the side effect that several tests specified a ssh key in their configuration that was then not working in the authentication. A fallback to the default ssh key still allowed the tests to pass. Because of these fallbacks several tests had to be adapted.

I am must say in hindsight this is not super useful, but I like that the tests do actually use the ssh key that is specified as this is nowhere mentioned and a bit confusing when adapting these parts of the code.

Requires #6450 to be merged before.

agoscinski and others added 2 commits September 11, 2024 18:14
The tests were relying on `~/.ssh/id_rsa` to be used to allow ssh to
localhost. This had the side effect that several tests specified a ssh
key in their configuration that was then not working in the
authentication but a fall back to the default ssh key still allowed a
connection. This PR fixes this behaviour and uses also the ssh key
specified for the connection. This also allows the user to specify a
dedicated ssh key for aiida tests and does not enforce the usage of the
default key.
@agoscinski agoscinski changed the title Tests/pass ssh key Allow specifying the ssh key for the tests and remove fallbacks to default ssh key Sep 11, 2024
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 7.89474% with 35 lines in your changes missing coverage. Please review.

Project coverage is 77.81%. Comparing base (ef60b66) to head (c3c259e).
Report is 112 commits behind head on main.

Files with missing lines Patch % Lines
src/aiida/manage/tests/pytest_fixtures.py 0.00% 18 Missing ⚠️
src/aiida/tools/pytest_fixtures/orm.py 15.00% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6563      +/-   ##
==========================================
+ Coverage   77.51%   77.81%   +0.30%     
==========================================
  Files         560      566       +6     
  Lines       41444    41988     +544     
==========================================
+ Hits        32120    32667     +547     
+ Misses       9324     9321       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@agoscinski agoscinski changed the title Allow specifying the ssh key for the tests and remove fallbacks to default ssh key Allow specifying the ssh key for the tests and loosen fallbacks to default ssh key Sep 11, 2024
"""Returns a SSH key for the test session.

If the environment variable ``AIIDA_PYTEST_SSH_KEY`` is set we take the key from this path otherwise we generate a
temporary SSH key pair for the test session and return the filepath of the private key.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
temporary SSH key pair for the test session and return the filepath of the private key.
temporary SSH key pair for the test session and return the filepath of the private key. The temporary key cannot be used to connect to localhost as it is not authorized, therefore it is required that the default ssh key `~/.ssh/id_rsa`is authorized to connect to localhost to automatically fallback.

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.

1 participant