Skip to content

Commit

Permalink
plan: fix error when variable is not set
Browse files Browse the repository at this point in the history
There is a corner case scenario where we end up with a
src_pocket_pkgs variable unset. We are now fixing this issue
by using a default value for this variable
  • Loading branch information
lucasmoura authored and orndorffgrant committed Oct 24, 2023
1 parent 6f16cd6 commit 00bf3dc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions features/api_fix_plan.feature
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,19 @@ Feature: Fix plan API endpoints
Examples: ubuntu release details
| release |
| bionic |

@series.mantic
@uses.config.machine_type.lxd-vm
Scenario Outline: Fix command on an unattached machine
Given a `<release>` machine with ubuntu-advantage-tools installed
When I run `pro api u.pro.security.fix.cve.plan.v1 --data '{"cves": ["CVE-2022-40982"]}'` as non-root
Then stdout is a json matching the `api_response` schema
And the json API response data matches the `cve_fix_plan` schema
And stdout matches regexp:
"""
{"_schema_version": "v1", "data": {"attributes": {"cves_data": {"cves": \[{"additional_data": {}, "affected_packages": \["linux"\], "description": ".*", "error": null, "expected_status": "still-affected", "plan": \[\], "title": "CVE-2022-40982", "warnings": \[{"data": {"source_packages": \["linux"\], "status": "pending"}, "order": 1, "warning_type": "security-issue-not-fixed"}\]}\], "expected_status": "still-affected"}}, "meta": {"environment_vars": \[\]}, "type": "CVEFixPlan"}, "errors": \[\], "result": "success", "version": ".*", "warnings": \[\]}
"""

Examples: ubuntu release details
| release |
| mantic |
2 changes: 2 additions & 0 deletions uaclient/api/u/pro/security/fix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,8 @@ def _generate_fix_plan(
additional_data=None
) -> FixPlanResult:
count = len(affected_pkg_status)
src_pocket_pkgs = defaultdict(list)

fix_plan = get_fix_plan(
title=issue_id,
description=issue_description,
Expand Down

0 comments on commit 00bf3dc

Please sign in to comment.