Skip to content

Commit 7bfc6c8

Browse files
author
saville
committed
Remove deploy key usage and instead use temporary SSH key
1 parent 1b4c6f9 commit 7bfc6c8

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

tests/test_buildrunner_files.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,27 @@
2626
@pytest.fixture(autouse=True, scope="session")
2727
def setup_buildrunner_test_ssh_key():
2828
key_file_path = Path(TEST_SSH_KEY_FILE)
29-
key_file_path.unlink(missing_ok=True)
30-
subprocess.run(
31-
[
32-
"ssh-keygen",
33-
"-t",
34-
"ecdsa",
35-
"-m",
36-
"PEM",
37-
"-N",
38-
"",
39-
"-f",
40-
TEST_SSH_KEY_FILE,
41-
],
42-
check=True,
43-
)
29+
pub_key_file_path = Path(f"{TEST_SSH_KEY_FILE}.pub")
30+
if not key_file_path.exists():
31+
subprocess.run(
32+
[
33+
"ssh-keygen",
34+
"-t",
35+
"ecdsa",
36+
"-m",
37+
"PEM",
38+
"-N",
39+
"",
40+
"-f",
41+
TEST_SSH_KEY_FILE,
42+
],
43+
check=True,
44+
)
4445
# Set the public key in an environment variable to use in the test buildrunner files
45-
os.environ["BUILDRUNNER_TEST_SSH_PUB_KEY"] = (
46-
Path(f"{TEST_SSH_KEY_FILE}.pub").read_text().strip()
47-
)
46+
os.environ["BUILDRUNNER_TEST_SSH_PUB_KEY"] = pub_key_file_path.read_text().strip()
4847
yield
4948
# Cleanup
5049
del os.environ["BUILDRUNNER_TEST_SSH_PUB_KEY"]
51-
key_file_path.unlink()
5250

5351

5452
def _get_test_args(file_name: str) -> Optional[List[str]]:

0 commit comments

Comments
 (0)