Skip to content

Commit

Permalink
lower timeout to 30s and add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcusk19 committed Sep 5, 2024
1 parent a59a565 commit 253bfd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion util/secscan/v4/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
logger = logging.getLogger(__name__)

DOWNLOAD_VALIDITY_LIFETIME_S = 60 # Amount of time the security scanner has to call the layer URL
DEFAULT_REQUEST_TIMEOUT = 180
DEFAULT_REQUEST_TIMEOUT = 30
INDEX_REQUEST_TIMEOUT = 600


Expand Down
9 changes: 9 additions & 0 deletions util/secscan/v4/test/test_secscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from mock import patch
from requests.exceptions import Timeout

from app import instance_keys, storage
from config import build_requests_session
Expand Down Expand Up @@ -101,3 +102,11 @@ def test_vulnerability_report_incompatible_api_response(api, initialized_db):
layers = registry_model.list_manifest_layers(manifest, storage, True)

api.vulnerability_report(manifest.digest)


def test_vulnerability_report_timeout(api, initialized_db):
with fake_security_scanner() as security_scanner:
with pytest.raises(APIRequestFailure):
with patch.object(api._client, "request", side_effect=Timeout):
manifest = manifest_for("devtable", "simple", "latest")
api.vulnerability_report(manifest.digest)

0 comments on commit 253bfd7

Please sign in to comment.