Esempio n. 1
0
class RetrieveTestsWithPublicBucket(BaseTestMixin, TestCase):
    def setUp(self):
        self.media_storage = MinioMediaStorage()
        self.static_storage = MinioStaticStorage()
        self.new_file = self.media_storage.save("test-file",
                                                ContentFile(b"yep"))

        self.media_storage.client.set_bucket_policy(
            self.media_storage.bucket_name,
            self.media_storage._policy("READ_WRITE"))

        self.static_storage.client.set_bucket_policy(
            self.static_storage.bucket_name,
            self.static_storage._policy("READ_WRITE"))

    def test_public_url_generation(self):
        media_test_file_name = self.media_storage.save(
            u"weird & ÜRΛ", ContentFile(b"irrelevant"))
        url = self.media_storage.url(media_test_file_name)
        res = requests.get(url)
        self.assertEqual(res.content, b"irrelevant")

        static_test_file_name = self.static_storage.save(
            u"weird & ÜRΛ", ContentFile(b"irrelevant"))
        url = self.static_storage.url(static_test_file_name)
        res = requests.get(url)
        self.assertEqual(res.content, b"irrelevant")
class RetrieveTestsWithPublicBucket(BaseTestMixin, TestCase):

    def setUp(self):
        self.media_storage = MinioMediaStorage()
        self.static_storage = MinioStaticStorage()
        self.new_file = self.media_storage.save("test-file",
                                                ContentFile(b"yep"))

        self.media_storage.client.set_bucket_policy(
            self.media_storage.bucket_name,
            self.media_storage._policy("READ_WRITE")
        )

        self.static_storage.client.set_bucket_policy(
            self.static_storage.bucket_name,
            self.static_storage._policy("READ_WRITE")
        )

    def test_public_url_generation(self):
        media_test_file_name = self.media_storage.save(
            u"weird & ÜRΛ", ContentFile(b"irrelevant"))
        url = self.media_storage.url(media_test_file_name)
        res = requests.get(url)
        self.assertEqual(res.content, b"irrelevant")

        static_test_file_name = self.static_storage.save(
            u"weird & ÜRΛ", ContentFile(b"irrelevant"))
        url = self.static_storage.url(static_test_file_name)
        res = requests.get(url)
        self.assertEqual(res.content, b"irrelevant")
Esempio n. 3
0
 def setUp(self):
     self.media_storage = MinioMediaStorage()
     self.static_storage = MinioStaticStorage()
     self.new_file = self.media_storage.save("test-file",
                                             ContentFile(b"yep"))
     self.media_storage.client.set_bucket_policy(
         self.media_storage.bucket_name, '', Policy.READ_WRITE)
     self.static_storage.client.set_bucket_policy(
         self.static_storage.bucket_name, '', Policy.READ_WRITE)
Esempio n. 4
0
    def test_public_url_generation(self):
        media_storage = MinioMediaStorage()
        media_test_file_name = media_storage.save("weird & ÜRΛ",
                                                  ContentFile(b"irrelevant"))
        url = media_storage.url(media_test_file_name)
        res = requests.get(url)
        self.assertEqual(res.content, b"irrelevant")

        static_storage = MinioStaticStorage()
        static_test_file_name = static_storage.save("weird & ÜRΛ",
                                                    ContentFile(b"irrelevant"))
        url = static_storage.url(static_test_file_name)
        res = requests.get(url)
        self.assertEqual(res.content, b"irrelevant")
Esempio n. 5
0
 def setUp(self):
     self.media_storage = MinioMediaStorage()
     self.static_storage = MinioStaticStorage()
     self.new_file = self.media_storage.save("test-file",
                                             ContentFile(b"yep"))
     self.second_file = self.media_storage.save("test-file",
                                                ContentFile(b"nope"))
 def test_static_storage_ignore_bucket_check(self):
     try:
         MinioStaticStorage()
     except OSError:
         self.assertTrue(False)
     else:
         pass
    def setUp(self):
        self.media_storage = MinioMediaStorage()
        self.static_storage = MinioStaticStorage()
        self.new_file = self.media_storage.save("test-file",
                                                ContentFile(b"yep"))

        self.media_storage.client.set_bucket_policy(
            self.media_storage.bucket_name,
            self.media_storage._policy("READ_WRITE")
        )

        self.static_storage.client.set_bucket_policy(
            self.static_storage.bucket_name,
            self.static_storage._policy("READ_WRITE")
        )
Esempio n. 8
0
 def test_static_storage_ignore_bucket_check(self):
     MinioStaticStorage()
Esempio n. 9
0
 def test_static_storage_cannot_be_initialized_without_bucket(self):
     with self.assertRaises(OSError):
         MinioStaticStorage()
Esempio n. 10
0
 def setUp(self):
     self.media_storage = MinioMediaStorage()
     self.static_storage = MinioStaticStorage()
     self.new_file = self.media_storage.save("a new & original file",
                                             ContentFile(b"yep"))