fix: [tests] Comment on an existing vulnerability, not a hardcoded CVE#97
Merged
Merged
Conversation
Vulnerability-Lookup now rejects comment creation when the target vulnerability is absent from storage (added in vulnerability-lookup#497). The two local comment tests hardcoded CVE-2024-20401, which the CI sample instance never imports, so create_comment returned 404 'Vulnerability not found'. Fetch a vulnerability actually present in the instance via get_last(source='pysec', number=1) and comment on it (the CI instance loads pysec). The test skips if no vulnerability is available. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #96. Vulnerability-Lookup now rejects comment creation when the commented-on vulnerability is not present in storage — added in vulnerability-lookup#497 (
comment.py:385, returns404 "Vulnerability not found."). The two local comment tests hardcodedCVE-2024-20401, which the CI sample instance never imports (it loads pysec advisories), socreate_commentreturned an error dict and the tests failed withKeyError: 'data'.Change
test_comments_localandtest_create_user_commentnow fetch a vulnerability the instance actually has —get_last(source="pysec", number=1)(the same calltest_get_lastalready relies on) — and comment on its id instead of a hardcoded CVE. If no vulnerability is available the test skips (return None), consistent with the existing guards in this file.Left untouched:
test_get_comments_public(runs only against the public instance, where the seeded comments exist) and the sightings/EPSS tests (sighting creation has no existence check and never failed). Only the primaryvulnerabilityfield is existence-checked, so therelated_vulnerabilitiesliterals stay as-is.Notes
This is a test-side adaptation to the intended new API behaviour (comments must attach to a known vulnerability), not a change to the client library, which continues to work unchanged.
🤖 Generated with Claude Code