Fix test S3Api middleware instance name from swift3

Change-Id: Ic5e4c877aac5e607c197cec33c55fe1057a7385b
This commit is contained in:
Kota Tsuyuzaki 2018-03-27 15:39:50 +09:00
parent ae8f8ad5be
commit c48430ba81
8 changed files with 35 additions and 35 deletions

View File

@ -78,7 +78,7 @@ class S3ApiTestCase(unittest.TestCase):
self.app = FakeApp()
self.swift = self.app.swift
self.swift3 = S3ApiMiddleware(self.app, self.conf)
self.s3api = S3ApiMiddleware(self.app, self.conf)
self.swift.register('HEAD', '/v1/AUTH_test',
swob.HTTPOk, {}, None)
@ -160,4 +160,4 @@ class S3ApiTestCase(unittest.TestCase):
return status[0], headers[0], body
def call_s3api(self, req, **kwargs):
return self.call_app(req, app=self.swift3, **kwargs)
return self.call_app(req, app=self.s3api, **kwargs)

View File

@ -35,7 +35,7 @@ class TestS3ApiLocation(S3ApiTestCase):
self.assertIsNone(location)
def test_object_location_setting_as_us_west_1(self):
self.swift3.conf.location = 'us-west-1'
self.s3api.conf.location = 'us-west-1'
req = Request.blank('/bucket?location',
environ={'REQUEST_METHOD': 'GET'},
headers={'Authorization': 'AWS test:tester:hmac',

View File

@ -77,7 +77,7 @@ class TestS3ApiMultiUpload(S3ApiTestCase):
self.last_modified = 'Fri, 01 Apr 2014 12:00:00 GMT'
put_headers = {'etag': self.etag, 'last-modified': self.last_modified}
self.swift3.conf.min_segment_size = 1
self.s3api.conf.min_segment_size = 1
objects = map(lambda item: {'name': item[0], 'last_modified': item[1],
'hash': item[2], 'bytes': item[3]},
@ -755,7 +755,7 @@ class TestS3ApiMultiUpload(S3ApiTestCase):
self.assertEqual(self._get_error_message(body), msg)
self.swift.clear_calls()
self.swift3.conf.min_segment_size = 5242880
self.s3api.conf.min_segment_size = 5242880
req = Request.blank(
'/bucket/object?uploadId=X',
environ={'REQUEST_METHOD': 'POST'},
@ -1175,7 +1175,7 @@ class TestS3ApiMultiUpload(S3ApiTestCase):
def test_object_list_parts_over_max_parts(self):
req = Request.blank('/bucket/object?uploadId=X&max-parts=%d' %
(self.swift3.conf.max_parts_listing + 1),
(self.s3api.conf.max_parts_listing + 1),
environ={'REQUEST_METHOD': 'GET'},
headers={'Authorization': 'AWS test:tester:hmac',
'Date': self.get_date_header()})
@ -1244,7 +1244,7 @@ class TestS3ApiMultiUpload(S3ApiTestCase):
self.assertEqual(self._get_error_code(body), 'InvalidArgument')
def test_object_list_parts_over_part_number_marker(self):
part_number_marker = str(self.swift3.conf.max_upload_part_num + 1)
part_number_marker = str(self.s3api.conf.max_upload_part_num + 1)
req = Request.blank('/bucket/object?uploadId=X&'
'part-number-marker=%s' % part_number_marker,
environ={'REQUEST_METHOD': 'GET'},

View File

@ -781,7 +781,7 @@ class TestS3ApiObj(S3ApiTestCase):
@s3acl
def test_object_DELETE_no_multipart(self):
self.swift3.conf.allow_multipart_uploads = False
self.s3api.conf.allow_multipart_uploads = False
req = Request.blank('/bucket/object',
environ={'REQUEST_METHOD': 'DELETE'},
headers={'Authorization': 'AWS test:tester:hmac',

View File

@ -89,7 +89,7 @@ class TestRequest(S3ApiTestCase):
def setUp(self):
super(TestRequest, self).setUp()
self.swift3.conf.s3_acl = True
self.s3api.conf.s3_acl = True
self.swift.s3_acl = True
@patch('swift.common.middleware.s3api.acl_handlers.ACL_MAP', Fake_ACL_MAP)
@ -126,10 +126,10 @@ class TestRequest(S3ApiTestCase):
mock_get_resp.return_value = fake_swift_resp \
or FakeResponse(self.conf.s3_acl)
return mock_get_resp, m_check_permission,\
s3_req.get_response(self.swift3)
s3_req.get_response(self.s3api)
def test_get_response_without_s3_acl(self):
self.swift3.conf.s3_acl = False
self.s3api.conf.s3_acl = False
self.swift.s3_acl = False
mock_get_resp, m_check_permission, s3_resp = \
self._test_get_response('HEAD')

View File

@ -78,7 +78,7 @@ def s3acl(func=None, s3acl_only=False):
call_func()
instance.swift._calls = []
instance.swift3.conf.s3_acl = True
instance.s3api.conf.s3_acl = True
instance.swift.s3_acl = True
owner = Owner('test:tester', 'test:tester')
generate_s3acl_environ('test', instance.swift, owner)
@ -160,7 +160,7 @@ class TestS3ApiS3Acl(S3ApiTestCase):
def setUp(self):
super(TestS3ApiS3Acl, self).setUp()
self.swift3.conf.s3_acl = True
self.s3api.conf.s3_acl = True
self.swift.s3_acl = True
account = 'test'
@ -169,7 +169,7 @@ class TestS3ApiS3Acl(S3ApiTestCase):
generate_s3acl_environ(account, self.swift, self.default_owner)
def tearDown(self):
self.swift3.conf.s3_acl = False
self.s3api.conf.s3_acl = False
def test_bucket_acl_PUT_with_other_owner(self):
req = Request.blank('/bucket?acl',
@ -507,7 +507,7 @@ class TestS3ApiS3Acl(S3ApiTestCase):
class FakeClass(object):
def __init__(self):
self.swift3 = MagicMock()
self.s3api = MagicMock()
self.swift = FakeSwift()
@s3acl
@ -520,12 +520,12 @@ class TestS3ApiS3Acl(S3ApiTestCase):
@s3acl(s3acl_only=True)
def s3acl_s3only_error(self):
if self.swift3.conf.s3_acl:
if self.s3api.conf.s3_acl:
raise TypeError()
@s3acl(s3acl_only=True)
def s3acl_s3only_no_error(self):
if not self.swift3.conf.s3_acl:
if not self.s3api.conf.s3_acl:
raise TypeError()
fake_class = FakeClass()

View File

@ -538,36 +538,36 @@ class TestS3ApiMiddleware(S3ApiTestCase):
self.conf.__file__ = ''
pipeline.return_value = 's3api tempauth proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
# This *should* still work; authtoken will remove our auth details,
# but the X-Auth-Token we drop in will remain
# if we found one in the response
pipeline.return_value = 's3api s3token authtoken keystoneauth ' \
'proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
# This should work now; no more doubled-up requests to keystone!
pipeline.return_value = 's3api s3token keystoneauth proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 's3api swauth proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
# Note that authtoken would need to have delay_auth_decision=True
pipeline.return_value = 's3api authtoken s3token keystoneauth ' \
'proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 's3api proxy-server'
with self.assertRaises(ValueError) as cm:
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
self.assertIn('expected auth between s3api and proxy-server',
cm.exception.message)
pipeline.return_value = 'proxy-server'
with self.assertRaises(ValueError) as cm:
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
self.assertIn("missing filters ['s3api']",
cm.exception.message)
@ -580,25 +580,25 @@ class TestS3ApiMiddleware(S3ApiTestCase):
self.conf.__file__ = ''
pipeline.return_value = 's3api tempauth proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 's3api s3token authtoken keystoneauth ' \
'proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 's3api swauth proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 's3api authtoken s3token keystoneauth ' \
'proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 's3api proxy-server'
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
pipeline.return_value = 'proxy-server'
with self.assertRaises(ValueError):
self.swift3.check_pipeline(self.conf)
self.s3api.check_pipeline(self.conf)
def test_signature_v4(self):
environ = {
@ -911,7 +911,7 @@ class TestS3ApiMiddleware(S3ApiTestCase):
self.swift, {'operator_roles': 'swift-user'})
self.s3_token = S3Token(
self.keystone_auth, {'auth_uri': 'https://fakehost/identity'})
self.swift3 = S3ApiMiddleware(self.s3_token, self.conf)
self.s3api = S3ApiMiddleware(self.s3_token, self.conf)
req = Request.blank(
'/bucket',
environ={'REQUEST_METHOD': 'PUT'},
@ -937,7 +937,7 @@ class TestS3ApiMiddleware(S3ApiTestCase):
self.swift, {'operator_roles': 'swift-user'})
self.s3_token = S3Token(
self.keystone_auth, {'auth_uri': 'https://fakehost/identity'})
self.swift3 = S3ApiMiddleware(self.s3_token, self.conf)
self.s3api = S3ApiMiddleware(self.s3_token, self.conf)
req = Request.blank(
'/bucket',
environ={'REQUEST_METHOD': 'PUT'},
@ -965,7 +965,7 @@ class TestS3ApiMiddleware(S3ApiTestCase):
self.keystone_auth, {'delay_auth_decision': 'True'})
self.s3_token = S3Token(
self.auth_token, {'auth_uri': 'https://fakehost/identity'})
self.swift3 = S3ApiMiddleware(self.s3_token, self.conf)
self.s3api = S3ApiMiddleware(self.s3_token, self.conf)
req = Request.blank(
'/bucket',
environ={'REQUEST_METHOD': 'PUT'},
@ -1003,7 +1003,7 @@ class TestS3ApiMiddleware(S3ApiTestCase):
self.keystone_auth, {'delay_auth_decision': 'True'})
self.s3_token = S3Token(
self.auth_token, {'auth_uri': 'https://fakehost/identity'})
self.swift3 = S3ApiMiddleware(self.s3_token, self.conf)
self.s3api = S3ApiMiddleware(self.s3_token, self.conf)
req = Request.blank(
'/bucket',
environ={'REQUEST_METHOD': 'PUT'},

View File

@ -136,7 +136,7 @@ class TestS3ApiService(S3ApiTestCase):
self.assertTrue(i[0] in names)
def _test_service_GET_for_check_bucket_owner(self, buckets):
self.swift3.conf.check_bucket_owner = True
self.s3api.conf.check_bucket_owner = True
bucket_list = create_bucket_list_json(buckets)
self.swift.register('GET', '/v1/AUTH_test', swob.HTTPOk, {},
bucket_list)