Merge "Swift formpost cleanup"
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index e0d15ac..81db252 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -39,6 +39,18 @@
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 @@
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")
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
index a52c248..fe0c994 100644
--- a/tempest/api/object_storage/test_object_formpost_negative.py
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -20,6 +20,7 @@
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 @@
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 @@
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))
diff --git a/tempest/common/rest_client.py b/tempest/common/rest_client.py
index 0d32f41..8c07d4f 100644
--- a/tempest/common/rest_client.py
+++ b/tempest/common/rest_client.py
@@ -490,7 +490,7 @@
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)