Skip to content

Commit

Permalink
Fix all the Travis CI failures (#1042)
Browse files Browse the repository at this point in the history
* Fix azure test in django 2.x

* Actually fix the azure test on django 3.1+ also

* Try running a newer distro to fix pip buildchain

Trying to install `cryptography` from a wheel,
rather than building from source (which is both slow, and also fails due
to missing rustc)
  • Loading branch information
craigds authored Sep 4, 2021
1 parent 35d0b84 commit 89403af
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# https://travis-ci.org/jschneier/django-storages/
language: python
dist: focal

cache: pip

Expand Down
20 changes: 16 additions & 4 deletions tests/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
from datetime import timedelta
from unittest import mock

import django
import pytz
from azure.storage.blob import Blob, BlobPermissions, BlobProperties
from django.core.exceptions import SuspiciousOperation
from django.core.files.base import ContentFile
from django.test import TestCase, override_settings

Expand Down Expand Up @@ -109,10 +111,20 @@ def test_get_available_name_max_len(self):
def test_get_available_invalid(self):
self.storage.overwrite_files = False
self.storage._service.exists.return_value = False
self.assertRaises(ValueError, self.storage.get_available_name, "")
self.assertRaises(ValueError, self.storage.get_available_name, "/")
self.assertRaises(ValueError, self.storage.get_available_name, ".")
self.assertRaises(ValueError, self.storage.get_available_name, "///")
if django.VERSION[:2] == (3, 0):
# Django 2.2.21 added this security fix:
# https://docs.djangoproject.com/en/3.2/releases/2.2.21/#cve-2021-31542-potential-directory-traversal-via-uploaded-files
# It raises SuspiciousOperation before we get to our ValueError.
# The fix wasn't applied to 3.0 (no longer in support), but was applied to 3.1 & 3.2.
self.assertRaises(ValueError, self.storage.get_available_name, "")
self.assertRaises(ValueError, self.storage.get_available_name, "/")
self.assertRaises(ValueError, self.storage.get_available_name, ".")
self.assertRaises(ValueError, self.storage.get_available_name, "///")
else:
self.assertRaises(SuspiciousOperation, self.storage.get_available_name, "")
self.assertRaises(SuspiciousOperation, self.storage.get_available_name, "/")
self.assertRaises(SuspiciousOperation, self.storage.get_available_name, ".")
self.assertRaises(SuspiciousOperation, self.storage.get_available_name, "///")
self.assertRaises(ValueError, self.storage.get_available_name, "...")

def test_url(self):
Expand Down

0 comments on commit 89403af

Please sign in to comment.