Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2412 from jeremycline/allow-content-too
Browse files Browse the repository at this point in the history
Allow xsendfile to serve /var/lib/pulp/content.
  • Loading branch information
jeremycline committed Feb 11, 2016
2 parents a97c76d + e74bd62 commit 1ea25b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions server/pulp/server/content/web/views.py
Expand Up @@ -11,8 +11,9 @@
from pulp.server.config import config as pulp_conf


# Make sure all requested paths fall under this directory.
# Make sure all requested paths fall under these directories.
PUBLISH_DIR = '/var/lib/pulp/published'
CONTENT_DIR = '/var/lib/pulp/content'


class ContentView(View):
Expand Down Expand Up @@ -141,7 +142,7 @@ def get(self, request):
# Not Authorized
return HttpResponseForbidden()

if not path.startswith(PUBLISH_DIR):
if not path.startswith(PUBLISH_DIR) and not path.startswith(CONTENT_DIR):
# Someone is requesting something they shouldn't.
return HttpResponseForbidden()

Expand Down
4 changes: 2 additions & 2 deletions server/test/unit/server/content/web/test_views.py
Expand Up @@ -152,7 +152,7 @@ def test_get_x_send(self, x_send, allow_access, exists, realpath):
def test_get_redirected(self, redirect, allow_access, mock_conf_get, exists, realpath):
allow_access.return_value = True
exists.return_value = False
realpath.side_effect = lambda p: '/var/lib/pulp/published/content'
realpath.side_effect = lambda p: '/var/lib/pulp/content/rpm'

host = 'localhost'
path = '/var/www/pub/content'
Expand All @@ -167,7 +167,7 @@ def test_get_redirected(self, redirect, allow_access, mock_conf_get, exists, rea
# validation
allow_access.assert_called_once_with(request.environ, host)
realpath.assert_called_once_with(path)
exists.assert_has_call('/var/lib/pulp/published/content')
exists.assert_has_call('/var/lib/pulp/content/rpm')
self.assertTrue(exists.call_count > 0)
redirect.assert_called_once_with(request, view.key)
self.assertEqual(reply, redirect.return_value)
Expand Down

0 comments on commit 1ea25b0

Please sign in to comment.