Project

Profile

Help

Issue #827

closed

Retrieve all/single content source url should accept only GET

Added by ipanova@redhat.com almost 9 years ago. Updated almost 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Category:
-
Sprint/Milestone:
-
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
2.7.0
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Easy Fix, Pulp 2
Sprint:
Quarter:

Description

Currently we have Views that are sharing more than one url, this causes the situation when url accepts other methods than the allowed one. One of the solution would be to slpit and have one url per View.

$ curl -i -H "Accept: application/json" -H "WebFrameworkSwitch: django" -X GET -k -u admin:admin  "https://localhost/pulp/api/v2/content/sources/"
HTTP/1.1 200 OK
Date: Tue, 31 Mar 2015 11:33:03 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.5 Python/2.7.5
Content-Length: 694
Content-Type: application/json

[{"name": "Content World", "url": "/x86_64/os/", "max_concurrent": "10", "ssl_validation": "true", "expires": "3d", "enabled": "1", "base_url": "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/", "priority": "0", "max_speed": "1000", "source_id": "content-zoo222", "type": "yum", "_href": "/pulp/api/v2/content/sources/content-zoo222/"}, {"name": "Content World", "url": "/x86_64/os/", "max_concurrent": "10", "ssl_validation": "true", "expires": "3d", "enabled": "1", "base_url": "http://repos.fedorapeople.org/repos/pulp/pulp/demo_repos/zoo/", "priority": "0", "max_speed": "1000", "source_id": "content-zoo", "type": "yum", "_href": "/pulp/api/v2/content/sources/content-zoo/"}][ipanova@ina pulp]$ 

$ curl -i -H "Accept: application/json" -H "WebFrameworkSwitch: django" -X PUT -k -u admin:admin  "https://localhost/pulp/api/v2/content/sources/"
HTTP/1.1 405 METHOD NOT ALLOWED
Date: Tue, 31 Mar 2015 11:33:13 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.5 Python/2.7.5
Allow: GET, POST, HEAD, OPTIONS
Content-Length: 0
Content-Type: text/html; charset=utf-8

[ipanova@ina pulp]$ curl -i -H "Accept: application/json" -H "WebFrameworkSwitch: django" -X POST -k -u admin:admin  "https://localhost/pulp/api/v2/content/sources/"
HTTP/1.1 500 INTERNAL SERVER ERROR
Date: Tue, 31 Mar 2015 11:33:25 GMT
Server: Apache/2.4.10 (Fedora) OpenSSL/1.0.1e-fips mod_wsgi/3.5 Python/2.7.5
Content-Encoding: utf-8
Content-Length: 1275
Connection: close
Content-Type: application/json

{"http_request_method": "POST", "exception": ["TypeError: post() takes exactly 3 arguments (2 given)\n"], "error_message": "post() takes exactly 3 arguments (2 given)", "_href": "/pulp/api/v2/content/sources/", "http_status": 500, "traceback": ["  File \"/usr/lib/python2.7/site-packages/django/core/handlers/base.py\", line 112, in get_response\n    response = wrapped_callback(request, *callback_args, **callback_kwargs)\n", "  File \"/usr/lib/python2.7/site-packages/django/views/generic/base.py\", line 69, in view\n    return self.dispatch(request, *args, **kwargs)\n", "  File \"/usr/lib/python2.7/site-packages/django/views/generic/base.py\", line 87, in dispatch\n    return handler(request, *args, **kwargs)\n", "  File \"/home/ipanova/pulp_development/pulp/server/pulp/server/webservices/controllers/decorators.py\", line 241, in _auth_decorator\n    return _verify_auth(self, operation, super_user_only, method, *args, **kwargs)\n", "  File \"/home/ipanova/pulp_development/pulp/server/pulp/server/webservices/controllers/decorators.py\", line 195, in _verify_auth\n    value = method(self, *args, **kwargs)\n", "  File \"/home/ipanova/pulp_development/pulp/server/pulp/server/webservices/views/util.py\", line 83, in wrapper\n    return func(*args, **kwargs)\n"]}

pulp/api/v2/content/sources/ and pulp/api/v2/content/action/refresh share same View
pulp/api/v2/content/sources/<source_id/ and pulp/api/v2/content/sources/<source-id>/action/refresh share same View

Also available in: Atom PDF