Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resource_read should 404 with wrong params
When resource read is called with wrong params, it can be manipulated to show that a resource belongs to the wrong package causing to overall confusion.
- Loading branch information
nigelb
committed
May 12, 2014
1 parent
be179c5
commit 9b5f411
Showing
4 changed files
with
56 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from nose.tools import assert_equal | ||
from routes import url_for as url_for | ||
|
||
from ckan.new_tests.controllers import WsgiAppCase | ||
import ckan.new_tests.factories as factories | ||
import ckan.new_tests.helpers as helpers | ||
import ckan.lib.search as search | ||
|
||
|
||
class TestResourceRead(WsgiAppCase): | ||
|
||
@classmethod | ||
def setup_class(cls): | ||
helpers.reset_db() | ||
|
||
def setup(self): | ||
import ckan.model as model | ||
|
||
# Reset the db before each test method. | ||
model.repo.rebuild_db() | ||
|
||
# Clear the search index | ||
search.clear() | ||
|
||
def test_existing_resource_with_associated_package(self): | ||
new_package = factories.Dataset() | ||
resource = factories.Resource(package_id=new_package['id']) | ||
response = self.app.get( | ||
url=url_for(controller='package', action='resource_read', | ||
id=new_package['id'], resource_id=resource['id']), | ||
status=200, | ||
) | ||
|
||
def test_existing_resource_with_package_not_associated(self): | ||
new_package = factories.Dataset() | ||
resource = factories.Resource() | ||
response = self.app.get( | ||
url=url_for(controller='package', action='resource_read', | ||
id=new_package['id'], resource_id=resource['id']), | ||
status=404, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters