Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Security/hardcoded s3 #1197

Merged
merged 4 commits into from
Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cadasta/config/settings/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,8 @@
}
}

ICON_URL = ('https://s3-us-west-2.amazonaws.com/cadasta-platformprod'
'-bucket/icons/{}.png')
ICON_URL = ('https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/{}.png')

ICON_LOOKUPS = {
'application/pdf': 'pdf',
Expand Down
6 changes: 3 additions & 3 deletions cadasta/resources/tests/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def setUpBeforeMigration(self, apps_before):
project = Project.objects.create(name='Test Proj', organization=org)

base_path = (
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-bucket/'
'https://s3-us-west-2.amazonaws.com/cadasta-resources/'
)

# cannot call custom save methods on models in migrations
Expand All @@ -97,7 +97,7 @@ def test_migration(self):
resources = Resource.objects.filter(mime_type='text/csv')
assert len(resources) == 10
base_path = (
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-bucket/'
'https://s3-us-west-2.amazonaws.com/cadasta-resources/'
)
resource = Resource.objects.get(name='test-resource-0')
assert resource.file.url == base_path + 'resources/test_0.csv'
Expand All @@ -118,7 +118,7 @@ def setUpBeforeMigration(self, apps_before):
project = Project.objects.create(name='Test Proj', organization=org)

base_path = (
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-bucket/'
'https://s3-us-west-2.amazonaws.com/cadasta-resources/'
'resources/'
)

Expand Down
48 changes: 24 additions & 24 deletions cadasta/resources/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,59 +64,59 @@ def test_thumbnail_pdf(self):
mime_type='application/pdf'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/pdf.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/pdf.png')

def test_thumbnail_mp3(self):
resource = ResourceFactory.build(
file='http://example.com/dir/filename.mp3',
mime_type='audio/mpeg3'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/mp3.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/mp3.png')

resource = ResourceFactory.build(
file='http://example.com/dir/filename.mp3',
mime_type='audio/x-mpeg-3'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/mp3.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/mp3.png')

resource = ResourceFactory.build(
file='http://example.com/dir/filename.mp3',
mime_type='video/mpeg'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/mp3.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/mp3.png')

resource = ResourceFactory.build(
file='http://example.com/dir/filename.mp3',
mime_type='video/x-mpeg'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/mp3.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/mp3.png')

def test_thumbnail_mp4(self):
resource = ResourceFactory.build(
file='http://example.com/dir/filename.mp4',
mime_type='video/mp4'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/mp4.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/mp4.png')

def test_thumbnail_doc(self):
resource = ResourceFactory.build(
file='http://example.com/dir/filename.doc',
mime_type='application/msword'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/doc.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/doc.png')

def test_thumbnail_docx(self):
resource = ResourceFactory.build(
Expand All @@ -125,25 +125,25 @@ def test_thumbnail_docx(self):
'wordprocessingml.document')
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/docx.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/docx.png')

def test_thumbnail_xls(self):
resource = ResourceFactory.build(
file='http://example.com/dir/filename.doc',
mime_type='application/msexcel'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/xls.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/xls.png')

resource = ResourceFactory.build(
file='http://example.com/dir/filename.doc',
mime_type='application/vnd.ms-excel'
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/xls.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/xls.png')

def test_thumbnail_xlsx(self):
resource = ResourceFactory.build(
Expand All @@ -152,16 +152,16 @@ def test_thumbnail_xlsx(self):
'.spreadsheetml.sheet')
)
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/xlsx.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/xlsx.png')

def test_thumbnail_xml(self):
resource = ResourceFactory.build(
file='http://example.com/dir/filename.gpx',
mime_type=('text/xml'))
assert (resource.thumbnail ==
'https://s3-us-west-2.amazonaws.com/cadasta-platformprod-'
'bucket/icons/xml.png')
'https://s3-us-west-2.amazonaws.com/cadasta-resources'
'/icons/xml.png')

def test_thumbnail_other(self):
resource = ResourceFactory.build(
Expand Down