Merge "Split up XML and JSON testing."
diff --git a/tempest/services/object_storage/object_client.py b/tempest/services/object_storage/object_client.py
index 03cd209..2256170 100644
--- a/tempest/services/object_storage/object_client.py
+++ b/tempest/services/object_storage/object_client.py
@@ -15,11 +15,14 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from hashlib import sha1
+import hmac
 import httplib2
 import json
 import re
 from tempest.common.rest_client import RestClient
 from tempest import exceptions
+from urlparse import urlparse
 
 
 class ObjectClient(RestClient):
@@ -120,6 +123,23 @@
         resp, body = self.copy(url, headers=headers)
         return resp, body
 
+    def get_object_using_temp_url(self, container, object_name, expires, key):
+        """Retrieve object's data using temp URL."""
+
+        self._set_auth()
+        method = 'GET'
+        path = "%s/%s/%s" % (urlparse(self.base_url).path, container,
+                             object_name)
+        hmac_body = '%s\n%s\n%s' % (method, expires, path)
+        sig = hmac.new(key, hmac_body, sha1).hexdigest()
+
+        url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,
+                                                             object_name,
+                                                             sig, expires)
+
+        resp, body = self.get(url)
+        return resp, body
+
 
 class ObjectClientCustomizedHeader(RestClient):
 
diff --git a/tempest/tests/object_storage/test_object_services.py b/tempest/tests/object_storage/test_object_services.py
index d380da6..fc3f45f 100644
--- a/tempest/tests/object_storage/test_object_services.py
+++ b/tempest/tests/object_storage/test_object_services.py
@@ -21,6 +21,7 @@
 from tempest.common.utils.data_utils import rand_name
 from tempest import exceptions
 from tempest.tests.object_storage import base
+from time import time
 import unittest2 as unittest
 
 
@@ -611,3 +612,47 @@
                           self.custom_object_client.delete_object,
                           self.container_name, object_name,
                           metadata=self.custom_headers)
+
+    @unittest.skip('Until bug 1097137 is resolved.')
+    @attr(type='positive')
+    def test_get_object_using_temp_url(self):
+        #Access object using temp url within expiry time
+
+        try:
+            #Update Account Metadata
+            # Flag to check if account metadata got updated
+            flag = False
+            key = 'Meta'
+            metadata = {'Temp-URL-Key': key}
+            resp, _ = \
+                self.account_client.create_account_metadata(metadata=metadata)
+            self.assertEqual(resp['status'], '204')
+            flag = True
+
+            resp, _ = self.account_client.list_account_metadata()
+            self.assertIn('x-account-meta-temp-url-key', resp)
+            self.assertEqual(resp['x-account-meta-temp-url-key'], key)
+
+            # Create Object
+            object_name = rand_name(name='ObjectTemp')
+            data = arbitrary_string(size=len(object_name),
+                                    base_text=object_name)
+            self.object_client.create_object(self.container_name,
+                                             object_name, data)
+
+            expires = int(time() + 10)
+
+            #Trying to GET object using temp URL with in expiry time
+            _, body = \
+                self.object_client.get_object_using_temp_url(
+                    self.container_name, object_name, expires, key)
+
+            self.assertEqual(body, data)
+
+        finally:
+            if flag:
+                resp, _ = \
+                    self.account_client.delete_account_metadata(
+                        metadata=metadata)
+                resp, _ = self.account_client.list_account_metadata()
+                self.assertNotIn('x-account-meta-temp-url-key', resp)
diff --git a/tools/install_venv.py b/tools/install_venv.py
index f4621c9..28275ba 100644
--- a/tools/install_venv.py
+++ b/tools/install_venv.py
@@ -150,16 +150,16 @@
 
 
 def get_distro():
-    if (os.path.exists('/etc/fedora-release') or
-            os.path.exists('/etc/redhat-release')):
-        if os.path.exists('/etc/redhat-release') \
-            and run_command_with_code(['grep', 'CentOS',
-                                       '/etc/redhat-release']) == 0:
-            return CentOS()
-        else:
-            return Fedora()
-    else:
-        return Distro()
+    if os.path.exists('/etc/redhat-release'):
+        with open('/etc/redhat-release') as rh_release:
+            if 'CentOS' in rh_release.read():
+                return CentOS()
+        return Fedora()
+
+    if os.path.exists('/etc/fedora-release'):
+        return Fedora()
+
+    return Distro()
 
 
 def check_dependencies():