Merge "Swift formpost cleanup"

This commit is contained in:
Jenkins 2014-04-17 22:25:32 +00:00 committed by Gerrit Code Review
commit 1da029e32b
3 changed files with 49 additions and 15 deletions

View File

@ -39,6 +39,18 @@ class ObjectFormPostTest(base.BaseObjectTest):
cls.metadata = {'Temp-URL-Key': cls.key}
cls.account_client.create_account_metadata(metadata=cls.metadata)
def setUp(self):
super(ObjectFormPostTest, self).setUp()
# make sure the metadata has been set
account_client_metadata, _ = \
self.account_client.list_account_metadata()
self.assertIn('x-account-meta-temp-url-key',
account_client_metadata)
self.assertEqual(
account_client_metadata['x-account-meta-temp-url-key'],
self.key)
@classmethod
def tearDownClass(cls):
cls.account_client.delete_account_metadata(metadata=cls.metadata)
@ -100,13 +112,9 @@ class ObjectFormPostTest(base.BaseObjectTest):
headers = {'Content-Type': content_type,
'Content-Length': str(len(body))}
url = "%s/%s/%s" % (self.container_client.base_url,
self.container_name,
self.object_name)
url = "%s/%s" % (self.container_name, self.object_name)
# Use a raw request, otherwise authentication headers are used
resp, body = self.object_client.http_obj.request(url, "POST",
body, headers=headers)
resp, body = self.object_client.post(url, body, headers=headers)
self.assertIn(int(resp['status']), test.HTTP_SUCCESS)
self.assertHeaders(resp, "Object", "POST")

View File

@ -20,6 +20,7 @@ import urlparse
from tempest.api.object_storage import base
from tempest.common.utils import data_utils
from tempest import exceptions
from tempest import test
@ -38,6 +39,18 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest):
cls.metadata = {'Temp-URL-Key': cls.key}
cls.account_client.create_account_metadata(metadata=cls.metadata)
def setUp(self):
super(ObjectFormPostNegativeTest, self).setUp()
# make sure the metadata has been set
account_client_metadata, _ = \
self.account_client.list_account_metadata()
self.assertIn('x-account-meta-temp-url-key',
account_client_metadata)
self.assertEqual(
account_client_metadata['x-account-meta-temp-url-key'],
self.key)
@classmethod
def tearDownClass(cls):
cls.account_client.delete_account_metadata(metadata=cls.metadata)
@ -100,12 +113,25 @@ class ObjectFormPostNegativeTest(base.BaseObjectTest):
headers = {'Content-Type': content_type,
'Content-Length': str(len(body))}
url = "%s/%s/%s" % (self.container_client.base_url,
self.container_name,
self.object_name)
url = "%s/%s" % (self.container_name, self.object_name)
exc = self.assertRaises(
exceptions.Unauthorized,
self.object_client.post,
url, body, headers=headers)
self.assertIn('FormPost: Form Expired', str(exc))
# Use a raw request, otherwise authentication headers are used
resp, body = self.object_client.http_obj.request(url, "POST",
body, headers=headers)
self.assertEqual(int(resp['status']), 401)
self.assertIn('FormPost: Form Expired', body)
@test.requires_ext(extension='formpost', service='object')
@test.attr(type='gate')
def test_post_object_using_form_invalid_signature(self):
self.key = "Wrong"
body, content_type = self.get_multipart_form()
headers = {'Content-Type': content_type,
'Content-Length': str(len(body))}
url = "%s/%s" % (self.container_name, self.object_name)
exc = self.assertRaises(
exceptions.Unauthorized,
self.object_client.post,
url, body, headers=headers)
self.assertIn('FormPost: Invalid Signature', str(exc))

View File

@ -490,7 +490,7 @@ class RestClient(object):
raise exceptions.InvalidContentType(str(resp.status))
if resp.status == 401 or resp.status == 403:
raise exceptions.Unauthorized()
raise exceptions.Unauthorized(resp_body)
if resp.status == 404:
raise exceptions.NotFound(resp_body)