Пример #1
0
    def test_public_if_none_match(self):
        # upload object
        cname = self.create_container()[0]
        oname, odata = self.upload_object(cname)[:-1]

        # set public
        url = join_urls(self.pithos_path, self.user, cname, oname)
        r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
        self.assertEqual(r.status_code, 202)

        info = self.get_object_info(cname, oname)
        public_url = info['X-Object-Public']

        def assert_non_match(etag):
            # perform get with If-None-Match
            r = self.get(public_url, HTTP_IF_NONE_MATCH=etag)

            # assert precondition_failed
            self.assertEqual(r.status_code, 304)

            # update object data
            r = self.append_object_data(cname, oname)[-1]
            self.assertTrue(etag != r['ETag'])

            # perform get with If-None-Match
            r = self.get(public_url, HTTP_IF_NONE_MATCH=etag)

            # assert get success
            self.assertEqual(r.status_code, 200)

        if pithos_settings.UPDATE_MD5:
            assert_non_match(md5_hash(odata))
        else:
            assert_non_match(merkle(odata))
Пример #2
0
    def test_public_get_multiple_if_match(self):
        cname = self.create_container()[0]
        oname, odata = self.upload_object(cname)[:-1]

        # set public
        url = join_urls(self.pithos_path, self.user, cname, oname)
        r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
        self.assertEqual(r.status_code, 202)

        info = self.get_object_info(cname, oname)
        public_url = info['X-Object-Public']

        def assert_multiple_match(etag):
            quoted = lambda s: '"%s"' % s
            r = self.get(public_url, HTTP_IF_MATCH=','.join(
                [quoted(etag), quoted(get_random_data(64))]))

            # assert get success
            self.assertEqual(r.status_code, 200)

            # assert response content
            self.assertEqual(r.content, odata)

        # perform get with If-Match
        if pithos_settings.UPDATE_MD5:
            assert_multiple_match(md5_hash(odata))
        else:
            assert_multiple_match(merkle(odata))
Пример #3
0
    def test_public_if_none_match(self):
        # upload object
        cname = self.create_container()[0]
        oname, odata = self.upload_object(cname)[:-1]

        # set public
        url = join_urls(self.pithos_path, self.user, cname, oname)
        r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
        self.assertEqual(r.status_code, 202)

        info = self.get_object_info(cname, oname)
        public_url = info['X-Object-Public']

        def assert_non_match(etag):
            # perform get with If-None-Match
            r = self.get(public_url, HTTP_IF_NONE_MATCH=etag)

            # assert precondition_failed
            self.assertEqual(r.status_code, 304)

            # update object data
            r = self.append_object_data(cname, oname)[-1]
            self.assertTrue(etag != r['ETag'])

            # perform get with If-None-Match
            r = self.get(public_url, HTTP_IF_NONE_MATCH=etag)

            # assert get success
            self.assertEqual(r.status_code, 200)

        if pithos_settings.UPDATE_MD5:
            assert_non_match(md5_hash(odata))
        else:
            assert_non_match(merkle(odata))
Пример #4
0
    def test_public_get_multiple_if_match(self):
        cname = self.create_container()[0]
        oname, odata = self.upload_object(cname)[:-1]

        # set public
        url = join_urls(self.pithos_path, self.user, cname, oname)
        r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
        self.assertEqual(r.status_code, 202)

        info = self.get_object_info(cname, oname)
        public_url = info['X-Object-Public']

        def assert_multiple_match(etag):
            quoted = lambda s: '"%s"' % s
            r = self.get(public_url,
                         HTTP_IF_MATCH=','.join(
                             [quoted(etag),
                              quoted(get_random_data(64))]))

            # assert get success
            self.assertEqual(r.status_code, 200)

            # assert response content
            self.assertEqual("".join(r.streaming_content), odata)

        # perform get with If-Match
        if pithos_settings.UPDATE_MD5:
            assert_multiple_match(md5_hash(odata))
        else:
            assert_multiple_match(merkle(odata))
Пример #5
0
    def test_public_get_if_match(self):
        cname = self.create_container()[0]
        oname, odata = self.upload_object(cname)[:-1]

        # set public
        url = join_urls(self.pithos_path, self.user, cname, oname)
        r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
        self.assertEqual(r.status_code, 202)

        info = self.get_object_info(cname, oname)
        public_url = info['X-Object-Public']

        def assert_matches(etag):
            r = self.get(public_url, HTTP_IF_MATCH=etag)

            # assert get success
            self.assertEqual(r.status_code, 200)

            # assert response content
            self.assertEqual(r.content, odata)

        # perform get with If-Match
        if pithos_settings.UPDATE_MD5:
            assert_matches(md5_hash(odata))
        else:
            assert_matches(merkle(odata))
Пример #6
0
    def test_public_get_if_match(self):
        cname = self.create_container()[0]
        oname, odata = self.upload_object(cname)[:-1]

        # set public
        url = join_urls(self.pithos_path, self.user, cname, oname)
        r = self.post(url, content_type='', HTTP_X_OBJECT_PUBLIC='true')
        self.assertEqual(r.status_code, 202)

        info = self.get_object_info(cname, oname)
        public_url = info['X-Object-Public']

        def assert_matches(etag):
            r = self.get(public_url, HTTP_IF_MATCH=etag)

            # assert get success
            self.assertEqual(r.status_code, 200)

            # assert response content
            self.assertEqual("".join(r.streaming_content), odata)

        # perform get with If-Match
        if pithos_settings.UPDATE_MD5:
            assert_matches(md5_hash(odata))
        else:
            assert_matches(merkle(odata))