Skip to content

Commit 50b56bb

Browse files
authored
Merge pull request #968 from GitGuardian/agateau/post-release-fixes
Post-release fixes
2 parents 589aa14 + 6ef1006 commit 50b56bb

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

scripts/hmsl/hashicorp_vault.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
ROOT_TOKEN = "my_vault_token"
1616
RESTRICTED_TOKEN = "restricted_token"
1717

18+
READY_TRIES = 20
19+
1820

1921
logger = logging.getLogger(__name__)
2022
logging.basicConfig(
@@ -29,8 +31,7 @@ def wait_for_server_to_be_ready() -> None:
2931
3032
If timeout elapsed, a RuntimeError is raised.
3133
"""
32-
tries = 0
33-
while tries < 10:
34+
for tries in range(READY_TRIES):
3435
check_cmd_ret = subprocess.run(
3536
[
3637
"docker",
@@ -46,11 +47,12 @@ def wait_for_server_to_be_ready() -> None:
4647

4748
if "(healthy)" in json_status["Status"]:
4849
logger.debug("Server is healthy")
49-
return True
50+
return
5051

51-
logger.debug("Server not healthy yet, waiting...")
52+
logger.debug(
53+
"Server not healthy yet, waiting... (%d / %d)", tries + 1, READY_TRIES
54+
)
5255
time.sleep(0.500)
53-
tries += 1
5456

5557
raise RuntimeError("Hashicorp Vault server is not ready")
5658

tests/functional/secret/test_scan_prereceive.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import logging
2-
import os
32
from pathlib import Path
43
from subprocess import CalledProcessError
5-
from unittest.mock import patch
64

75
import pytest
86

@@ -106,7 +104,7 @@ def test_scan_prereceive_push_force(tmp_path: Path) -> None:
106104

107105

108106
def test_scan_prereceive_timeout(
109-
tmp_path: Path, slow_gitguardian_api: str, caplog
107+
tmp_path: Path, monkeypatch, slow_gitguardian_api: str, caplog
110108
) -> None:
111109
# GIVEN a remote repository
112110
remote_repo = Repository.create(tmp_path / "remote", bare=True)
@@ -128,9 +126,9 @@ def test_scan_prereceive_timeout(
128126

129127
# WHEN I try to push
130128
# THEN the hook timeouts and allows the push
131-
with patch.dict(
132-
os.environ, {**os.environ, "GITGUARDIAN_API_URL": slow_gitguardian_api}
133-
), caplog.at_level(logging.WARNING):
129+
with caplog.at_level(logging.WARNING):
130+
monkeypatch.setenv("GITGUARDIAN_API_URL", slow_gitguardian_api)
131+
monkeypatch.delenv("GITGUARDIAN_INSTANCE", raising=False)
134132
local_repo.push()
135133

136134
# AND the error message contains timeout message

0 commit comments

Comments
 (0)