Bug 1104106

Summary: Before doing import content into a repo the posted data should be checked for presence and content of required keys
Product: [Retired] Pulp Reporter: Ina Panova <ipanova>
Component: API/integrationAssignee: pulp-bugs
Status: CLOSED UPSTREAM QA Contact: pulp-qe-list
Severity: unspecified Docs Contact:
Priority: medium    
Version: unspecifiedCC: skarmark
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-02-28 22:09:41 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1104148    

Description Ina Panova 2014-06-03 09:55:07 UTC
Description of problem:
Before doing import content into a repo the posted data should be checked for presence of required keys instead of creating an async task.


For example here I completely skipped all unit_key data:

$ curl -H "Accept: application/json" -X POST -k -u admin:admin  -d '{"unit_type_id": "iso", "upload_id": "d281d911-5231-4e2b-a865-cb669e6ce694", "unit_key":{}}' 'https://example.com/pulp/api/v2/repositories/isorepo/actions/import_upload/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   263  100   172  100    91    109     58  0:00:01  0:00:01 --:--:--   109
{
    "error": null,
    "result": null,
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/5f8aa1f1-5d77-408b-8d6f-822afaa38cf5/",
            "task_id": "5f8aa1f1-5d77-408b-8d6f-822afaa38cf5"
        }
    ]
}


Here I try to import upload into *non-existent* repo:

$ curl -H "Accept: application/json" -X POST -k -u admin:admin  -d '{"unit_type_id": "iso", "upload_id": "d281d911-5231-4e2b-a865-cb669e6ce694", "unit_key":{}}' 'https://example.com/pulp/api/v2/repositories/non-existent-repo/actions/import_upload/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   263  100   172  100    91    110     58  0:00:01  0:00:01 --:--:--   110
{
    "error": null,
    "result": null,
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/a508ba1b-c596-41e0-b768-5ed6ed418eaa/",
            "task_id": "a508ba1b-c596-41e0-b768-5ed6ed418eaa"
        }
    ]
}

Here I try to post iso unit type into an rpm type repo:

$ curl -H "Accept: application/json" -X POST -k -u admin:admin  -d '{"unit_type_id": "iso", "upload_id": "d281d911-5231-4e2b-a865-cb669e6ce694", "unit_key":{}}' 'https://example.com/pulp/api/v2/repositories/rpmrepo/actions/import_upload/'|python -m json.tool
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   263  100   172  100    91    110     58  0:00:01  0:00:01 --:--:--   110
{
    "error": null,
    "result": null,
    "spawned_tasks": [
        {
            "_href": "/pulp/api/v2/tasks/6a3b6aee-3636-4179-be96-f4a66975d669/",
            "task_id": "6a3b6aee-3636-4179-be96-f4a66975d669"
        }
    ]
}

In all these cases async tasks should NOT be created but instead have 404 or 400 code returned depending on the situation.

Version-Release number of selected component (if applicable):
2.4.0-0.19.beta

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
in the posted data presence and content of the keys are not checked

Expected results:
in the posted data presence and content of the keys are checked, and 404/400 code returned

Additional info:

Comment 1 Brian Bouterse 2015-02-28 22:09:41 UTC
Moved to https://pulp.plan.io/issues/445