summaryrefslogtreecommitdiffstats
path: root/test/functionalnosetests
diff options
context:
space:
mode:
authorPeter Portante <peter.portante@redhat.com>2013-10-24 16:15:25 -0400
committerLuis Pabon <lpabon@redhat.com>2013-10-28 11:51:51 -0700
commit286a1308db72c5cfdd6ce16aff3f291ebce257c2 (patch)
treeaabb3c54a29d6236f5ade0a229c477378a6c832c /test/functionalnosetests
parent6b8d7c59195327484ac0f14bd1c29e4f75415e3b (diff)
Rebase to OpenStack Swift Havana (1.10.0)
Change-Id: I90821230a1a7100c74d97cccc9c445251d0f65e7 Signed-off-by: Peter Portante <peter.portante@redhat.com> Reviewed-on: http://review.gluster.org/6157 Reviewed-by: Luis Pabon <lpabon@redhat.com> Tested-by: Luis Pabon <lpabon@redhat.com>
Diffstat (limited to 'test/functionalnosetests')
-rw-r--r--test/functionalnosetests/swift_testing.py42
-rwxr-xr-xtest/functionalnosetests/test_account.py43
-rwxr-xr-xtest/functionalnosetests/test_container.py149
-rwxr-xr-xtest/functionalnosetests/test_object.py211
4 files changed, 238 insertions, 207 deletions
diff --git a/test/functionalnosetests/swift_testing.py b/test/functionalnosetests/swift_testing.py
index c49d9cd..50abc8e 100644
--- a/test/functionalnosetests/swift_testing.py
+++ b/test/functionalnosetests/swift_testing.py
@@ -1,19 +1,4 @@
-# Copyright (c) 2010-2013 OpenStack, LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Copyright (c) 2013 Red Hat, Inc.
+# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -28,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+from httplib import HTTPException
import os
import socket
import sys
@@ -35,7 +21,7 @@ from time import sleep
from test import get_config
-from swiftclient import get_auth, http_connection, HTTPException
+from swiftclient import get_auth, http_connection
conf = get_config('func_test')
web_front_end = conf.get('web_front_end', 'integral')
@@ -57,8 +43,8 @@ if conf:
if 'auth_prefix' not in conf:
conf['auth_prefix'] = '/'
try:
- swift_test_auth += \
- '://%(auth_host)s:%(auth_port)s%(auth_prefix)s' % conf
+ suffix = '://%(auth_host)s:%(auth_port)s%(auth_prefix)s' % conf
+ swift_test_auth += suffix
except KeyError:
pass # skip
@@ -71,17 +57,17 @@ if conf:
swift_test_user[0] = '%(username)s' % conf
swift_test_key[0] = conf['password']
try:
- swift_test_user[1] = '%s%s' % \
- ('%s:' % conf['account2'] if 'account2' in conf else '',
+ swift_test_user[1] = '%s%s' % (
+ '%s:' % conf['account2'] if 'account2' in conf else '',
conf['username2'])
swift_test_key[1] = conf['password2']
- except KeyError, err:
+ except KeyError as err:
pass # old conf, no second account tests can be run
try:
swift_test_user[2] = '%s%s' % ('%s:' % conf['account'] if 'account'
in conf else '', conf['username3'])
swift_test_key[2] = conf['password3']
- except KeyError, err:
+ except KeyError as err:
pass # old conf, no third account tests can be run
for _ in range(3):
@@ -99,7 +85,8 @@ if conf:
swift_test_key[2] = conf['password3']
for _ in range(3):
- swift_test_perm[_] = swift_test_tenant[_] + ':' + swift_test_user[_]
+ swift_test_perm[_] = swift_test_tenant[_] + ':' \
+ + swift_test_user[_]
skip = not all([swift_test_auth, swift_test_user[0], swift_test_key[0]])
if skip:
@@ -108,12 +95,12 @@ if skip:
skip2 = not all([not skip, swift_test_user[1], swift_test_key[1]])
if not skip and skip2:
print >>sys.stderr, \
- 'SKIPPING SECOND ACCOUNT FUNCTIONAL TESTS DUE TO NO CONFIG FOR THEM'
+ 'SKIPPING SECOND ACCOUNT FUNCTIONAL TESTS DUE TO NO CONFIG FOR THEM'
skip3 = not all([not skip, swift_test_user[2], swift_test_key[2]])
if not skip and skip3:
print >>sys.stderr, \
- 'SKIPPING THIRD ACCOUNT FUNCTIONAL TESTS DUE TO NO CONFIG FOR THEM'
+ 'SKIPPING THIRD ACCOUNT FUNCTIONAL TESTS DUE TO NO CONFIG FOR THEM'
class AuthError(Exception):
@@ -160,7 +147,8 @@ def retry(func, *args, **kwargs):
parsed[use_account], conn[use_account] = \
http_connection(url[use_account])
return func(url[use_account], token[use_account],
- parsed[use_account], conn[use_account], *args, **kwargs)
+ parsed[use_account], conn[use_account],
+ *args, **kwargs)
except (socket.error, HTTPException):
if attempts > retries:
raise
diff --git a/test/functionalnosetests/test_account.py b/test/functionalnosetests/test_account.py
index d28ff2f..b2f743f 100755
--- a/test/functionalnosetests/test_account.py
+++ b/test/functionalnosetests/test_account.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-# Copyright (c) 2010-2013 OpenStack, LLC.
+# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -15,22 +15,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# Copyright (c) 2013 Red Hat, Inc.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
import unittest
from nose import SkipTest
@@ -45,16 +29,20 @@ class TestAccount(unittest.TestCase):
def test_metadata(self):
if skip:
raise SkipTest
+
def post(url, token, parsed, conn, value):
conn.request('POST', parsed.path, '',
- {'X-Auth-Token': token, 'X-Account-Meta-Test': value})
+ {'X-Auth-Token': token, 'X-Account-Meta-Test': value})
return check_response(conn)
+
def head(url, token, parsed, conn):
conn.request('HEAD', parsed.path, '', {'X-Auth-Token': token})
return check_response(conn)
+
def get(url, token, parsed, conn):
conn.request('GET', parsed.path, '', {'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(post, '')
resp.read()
self.assertEquals(resp.status, 204)
@@ -121,13 +109,16 @@ class TestAccount(unittest.TestCase):
def test_multi_metadata(self):
if skip:
raise SkipTest
+
def post(url, token, parsed, conn, name, value):
conn.request('POST', parsed.path, '',
{'X-Auth-Token': token, name: value})
return check_response(conn)
+
def head(url, token, parsed, conn):
conn.request('HEAD', parsed.path, '', {'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(post, 'X-Account-Meta-One', '1')
resp.read()
self.assertEquals(resp.status, 204)
@@ -147,26 +138,30 @@ class TestAccount(unittest.TestCase):
def test_bad_metadata(self):
if skip:
raise SkipTest
+
def post(url, token, parsed, conn, extra_headers):
headers = {'X-Auth-Token': token}
headers.update(extra_headers)
conn.request('POST', parsed.path, '', headers)
return check_response(conn)
+
resp = retry(post,
- {'X-Account-Meta-' + ('k' * MAX_META_NAME_LENGTH): 'v'})
+ {'X-Account-Meta-' + ('k' * MAX_META_NAME_LENGTH): 'v'})
resp.read()
self.assertEquals(resp.status, 204)
- resp = retry(post,
- {'X-Account-Meta-' + ('k' * (MAX_META_NAME_LENGTH + 1)): 'v'})
+ resp = retry(
+ post,
+ {'X-Account-Meta-' + ('k' * (MAX_META_NAME_LENGTH + 1)): 'v'})
resp.read()
self.assertEquals(resp.status, 400)
resp = retry(post,
- {'X-Account-Meta-Too-Long': 'k' * MAX_META_VALUE_LENGTH})
+ {'X-Account-Meta-Too-Long': 'k' * MAX_META_VALUE_LENGTH})
resp.read()
self.assertEquals(resp.status, 204)
- resp = retry(post,
- {'X-Account-Meta-Too-Long': 'k' * (MAX_META_VALUE_LENGTH + 1)})
+ resp = retry(
+ post,
+ {'X-Account-Meta-Too-Long': 'k' * (MAX_META_VALUE_LENGTH + 1)})
resp.read()
self.assertEquals(resp.status, 400)
diff --git a/test/functionalnosetests/test_container.py b/test/functionalnosetests/test_container.py
index af78a7a..15f7fc1 100755
--- a/test/functionalnosetests/test_container.py
+++ b/test/functionalnosetests/test_container.py
@@ -1,21 +1,6 @@
#!/usr/bin/python
-# Copyright (c) 2010-2013 OpenStack, LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Copyright (c) 2013 Red Hat, Inc.
+# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -39,7 +24,7 @@ from swift.common.constraints import MAX_META_COUNT, MAX_META_NAME_LENGTH, \
MAX_META_OVERALL_SIZE, MAX_META_VALUE_LENGTH
from swift_testing import check_response, retry, skip, skip2, skip3, \
- swift_test_perm, web_front_end
+ swift_test_perm, web_front_end
class TestContainer(unittest.TestCase):
@@ -48,10 +33,12 @@ class TestContainer(unittest.TestCase):
if skip:
raise SkipTest
self.name = uuid4().hex
+
def put(url, token, parsed, conn):
conn.request('PUT', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(put)
resp.read()
self.assertEquals(resp.status, 201)
@@ -59,15 +46,18 @@ class TestContainer(unittest.TestCase):
def tearDown(self):
if skip:
raise SkipTest
+
def get(url, token, parsed, conn):
conn.request('GET', parsed.path + '/' + self.name + '?format=json',
'', {'X-Auth-Token': token})
return check_response(conn)
+
def delete(url, token, parsed, conn, obj):
conn.request('DELETE',
'/'.join([parsed.path, self.name, obj['name']]), '',
{'X-Auth-Token': token})
return check_response(conn)
+
while True:
resp = retry(get)
body = resp.read()
@@ -79,10 +69,12 @@ class TestContainer(unittest.TestCase):
resp = retry(delete, obj)
resp.read()
self.assertEquals(resp.status, 204)
+
def delete(url, token, parsed, conn):
conn.request('DELETE', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(delete)
resp.read()
self.assertEquals(resp.status, 204)
@@ -90,14 +82,17 @@ class TestContainer(unittest.TestCase):
def test_multi_metadata(self):
if skip:
raise SkipTest
+
def post(url, token, parsed, conn, name, value):
conn.request('POST', parsed.path + '/' + self.name, '',
- {'X-Auth-Token': token, name: value})
+ {'X-Auth-Token': token, name: value})
return check_response(conn)
+
def head(url, token, parsed, conn):
conn.request('HEAD', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(post, 'X-Container-Meta-One', '1')
resp.read()
self.assertEquals(resp.status, 204)
@@ -154,27 +149,33 @@ class TestContainer(unittest.TestCase):
resp.read()
self.assert_(resp.status in (200, 204), resp.status)
self.assertEquals(resp.getheader(uni_key.encode('utf-8')),
- uni_value.encode('utf-8'))
+ uni_value.encode('utf-8'))
def test_PUT_metadata(self):
if skip:
raise SkipTest
+
def put(url, token, parsed, conn, name, value):
conn.request('PUT', parsed.path + '/' + name, '',
- {'X-Auth-Token': token, 'X-Container-Meta-Test': value})
+ {'X-Auth-Token': token,
+ 'X-Container-Meta-Test': value})
return check_response(conn)
+
def head(url, token, parsed, conn, name):
conn.request('HEAD', parsed.path + '/' + name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
def get(url, token, parsed, conn, name):
conn.request('GET', parsed.path + '/' + name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
def delete(url, token, parsed, conn, name):
conn.request('DELETE', parsed.path + '/' + name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
name = uuid4().hex
resp = retry(put, name, 'Value')
resp.read()
@@ -210,18 +211,23 @@ class TestContainer(unittest.TestCase):
def test_POST_metadata(self):
if skip:
raise SkipTest
+
def post(url, token, parsed, conn, value):
conn.request('POST', parsed.path + '/' + self.name, '',
- {'X-Auth-Token': token, 'X-Container-Meta-Test': value})
+ {'X-Auth-Token': token,
+ 'X-Container-Meta-Test': value})
return check_response(conn)
+
def head(url, token, parsed, conn):
conn.request('HEAD', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
def get(url, token, parsed, conn):
conn.request('GET', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(head)
resp.read()
self.assert_(resp.status in (200, 204), resp.status)
@@ -245,26 +251,31 @@ class TestContainer(unittest.TestCase):
def test_PUT_bad_metadata(self):
if skip:
raise SkipTest
+
def put(url, token, parsed, conn, name, extra_headers):
headers = {'X-Auth-Token': token}
headers.update(extra_headers)
conn.request('PUT', parsed.path + '/' + name, '', headers)
return check_response(conn)
+
def delete(url, token, parsed, conn, name):
conn.request('DELETE', parsed.path + '/' + name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
name = uuid4().hex
- resp = retry(put, name,
- {'X-Container-Meta-' + ('k' * MAX_META_NAME_LENGTH): 'v'})
+ resp = retry(
+ put, name,
+ {'X-Container-Meta-' + ('k' * MAX_META_NAME_LENGTH): 'v'})
resp.read()
self.assertEquals(resp.status, 201)
resp = retry(delete, name)
resp.read()
self.assertEquals(resp.status, 204)
name = uuid4().hex
- resp = retry(put, name,
- {'X-Container-Meta-' + ('k' * (MAX_META_NAME_LENGTH + 1)): 'v'})
+ resp = retry(
+ put, name,
+ {'X-Container-Meta-' + ('k' * (MAX_META_NAME_LENGTH + 1)): 'v'})
resp.read()
self.assertEquals(resp.status, 400)
resp = retry(delete, name)
@@ -272,16 +283,18 @@ class TestContainer(unittest.TestCase):
self.assertEquals(resp.status, 404)
name = uuid4().hex
- resp = retry(put, name,
- {'X-Container-Meta-Too-Long': 'k' * MAX_META_VALUE_LENGTH})
+ resp = retry(
+ put, name,
+ {'X-Container-Meta-Too-Long': 'k' * MAX_META_VALUE_LENGTH})
resp.read()
self.assertEquals(resp.status, 201)
resp = retry(delete, name)
resp.read()
self.assertEquals(resp.status, 204)
name = uuid4().hex
- resp = retry(put, name,
- {'X-Container-Meta-Too-Long': 'k' * (MAX_META_VALUE_LENGTH + 1)})
+ resp = retry(
+ put, name,
+ {'X-Container-Meta-Too-Long': 'k' * (MAX_META_VALUE_LENGTH + 1)})
resp.read()
self.assertEquals(resp.status, 400)
resp = retry(delete, name)
@@ -340,26 +353,32 @@ class TestContainer(unittest.TestCase):
def test_POST_bad_metadata(self):
if skip:
raise SkipTest
+
def post(url, token, parsed, conn, extra_headers):
headers = {'X-Auth-Token': token}
headers.update(extra_headers)
conn.request('POST', parsed.path + '/' + self.name, '', headers)
return check_response(conn)
- resp = retry(post,
- {'X-Container-Meta-' + ('k' * MAX_META_NAME_LENGTH): 'v'})
+
+ resp = retry(
+ post,
+ {'X-Container-Meta-' + ('k' * MAX_META_NAME_LENGTH): 'v'})
resp.read()
self.assertEquals(resp.status, 204)
- resp = retry(post,
- {'X-Container-Meta-' + ('k' * (MAX_META_NAME_LENGTH + 1)): 'v'})
+ resp = retry(
+ post,
+ {'X-Container-Meta-' + ('k' * (MAX_META_NAME_LENGTH + 1)): 'v'})
resp.read()
self.assertEquals(resp.status, 400)
- resp = retry(post,
- {'X-Container-Meta-Too-Long': 'k' * MAX_META_VALUE_LENGTH})
+ resp = retry(
+ post,
+ {'X-Container-Meta-Too-Long': 'k' * MAX_META_VALUE_LENGTH})
resp.read()
self.assertEquals(resp.status, 204)
- resp = retry(post,
- {'X-Container-Meta-Too-Long': 'k' * (MAX_META_VALUE_LENGTH + 1)})
+ resp = retry(
+ post,
+ {'X-Container-Meta-Too-Long': 'k' * (MAX_META_VALUE_LENGTH + 1)})
resp.read()
self.assertEquals(resp.status, 400)
@@ -399,36 +418,42 @@ class TestContainer(unittest.TestCase):
def test_public_container(self):
if skip:
raise SkipTest
+
def get(url, token, parsed, conn):
conn.request('GET', parsed.path + '/' + self.name)
return check_response(conn)
+
try:
resp = retry(get)
raise Exception('Should not have been able to GET')
- except Exception, err:
+ except Exception as err:
self.assert_(str(err).startswith('No result after '), err)
+
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token,
'X-Container-Read': '.r:*,.rlistings'})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
resp = retry(get)
resp.read()
self.assertEquals(resp.status, 204)
+
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token, 'X-Container-Read': ''})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
try:
resp = retry(get)
raise Exception('Should not have been able to GET')
- except Exception, err:
+ except Exception as err:
self.assert_(str(err).startswith('No result after '), err)
def test_cross_account_container(self):
@@ -436,27 +461,34 @@ class TestContainer(unittest.TestCase):
raise SkipTest
# Obtain the first account's string
first_account = ['unknown']
+
def get1(url, token, parsed, conn):
first_account[0] = parsed.path
conn.request('HEAD', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(get1)
resp.read()
+
# Ensure we can't access the container with the second account
def get2(url, token, parsed, conn):
conn.request('GET', first_account[0] + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(get2, use_account=2)
resp.read()
self.assertEquals(resp.status, 403)
+
# Make the container accessible by the second account
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
- {'X-Auth-Token': token, 'X-Container-Read': swift_test_perm[1],
- 'X-Container-Write': swift_test_perm[1]})
+ {'X-Auth-Token': token,
+ 'X-Container-Read': swift_test_perm[1],
+ 'X-Container-Write': swift_test_perm[1]})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
@@ -464,12 +496,14 @@ class TestContainer(unittest.TestCase):
resp = retry(get2, use_account=2)
resp.read()
self.assertEquals(resp.status, 204)
+
# Make the container private again
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token, 'X-Container-Read': '',
'X-Container-Write': ''})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
@@ -483,27 +517,33 @@ class TestContainer(unittest.TestCase):
raise SkipTest
# Obtain the first account's string
first_account = ['unknown']
+
def get1(url, token, parsed, conn):
first_account[0] = parsed.path
conn.request('HEAD', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(get1)
resp.read()
+
# Ensure we can't access the container with the second account
def get2(url, token, parsed, conn):
conn.request('GET', first_account[0] + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(get2, use_account=2)
resp.read()
self.assertEquals(resp.status, 403)
+
# Make the container completely public
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token,
'X-Container-Read': '.r:*,.rlistings'})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
@@ -511,20 +551,24 @@ class TestContainer(unittest.TestCase):
resp = retry(get2, use_account=2)
resp.read()
self.assertEquals(resp.status, 204)
+
# But we shouldn't be able to write with the second account
def put2(url, token, parsed, conn):
conn.request('PUT', first_account[0] + '/' + self.name + '/object',
'test object', {'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(put2, use_account=2)
resp.read()
self.assertEquals(resp.status, 403)
+
# Now make the container also writeable by the second account
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
- {'X-Auth-Token': token,
- 'X-Container-Write': swift_test_perm[1]})
+ {'X-Auth-Token': token,
+ 'X-Container-Write': swift_test_perm[1]})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
@@ -542,26 +586,33 @@ class TestContainer(unittest.TestCase):
raise SkipTest
# Obtain the first account's string
first_account = ['unknown']
+
def get1(url, token, parsed, conn):
first_account[0] = parsed.path
conn.request('HEAD', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(get1)
resp.read()
+
# Ensure we can't access the container with the third account
def get3(url, token, parsed, conn):
conn.request('GET', first_account[0] + '/' + self.name, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(get3, use_account=3)
resp.read()
self.assertEquals(resp.status, 403)
+
# Make the container accessible by the third account
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
- {'X-Auth-Token': token, 'X-Container-Read': swift_test_perm[2]})
+ {'X-Auth-Token': token,
+ 'X-Container-Read': swift_test_perm[2]})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
@@ -569,20 +620,24 @@ class TestContainer(unittest.TestCase):
resp = retry(get3, use_account=3)
resp.read()
self.assertEquals(resp.status, 204)
+
# But we shouldn't be able to write with the third account
def put3(url, token, parsed, conn):
conn.request('PUT', first_account[0] + '/' + self.name + '/object',
'test object', {'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(put3, use_account=3)
resp.read()
self.assertEquals(resp.status, 403)
+
# Now make the container also writeable by the third account
def post(url, token, parsed, conn):
conn.request('POST', parsed.path + '/' + self.name, '',
{'X-Auth-Token': token,
'X-Container-Write': swift_test_perm[2]})
return check_response(conn)
+
resp = retry(post)
resp.read()
self.assertEquals(resp.status, 204)
@@ -601,9 +656,10 @@ class TestContainer(unittest.TestCase):
def put(url, token, parsed, conn):
container_name = 'X' * 2048
- conn.request('PUT', '%s/%s' % (parsed.path,
- container_name), 'there', {'X-Auth-Token': token})
+ conn.request('PUT', '%s/%s' % (parsed.path, container_name),
+ 'there', {'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(put)
resp.read()
self.assertEquals(resp.status, 400)
@@ -618,6 +674,7 @@ class TestContainer(unittest.TestCase):
conn.request('PUT', '%s/abc%%00def' % parsed.path, '',
{'X-Auth-Token': token})
return check_response(conn)
+
resp = retry(put)
if (web_front_end == 'apache2'):
self.assertEquals(resp.status, 404)
diff --git a/test/functionalnosetests/test_object.py b/test/functionalnosetests/test_object.py
index 3972aaf..97cd8d0 100755
--- a/test/functionalnosetests/test_object.py
+++ b/test/functionalnosetests/test_object.py
@@ -1,21 +1,6 @@
#!/usr/bin/python
-# Copyright (c) 2010-2013 OpenStack, LLC.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-# implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Copyright (c) 2013 Red Hat, Inc.
+# Copyright (c) 2010-2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -55,8 +40,9 @@ class TestObject(unittest.TestCase):
self.obj = uuid4().hex
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/%s' % (parsed.path, self.container,
- self.obj), 'test', {'X-Auth-Token': token})
+ conn.request('PUT', '%s/%s/%s' % (
+ parsed.path, self.container, self.obj), 'test',
+ {'X-Auth-Token': token})
return check_response(conn)
resp = retry(put)
resp.read()
@@ -182,7 +168,7 @@ class TestObject(unittest.TestCase):
try:
resp = retry(get)
raise Exception('Should not have been able to GET')
- except Exception, err:
+ except Exception as err:
self.assert_(str(err).startswith('No result after '))
def post(url, token, parsed, conn):
@@ -207,7 +193,7 @@ class TestObject(unittest.TestCase):
try:
resp = retry(get)
raise Exception('Should not have been able to GET')
- except Exception, err:
+ except Exception as err:
self.assert_(str(err).startswith('No result after '))
def test_private_object(self):
@@ -216,9 +202,9 @@ class TestObject(unittest.TestCase):
# Ensure we can't access the object with the third account
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/%s' % (parsed.path, self.container,
- self.obj), '',
- {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/%s' % (
+ parsed.path, self.container, self.obj), '',
+ {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get, use_account=3)
resp.read()
@@ -228,11 +214,11 @@ class TestObject(unittest.TestCase):
shared_container = uuid4().hex
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s' % (parsed.path,
- shared_container), '',
- {'X-Auth-Token': token,
- 'X-Container-Read': swift_test_perm[2],
- 'X-Container-Write': swift_test_perm[2]})
+ conn.request('PUT', '%s/%s' % (
+ parsed.path, shared_container), '',
+ {'X-Auth-Token': token,
+ 'X-Container-Read': swift_test_perm[2],
+ 'X-Container-Write': swift_test_perm[2]})
return check_response(conn)
resp = retry(put)
resp.read()
@@ -240,13 +226,11 @@ class TestObject(unittest.TestCase):
# verify third account can not copy from private container
def copy(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/%s' % (parsed.path,
- shared_container,
- 'private_object'),
- '', {'X-Auth-Token': token,
- 'Content-Length': '0',
- 'X-Copy-From': '%s/%s' % (self.container,
- self.obj)})
+ conn.request('PUT', '%s/%s/%s' % (
+ parsed.path, shared_container, 'private_object'), '',
+ {'X-Auth-Token': token,
+ 'Content-Length': '0',
+ 'X-Copy-From': '%s/%s' % (self.container, self.obj)})
return check_response(conn)
resp = retry(copy, use_account=3)
resp.read()
@@ -254,8 +238,9 @@ class TestObject(unittest.TestCase):
# verify third account can write "obj1" to shared container
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/%s' % (parsed.path, shared_container,
- 'obj1'), 'test', {'X-Auth-Token': token})
+ conn.request('PUT', '%s/%s/%s' % (
+ parsed.path, shared_container, 'obj1'), 'test',
+ {'X-Auth-Token': token})
return check_response(conn)
resp = retry(put, use_account=3)
resp.read()
@@ -263,12 +248,10 @@ class TestObject(unittest.TestCase):
# verify third account can copy "obj1" to shared container
def copy2(url, token, parsed, conn):
- conn.request('COPY', '%s/%s/%s' % (parsed.path,
- shared_container,
- 'obj1'),
- '', {'X-Auth-Token': token,
- 'Destination': '%s/%s' % (shared_container,
- 'obj1')})
+ conn.request('COPY', '%s/%s/%s' % (
+ parsed.path, shared_container, 'obj1'), '',
+ {'X-Auth-Token': token,
+ 'Destination': '%s/%s' % (shared_container, 'obj1')})
return check_response(conn)
resp = retry(copy2, use_account=3)
resp.read()
@@ -276,12 +259,11 @@ class TestObject(unittest.TestCase):
# verify third account STILL can not copy from private container
def copy3(url, token, parsed, conn):
- conn.request('COPY', '%s/%s/%s' % (parsed.path,
- self.container,
- self.obj),
- '', {'X-Auth-Token': token,
- 'Destination': '%s/%s' % (shared_container,
- 'private_object')})
+ conn.request('COPY', '%s/%s/%s' % (
+ parsed.path, self.container, self.obj), '',
+ {'X-Auth-Token': token,
+ 'Destination': '%s/%s' % (shared_container,
+ 'private_object')})
return check_response(conn)
resp = retry(copy3, use_account=3)
resp.read()
@@ -289,8 +271,9 @@ class TestObject(unittest.TestCase):
# clean up "obj1"
def delete(url, token, parsed, conn):
- conn.request('DELETE', '%s/%s/%s' % (parsed.path, shared_container,
- 'obj1'), '', {'X-Auth-Token': token})
+ conn.request('DELETE', '%s/%s/%s' % (
+ parsed.path, shared_container, 'obj1'), '',
+ {'X-Auth-Token': token})
return check_response(conn)
resp = retry(delete)
resp.read()
@@ -316,8 +299,8 @@ class TestObject(unittest.TestCase):
# Upload the first set of segments
def put(url, token, parsed, conn, objnum):
- conn.request('PUT', '%s/%s/segments1/%s' % (parsed.path,
- self.container, str(objnum)), segments1[objnum],
+ conn.request('PUT', '%s/%s/segments1/%s' % (
+ parsed.path, self.container, str(objnum)), segments1[objnum],
{'X-Auth-Token': token})
return check_response(conn)
for objnum in xrange(len(segments1)):
@@ -327,10 +310,11 @@ class TestObject(unittest.TestCase):
# Upload the manifest
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token,
- 'X-Object-Manifest': '%s/segments1/' % self.container,
- 'Content-Type': 'text/jibberish', 'Content-Length': '0'})
+ conn.request('PUT', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {
+ 'X-Auth-Token': token,
+ 'X-Object-Manifest': '%s/segments1/' % self.container,
+ 'Content-Type': 'text/jibberish', 'Content-Length': '0'})
return check_response(conn)
resp = retry(put)
resp.read()
@@ -338,8 +322,8 @@ class TestObject(unittest.TestCase):
# Get the manifest (should get all the segments as the body)
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments1))
@@ -348,9 +332,9 @@ class TestObject(unittest.TestCase):
# Get with a range at the start of the second segment
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token, 'Range':
- 'bytes=3-'})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {
+ 'X-Auth-Token': token, 'Range': 'bytes=3-'})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments1[1:]))
@@ -358,9 +342,9 @@ class TestObject(unittest.TestCase):
# Get with a range in the middle of the second segment
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token, 'Range':
- 'bytes=5-'})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {
+ 'X-Auth-Token': token, 'Range': 'bytes=5-'})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments1)[5:])
@@ -368,9 +352,9 @@ class TestObject(unittest.TestCase):
# Get with a full start and stop range
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token, 'Range':
- 'bytes=5-10'})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {
+ 'X-Auth-Token': token, 'Range': 'bytes=5-10'})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments1)[5:11])
@@ -378,8 +362,8 @@ class TestObject(unittest.TestCase):
# Upload the second set of segments
def put(url, token, parsed, conn, objnum):
- conn.request('PUT', '%s/%s/segments2/%s' % (parsed.path,
- self.container, str(objnum)), segments2[objnum],
+ conn.request('PUT', '%s/%s/segments2/%s' % (
+ parsed.path, self.container, str(objnum)), segments2[objnum],
{'X-Auth-Token': token})
return check_response(conn)
for objnum in xrange(len(segments2)):
@@ -389,8 +373,8 @@ class TestObject(unittest.TestCase):
# Get the manifest (should still be the first segments of course)
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments1))
@@ -398,10 +382,11 @@ class TestObject(unittest.TestCase):
# Update the manifest
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token,
- 'X-Object-Manifest': '%s/segments2/' % self.container,
- 'Content-Length': '0'})
+ conn.request('PUT', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {
+ 'X-Auth-Token': token,
+ 'X-Object-Manifest': '%s/segments2/' % self.container,
+ 'Content-Length': '0'})
return check_response(conn)
resp = retry(put)
resp.read()
@@ -409,8 +394,8 @@ class TestObject(unittest.TestCase):
# Get the manifest (should be the second set of segments now)
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments2))
@@ -420,8 +405,8 @@ class TestObject(unittest.TestCase):
# Ensure we can't access the manifest with the third account
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get, use_account=3)
resp.read()
@@ -430,8 +415,8 @@ class TestObject(unittest.TestCase):
# Grant access to the third account
def post(url, token, parsed, conn):
conn.request('POST', '%s/%s' % (parsed.path, self.container),
- '', {'X-Auth-Token': token,
- 'X-Container-Read': swift_test_perm[2]})
+ '', {'X-Auth-Token': token,
+ 'X-Container-Read': swift_test_perm[2]})
return check_response(conn)
resp = retry(post)
resp.read()
@@ -439,8 +424,8 @@ class TestObject(unittest.TestCase):
# The third account should be able to get the manifest now
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get, use_account=3)
self.assertEquals(resp.read(), ''.join(segments2))
@@ -459,8 +444,8 @@ class TestObject(unittest.TestCase):
# Upload the third set of segments in the other container
def put(url, token, parsed, conn, objnum):
- conn.request('PUT', '%s/%s/segments3/%s' % (parsed.path,
- acontainer, str(objnum)), segments3[objnum],
+ conn.request('PUT', '%s/%s/segments3/%s' % (
+ parsed.path, acontainer, str(objnum)), segments3[objnum],
{'X-Auth-Token': token})
return check_response(conn)
for objnum in xrange(len(segments3)):
@@ -470,10 +455,11 @@ class TestObject(unittest.TestCase):
# Update the manifest
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token,
- 'X-Object-Manifest': '%s/segments3/' % acontainer,
- 'Content-Length': '0'})
+ conn.request('PUT', '%s/%s/manifest' % (
+ parsed.path, self.container), '',
+ {'X-Auth-Token': token,
+ 'X-Object-Manifest': '%s/segments3/' % acontainer,
+ 'Content-Length': '0'})
return check_response(conn)
resp = retry(put)
resp.read()
@@ -481,8 +467,8 @@ class TestObject(unittest.TestCase):
# Get the manifest to ensure it's the third set of segments
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get)
self.assertEquals(resp.read(), ''.join(segments3))
@@ -495,8 +481,8 @@ class TestObject(unittest.TestCase):
# manifest itself is not).
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get, use_account=3)
resp.read()
@@ -505,8 +491,8 @@ class TestObject(unittest.TestCase):
# Grant access to the third account
def post(url, token, parsed, conn):
conn.request('POST', '%s/%s' % (parsed.path, acontainer),
- '', {'X-Auth-Token': token,
- 'X-Container-Read': swift_test_perm[2]})
+ '', {'X-Auth-Token': token,
+ 'X-Container-Read': swift_test_perm[2]})
return check_response(conn)
resp = retry(post)
resp.read()
@@ -514,8 +500,8 @@ class TestObject(unittest.TestCase):
# The third account should be able to get the manifest now
def get(url, token, parsed, conn):
- conn.request('GET', '%s/%s/manifest' % (parsed.path,
- self.container), '', {'X-Auth-Token': token})
+ conn.request('GET', '%s/%s/manifest' % (
+ parsed.path, self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(get, use_account=3)
self.assertEquals(resp.read(), ''.join(segments3))
@@ -523,7 +509,8 @@ class TestObject(unittest.TestCase):
# Delete the manifest
def delete(url, token, parsed, conn, objnum):
- conn.request('DELETE', '%s/%s/manifest' % (parsed.path,
+ conn.request('DELETE', '%s/%s/manifest' % (
+ parsed.path,
self.container), '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(delete, objnum)
@@ -532,8 +519,9 @@ class TestObject(unittest.TestCase):
# Delete the third set of segments
def delete(url, token, parsed, conn, objnum):
- conn.request('DELETE', '%s/%s/segments3/%s' % (parsed.path,
- acontainer, str(objnum)), '', {'X-Auth-Token': token})
+ conn.request('DELETE', '%s/%s/segments3/%s' % (
+ parsed.path, acontainer, str(objnum)), '',
+ {'X-Auth-Token': token})
return check_response(conn)
for objnum in xrange(len(segments3)):
resp = retry(delete, objnum)
@@ -542,8 +530,9 @@ class TestObject(unittest.TestCase):
# Delete the second set of segments
def delete(url, token, parsed, conn, objnum):
- conn.request('DELETE', '%s/%s/segments2/%s' % (parsed.path,
- self.container, str(objnum)), '', {'X-Auth-Token': token})
+ conn.request('DELETE', '%s/%s/segments2/%s' % (
+ parsed.path, self.container, str(objnum)), '',
+ {'X-Auth-Token': token})
return check_response(conn)
for objnum in xrange(len(segments2)):
resp = retry(delete, objnum)
@@ -552,8 +541,9 @@ class TestObject(unittest.TestCase):
# Delete the first set of segments
def delete(url, token, parsed, conn, objnum):
- conn.request('DELETE', '%s/%s/segments1/%s' % (parsed.path,
- self.container, str(objnum)), '', {'X-Auth-Token': token})
+ conn.request('DELETE', '%s/%s/segments1/%s' % (
+ parsed.path, self.container, str(objnum)), '',
+ {'X-Auth-Token': token})
return check_response(conn)
for objnum in xrange(len(segments1)):
resp = retry(delete, objnum)
@@ -563,7 +553,7 @@ class TestObject(unittest.TestCase):
# Delete the extra container
def delete(url, token, parsed, conn):
conn.request('DELETE', '%s/%s' % (parsed.path, acontainer), '',
- {'X-Auth-Token': token})
+ {'X-Auth-Token': token})
return check_response(conn)
resp = retry(delete)
resp.read()
@@ -574,8 +564,8 @@ class TestObject(unittest.TestCase):
raise SkipTest
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/hi' % (parsed.path,
- self.container), 'there', {'X-Auth-Token': token})
+ conn.request('PUT', '%s/%s/hi' % (parsed.path, self.container),
+ 'there', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(put)
resp.read()
@@ -583,7 +573,7 @@ class TestObject(unittest.TestCase):
def delete(url, token, parsed, conn):
conn.request('DELETE', '%s/%s/hi' % (parsed.path, self.container),
- '', {'X-Auth-Token': token})
+ '', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(delete)
resp.read()
@@ -596,7 +586,8 @@ class TestObject(unittest.TestCase):
raise SkipTest
def put(url, token, parsed, conn):
- conn.request('PUT', '%s/%s/abc%%00def' % (parsed.path,
+ conn.request('PUT', '%s/%s/abc%%00def' % (
+ parsed.path,
self.container), 'test', {'X-Auth-Token': token})
return check_response(conn)
resp = retry(put)