Skip to content

test(api): test automation for the Remediation endpoint - #1204

Open
matejnesuta wants to merge 5 commits into
guacsec:mainfrom
matejnesuta:remediations
Open

test(api): test automation for the Remediation endpoint#1204
matejnesuta wants to merge 5 commits into
guacsec:mainfrom
matejnesuta:remediations

Conversation

@matejnesuta

@matejnesuta matejnesuta commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR contains API tests for the Remediation feature.

Related Issues

https://redhat.atlassian.net/browse/TC-3755

Type of Change

Tests

Summary by Sourcery

Add end-to-end API tests for vulnerability remediation responses, covering all remediation categories and version range behavior.

Tests:

  • Add e2e tests for /api/v3/vulnerability/analyze to validate remediation categories, URLs, data payloads, and multi-PURL behavior for a synthetic CVE.
  • Introduce a CSAF advisory dataset for CVE-2024-99999 to drive remediation-related API testing.

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Adds end-to-end API tests for the Remediations behavior of POST /api/v3/vulnerability/analyze, validating remediation categories, URLs, data payloads, multi-remediation behavior, and version range handling against synthetic CSAF advisory data.

File-Level Changes

Change Details Files
Add focused API e2e tests covering remediation categories, URLs, data payloads, multi-remediation entries, and version range semantics for synthetic CVE data.
  • Define shared constants for analyze endpoint, synthetic advisory/CVE identifiers, multi-remediation PURL, and remediation test cases across five categories.
  • Implement helper function to locate the synthetic CVE entry and remediation status for a given PURL in the analyze API response, asserting presence of expected advisory and data shape.
  • Add parameterized tests to assert each remediation category is returned as expected for its PURL and CVE, including status and single-remediation constraints.
  • Add tests verifying URL behavior for remediations, including null URL when absent in CSAF, presence of errata URL for vendor_fix, and raw CSAF fields preserved in data.
  • Add tests for multi-remediation PURL returning both vendor_fix and workaround categories, multi-PURL requests returning all five categories, and version_range exactly matching the affected version with inclusive bounds.
e2e/tests/api/features/remediations.ts
Introduce synthetic CSAF advisory dataset for REMEDIATIONS-CVE-2024-99999 used by the remediation tests.
  • Add CSAF advisory JSON fixture for synthetic CVE-2024-99999 to drive remediation behavior in the analyze API tests.
e2e/tests/common/dataset/advisory/csaf/REMEDIATIONS-CVE-2024-99999.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The findSyntheticPurlStatus helper uses Record<string, any> and inline object casts; consider introducing a lightweight response type interface so the test assertions remain type-safe and easier to refactor.
  • Several long string literals (purls, details text, URLs) are duplicated between the dataset and tests; centralizing these in a shared fixture or constants file would reduce brittleness if the synthetic data changes.
  • The communityPurl fields in remediationCases are currently unused; if they are not needed for future assertions, remove them to avoid confusion, or add a test that explicitly validates the community PURL behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `findSyntheticPurlStatus` helper uses `Record<string, any>` and inline object casts; consider introducing a lightweight response type interface so the test assertions remain type-safe and easier to refactor.
- Several long string literals (purls, details text, URLs) are duplicated between the dataset and tests; centralizing these in a shared fixture or constants file would reduce brittleness if the synthetic data changes.
- The `communityPurl` fields in `remediationCases` are currently unused; if they are not needed for future assertions, remove them to avoid confusion, or add a test that explicitly validates the community PURL behavior.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@matejnesuta matejnesuta changed the title Remediations test(api): test automation for the Remediation endpoint Aug 12, 2026
@matejnesuta
matejnesuta requested review from queria and vobratil August 12, 2026 17:01
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.13%. Comparing base (1d0914c) to head (ed0c384).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1204   +/-   ##
=======================================
  Coverage   54.13%   54.13%           
=======================================
  Files         255      255           
  Lines        5715     5715           
  Branches     1774     1774           
=======================================
  Hits         3094     3094           
  Misses       2356     2356           
  Partials      265      265           
Flag Coverage Δ
e2e 70.29% <ø> (ø)
unit 8.65% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant